Class: OandaAPI::Client::UsernameClient

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

Overview

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_throttled_at, map_method_to_http_verb, #proc, throttle_request_rate

Constructor Details

#initialize(username) ⇒ UsernameClient


38
39
40
41
42
43
44
# File 'lib/oanda_api/client/username_client.rb', line 38

def initialize(username)
  super()
  @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


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/oanda_api/client/username_client.rb', line 31

class UsernameClient
  include Client

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

  # @param [String] username used for authentication.
  def initialize(username)
    super()
    @domain = :sandbox
    @username = username
    @default_params = auth
    @headers = {}
  end

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

#domainSymbol (readonly)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/oanda_api/client/username_client.rb', line 31

class UsernameClient
  include Client

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

  # @param [String] username used for authentication.
  def initialize(username)
    super()
    @domain = :sandbox
    @username = username
    @default_params = auth
    @headers = {}
  end

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

#headersHash


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/oanda_api/client/username_client.rb', line 31

class UsernameClient
  include Client

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

  # @param [String] username used for authentication.
  def initialize(username)
    super()
    @domain = :sandbox
    @username = username
    @default_params = auth
    @headers = {}
  end

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

#usernameString (readonly)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/oanda_api/client/username_client.rb', line 31

class UsernameClient
  include Client

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

  # @param [String] username used for authentication.
  def initialize(username)
    super()
    @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.


48
49
50
# File 'lib/oanda_api/client/username_client.rb', line 48

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