Class: ApiController

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

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, token) ⇒ ApiController

Returns a new instance of ApiController.



8
9
10
11
# File 'lib/api_controller.rb', line 8

def initialize(endpoint, token)
  @endpoint = endpoint
  @auth_token = token
end

Instance Method Details

#post_order(market, price, volume, type) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/api_controller.rb', line 13

def post_order(market, price, volume, type)
  response = RestClient.post("#{@endpoint}/orders",
                             {
                               'market': market,
                               'side': type.to_s,
                               'volume': volume.to_s,
                               'price': price.to_s,
                               'ord_type': 'limit'
                             },
                             { 'Authorization': "Bearer #{@auth_token}",
                              'content_type': 'application/x-www-form-urlencoded'})
  #puts response
end