Class: WeighflowCli::Client
- Inherits:
-
Object
- Object
- WeighflowCli::Client
- Includes:
- HTTParty
- Defined in:
- lib/weighflow_cli/client.rb
Instance Method Summary collapse
- #auth_headers(token) ⇒ Object
- #bulk_inventory_inbound_truck ⇒ Object
- #bulk_inventory_outbound_truck ⇒ Object
- #commodity_inbound_truck ⇒ Object
- #commodity_outbound_truck ⇒ Object
- #create_weight(params: {}) ⇒ Object
-
#initialize(config = {}) ⇒ Client
constructor
A new instance of Client.
- #status ⇒ Object
- #void_weight(weight_id, reason) ⇒ Object
- #weights ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/weighflow_cli/client.rb', line 7 def initialize(config = {}) self.class.headers auth_headers(config[:secret].to_s) self.class.base_uri config[:url].to_s end |
Instance Method Details
#auth_headers(token) ⇒ Object
12 13 14 |
# File 'lib/weighflow_cli/client.rb', line 12 def auth_headers(token) { 'Authorization' => "Token #{token}"} end |
#bulk_inventory_inbound_truck ⇒ Object
46 47 48 |
# File 'lib/weighflow_cli/client.rb', line 46 def bulk_inventory_inbound_truck find_orders(selection: 'II') end |
#bulk_inventory_outbound_truck ⇒ Object
51 52 53 |
# File 'lib/weighflow_cli/client.rb', line 51 def bulk_inventory_outbound_truck find_orders(selection: 'OI') end |
#commodity_inbound_truck ⇒ Object
42 43 44 |
# File 'lib/weighflow_cli/client.rb', line 42 def commodity_inbound_truck find_orders(selection: 'IC') end |
#commodity_outbound_truck ⇒ Object
38 39 40 |
# File 'lib/weighflow_cli/client.rb', line 38 def commodity_outbound_truck find_orders(selection: 'OC') end |
#create_weight(params: {}) ⇒ Object
22 23 24 25 |
# File 'lib/weighflow_cli/client.rb', line 22 def create_weight(params: {}) response = self.class.post('/weights', body: params) render_json(response) end |
#status ⇒ Object
17 18 19 20 |
# File 'lib/weighflow_cli/client.rb', line 17 def status response = self.class.get('/') render_json(response) end |
#void_weight(weight_id, reason) ⇒ Object
27 28 29 30 |
# File 'lib/weighflow_cli/client.rb', line 27 def void_weight(weight_id, reason) response = self.class.delete("/weights/#{weight_id}", body: { reason: reason }) render_json(response) end |
#weights ⇒ Object
32 33 34 35 |
# File 'lib/weighflow_cli/client.rb', line 32 def weights response = self.class.get('/weights') render_json(response) end |