Module: Buttercoin::Client::OrderMethods

Included in:
Buttercoin::Client
Defined in:
lib/buttercoin/client/order_methods.rb

Instance Method Summary collapse

Instance Method Details

#cancel_order(orderId, timestamp = nil) ⇒ Object

Cancel order by id

Parameters:

  • timestamp (defaults to: nil)

    integer (optional)

Returns:

  • Hashie object containing status and success message



60
61
62
# File 'lib/buttercoin/client/order_methods.rb', line 60

def cancel_order(orderId, timestamp=nil)
  delete '/orders/'+orderId, timestamp
end

#create_order(options, timestamp = nil) ⇒ Object

Create new order with the given params

Parameters:

  • timestamp (defaults to: nil)

    integer (optional)

  • options

    Hash (required) order params

Returns:

  • string containing response location header url



49
50
51
# File 'lib/buttercoin/client/order_methods.rb', line 49

def create_order(options, timestamp=nil)
  post '/orders', timestamp, options
end

#get_order_by_id(orderId, timestamp = nil) ⇒ Object

Retrieve the order by id

Parameters:

  • timestamp (defaults to: nil)

    integer (optional)

Returns:

  • Hashie object containing order info



12
13
14
# File 'lib/buttercoin/client/order_methods.rb', line 12

def get_order_by_id(orderId, timestamp=nil)
  get '/orders/'+orderId, timestamp
end

#get_order_by_url(url, timestamp = nil) ⇒ Object

Retrieve the order by url

Parameters:

  • url

    full url of the order request

  • timestamp (defaults to: nil)

    integer (optional)

Returns:

  • Hashie object containing order info

Raises:



23
24
25
26
27
28
# File 'lib/buttercoin/client/order_methods.rb', line 23

def get_order_by_url(url, timestamp=nil)
  index = url.rindex('/orders')
  raise Error.new('Url not correctly formatted for orders') if index.nil?
  path = url[index..-1]
  get path, timestamp
end

#get_orders(options = {}, timestamp = nil) ⇒ Object

Get list of orders by search criteria

Parameters:

  • timestamp (defaults to: nil)

    integer (optional)

  • options (defaults to: {})

    Hash (optional) criteria to filter list

Returns:

  • Hashie object containing list of orders



37
38
39
40
# File 'lib/buttercoin/client/order_methods.rb', line 37

def get_orders(options={}, timestamp=nil)
  mash = get '/orders', timestamp, options
  mash.results
end