class OandaAPI::Client::UsernameClient

:nocov:

DEPRECATED: The Sandbox API endpoint is no longer supported by Oanda. @deprecated Please use {OandaAPI::Client::TokenClient} with a practice account instead.

Makes requests to the API. Instances access the Oanda sandbox environment. Most client requests require a valid Oanda sandbox account username. See the Oanda Development Guide for information about {developer.oanda.com/rest-live/accounts/#createTestAccount creating a test account}.

@example Example usage (creates a new test account).

client = OandaAPI::Client::UsernameClient.new "_"  # Note: A new test account can be created without having an
                                                   # existing account, which is why we create a client in this
                                                   # example with a bogus username ("_").
new_account = client.account.create                # => OandaAPI::Resource::Account
new_account.username                               # => "<username>"

@!attribute [r] domain

@return [Symbol] identifies the Oanda subdomain (`:sandbox`) which the
  client accesses.

@!attribute [r] username

@return [String] the username used for authentication.

@!attribute [rw] default_params

@return [Hash] parameters that are included with every API request as
  either query or url_form encoded parameters.

@!attribute [rw] headers

@return [Hash] parameters that are included with every API request as
  HTTP headers.

Attributes

default_params[RW]
domain[R]
headers[RW]
username[R]

Public Class Methods

new(username, options={}) click to toggle source

@param [String] username used for authentication.

Calls superclass method OandaAPI::Client::new
# File lib/oanda_api/client/username_client.rb, line 43
def initialize(username, options={})
  warn Kernel.caller.first + " [DEPRECATION] `OandaAPI::Client::UsernameClient` is deprecated.  Please use `OandaAPI::Client::TokenClient` instead."
  super options
  @domain = :sandbox
  @username = username
  @default_params = auth
  @headers = {}
end

Public Instance Methods

auth() click to toggle source

Parameters used for authentication. @return [Hash]

# File lib/oanda_api/client/username_client.rb, line 54
def auth
  { "username" => @username }
end