Class: Gman::Client

Inherits:
Object
  • Object
show all
Includes:
GmanClient::Api::Orders, GmanClient::CommodityMerchandising::Contracts, GmanClient::Utility
Defined in:
lib/gman/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GmanClient::Utility

#attempt, #convert_payload, #request, #token

Methods included from GmanClient::CommodityMerchandising::Contracts

#clean_filters, #contracts

Methods included from GmanClient::Api::Orders

#order

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
# File 'lib/gman/client.rb', line 9

def initialize(options)
  @url = options[:url]
  @token_url = "#{url}/oauth/token"
  @client_id = options[:client_id]
  @client_secret = options[:client_secret]
  @retry_attempts = options[:retries] || 3
end

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



7
8
9
# File 'lib/gman/client.rb', line 7

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



7
8
9
# File 'lib/gman/client.rb', line 7

def client_secret
  @client_secret
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/gman/client.rb', line 7

def url
  @url
end

Instance Method Details

#driver_commission_historiesObject



22
23
24
25
26
27
# File 'lib/gman/client.rb', line 22

def driver_commission_histories
  response = attempt(3) do
    request.api.v1.driver_commissions_history.get
  end
  convert_payload(response)
end

#driver_commission_histories_by_paid_date(paid_date) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/gman/client.rb', line 29

def driver_commission_histories_by_paid_date(paid_date)
  response = attempt(3) do
    request
      .api
      .v1
      .driver_commissions_history_by_paid_date
      .get(params: { paid_date: paid_date })
  end
  convert_payload(response)
end

#driversObject



17
18
19
20
# File 'lib/gman/client.rb', line 17

def drivers
  response = attempt(3) { request.api.v1.drivers.get }
  convert_payload(response)
end

#inventory_itemsObject



40
41
42
43
# File 'lib/gman/client.rb', line 40

def inventory_items
  response = attempt(3) { request.api.v1.inventory.items.get }
  convert_payload(response)
end

#inventory_items_by_id(item_id) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gman/client.rb', line 62

def inventory_items_by_id(item_id)
  response = attempt(3) do
    request
      .api
      .v1
      .inventory
      .items_by_id
      .get(params: { item_id: item_id })
  end
  convert_payload([response].flatten)
end

#inventory_items_like_id_description(item_id, in_item_description) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/gman/client.rb', line 45

def inventory_items_like_id_description(item_id, in_item_description)
  response = attempt(3) do
    request
      .api
      .v1
      .inventory
      .items_like_id_description
      .get(params:
            {
              item_id: item_id,
              in_item_description: in_item_description
            }
          )
  end
  convert_payload(response)
end