Class: Gman::Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GmanClient::Utility

#attempt, #convert_payload, #get, #request, #token

Methods included from GmanClient::CommodityMerchandising::BulkContracts

#bulk_contracts

Methods included from GmanClient::CommodityMerchandising::Contracts

#clean_filters, #contracts

Methods included from GmanClient::Api::HealthCheck

#health_check

Methods included from GmanClient::Api::PickUpOrders

#pick_up_orders

Methods included from GmanClient::Api::Orders

#order, #orders

Methods included from GmanClient::Api::CustomerContracts

#customer_contracts

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



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

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.



13
14
15
# File 'lib/gman/client.rb', line 13

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



13
14
15
# File 'lib/gman/client.rb', line 13

def client_secret
  @client_secret
end

#urlObject

Returns the value of attribute url.



13
14
15
# File 'lib/gman/client.rb', line 13

def url
  @url
end

Instance Method Details

#driver_commission_historiesObject



28
29
30
31
32
33
# File 'lib/gman/client.rb', line 28

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



35
36
37
38
39
40
41
42
43
44
# File 'lib/gman/client.rb', line 35

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



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

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

#inventory_itemsObject



46
47
48
49
# File 'lib/gman/client.rb', line 46

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

#inventory_items_by_id(item_id) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/gman/client.rb', line 69

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



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/gman/client.rb', line 51

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