Class: OandaAPI::Client::UsernameClient Deprecated

Inherits:
Object
  • Object
show all
Includes:
OandaAPI::Client
Defined in:
lib/oanda_api/client/username_client.rb

Overview

Deprecated.

Please use TokenClient with a practice account instead.

:nocov:

DEPRECATED: The Sandbox API endpoint is no longer supported by Oanda. 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 creating a test account.

Examples:

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 ("_").
 = client..create                # => OandaAPI::Resource::Account
.username                               # => "<username>"

Constant Summary

Constants included from OandaAPI::Client

BASE_URI

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OandaAPI::Client

#api_uri, #execute_request, last_request_at, last_request_at=, last_throttled_at, #load_persistent_connection_adapter, map_method_to_http_verb, #proc, throttle_request_rate

Constructor Details

#initialize(username, options = {}) ⇒ UsernameClient

Returns a new instance of UsernameClient.

Parameters:

  • username (String)

    used for authentication.



43
44
45
46
47
48
49
50
# 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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OandaAPI::Client

Instance Attribute Details

#default_paramsHash

Returns parameters that are included with every API request as either query or url_form encoded parameters.

Returns:

  • (Hash)

    parameters that are included with every API request as either query or url_form encoded parameters.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/oanda_api/client/username_client.rb', line 36

class UsernameClient
  include Client

  attr_reader :domain, :username
  attr_accessor :default_params, :headers

  # @param [String] username used for authentication.
  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

  # Parameters used for authentication.
  # @return [Hash]
  def auth
    { "username" => @username }
  end
end

#domainSymbol (readonly)

Returns identifies the Oanda subdomain (:sandbox) which the client accesses.

Returns:

  • (Symbol)

    identifies the Oanda subdomain (:sandbox) which the client accesses.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/oanda_api/client/username_client.rb', line 36

class UsernameClient
  include Client

  attr_reader :domain, :username
  attr_accessor :default_params, :headers

  # @param [String] username used for authentication.
  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

  # Parameters used for authentication.
  # @return [Hash]
  def auth
    { "username" => @username }
  end
end

#headersHash

Returns parameters that are included with every API request as HTTP headers.

Returns:

  • (Hash)

    parameters that are included with every API request as HTTP headers.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/oanda_api/client/username_client.rb', line 36

class UsernameClient
  include Client

  attr_reader :domain, :username
  attr_accessor :default_params, :headers

  # @param [String] username used for authentication.
  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

  # Parameters used for authentication.
  # @return [Hash]
  def auth
    { "username" => @username }
  end
end

#usernameString (readonly)

Returns the username used for authentication.

Returns:

  • (String)

    the username used for authentication.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/oanda_api/client/username_client.rb', line 36

class UsernameClient
  include Client

  attr_reader :domain, :username
  attr_accessor :default_params, :headers

  # @param [String] username used for authentication.
  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

  # Parameters used for authentication.
  # @return [Hash]
  def auth
    { "username" => @username }
  end
end

Instance Method Details

#authHash

Parameters used for authentication.

Returns:

  • (Hash)


54
55
56
# File 'lib/oanda_api/client/username_client.rb', line 54

def auth
  { "username" => @username }
end