Class: Honeymaker::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/honeymaker/client.rb

Constant Summary collapse

OPTIONS =
{
  request: {
    open_timeout: 5,
    read_timeout: 30,
    write_timeout: 10
  }
}.freeze
RATE_LIMITS =
{
  default: 100,
  orders: 100
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, api_secret: nil, proxy: nil, logger: nil) ⇒ Client

Returns a new instance of Client.



25
26
27
28
29
30
# File 'lib/honeymaker/client.rb', line 25

def initialize(api_key: nil, api_secret: nil, proxy: nil, logger: nil)
  @api_key = api_key
  @api_secret = api_secret
  @proxy = proxy
  @logger = logger
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



23
24
25
# File 'lib/honeymaker/client.rb', line 23

def api_key
  @api_key
end

#api_secretObject (readonly)

Returns the value of attribute api_secret.



23
24
25
# File 'lib/honeymaker/client.rb', line 23

def api_secret
  @api_secret
end

Class Method Details

.rate_limitsObject



32
33
34
# File 'lib/honeymaker/client.rb', line 32

def self.rate_limits
  self::RATE_LIMITS
end

Instance Method Details

#get_balancesObject

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/honeymaker/client.rb', line 36

def get_balances
  raise NotImplementedError, "#{self.class} must implement #get_balances"
end

#validate(type = :trading) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/honeymaker/client.rb', line 40

def validate(type = :trading)
  return Result::Failure.new("No credentials provided") unless authenticated?

  case type
  when :trading then validate_trading_credentials
  when :read then validate_read_credentials
  else raise Error, "Unknown validation type: #{type}. Use :trading or :read"
  end
rescue Error
  raise
rescue StandardError => e
  Result::Failure.new(e.message)
end