Class: Workarea::Orderbot::Gateway

Inherits:
Object
  • Object
show all
Includes:
Authentication
Defined in:
lib/workarea/orderbot/gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Authentication

#token

Constructor Details

#initialize(options = {}) ⇒ Gateway

Returns a new instance of Gateway.



7
8
9
10
# File 'lib/workarea/orderbot/gateway.rb', line 7

def initialize(options = {})
  requires!(options, :api_user_name, :api_password)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/workarea/orderbot/gateway.rb', line 5

def options
  @options
end

Instance Method Details

#create_order(attrs = {}) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/workarea/orderbot/gateway.rb', line 39

def create_order(attrs = {})
  response = connection.post do |req|
    req.url "orders"
    req.body = attrs.to_json
  end

  Orderbot::Response.new(response)
end

#get_fulfillments(attrs = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/workarea/orderbot/gateway.rb', line 48

def get_fulfillments(attrs = {})
  response = connection.get do |req|
    req.options.params_encoder = Faraday::FlatParamsEncoder
    req.url "fulfillments"
    req.params = attrs
  end

  Orderbot::Response.new(response)
end

#get_inventory(attrs = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/workarea/orderbot/gateway.rb', line 21

def get_inventory(attrs = {})
  response = connection.get do |req|
    req.options.params_encoder = Faraday::FlatParamsEncoder
    req.url "inventory"
    req.params = attrs
  end
  Orderbot::Response.new(response)
end

#get_pricing(attrs = {}) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/workarea/orderbot/gateway.rb', line 30

def get_pricing(attrs = {})
  response = connection.get do |req|
    req.options.params_encoder = Faraday::FlatParamsEncoder
    req.url "pricing"
    req.params = attrs
  end
  Orderbot::Response.new(response)
end

#get_products(attrs = {}) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/workarea/orderbot/gateway.rb', line 12

def get_products(attrs = {})
  response = connection.get do |req|
    req.options.params_encoder = Faraday::FlatParamsEncoder
    req.url "products"
    req.params = attrs
  end
  Orderbot::Response.new(response)
end