Class: Straight

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/straight-api.rb,
lib/straight-api/version.rb

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Constructor Details

#initialize(uri, gateway, options = {}) ⇒ Straight

Returns a new instance of Straight.



9
10
11
12
# File 'lib/straight-api.rb', line 9

def initialize (uri, gateway, options={})
  self.class.base_uri "#{uri}/gateways/#{gateway}"
  @options = {query: options}
end

Instance Method Details

#create(amount, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/straight-api.rb', line 14

def create (amount, options={})
  options.merge!(@options)
  options.merge!({amount: amount})
  options = {query: options}
  Hashie::Mash.new(JSON.parse(self.class.post('/orders', options)))
end

#get(id, options = {}) ⇒ Object



21
22
23
24
25
# File 'lib/straight-api.rb', line 21

def get (id, options={})
  options.merge!(@options)
  options = {query: options}
  Hashie::Mash.new(JSON.parse(self.class.get("/orders/#{id}", options)))
end