Class: WeShipClient::Interactors::ProcessOrders
- Inherits:
-
Object
- Object
- WeShipClient::Interactors::ProcessOrders
- Defined in:
- lib/we_ship_client/interactors/process_orders.rb
Overview
Class to interact with the /process_orders API endpoint.
Instance Method Summary collapse
-
#call ⇒ Entities::Responses::ProcessOrders
Sends orders to be processed.
-
#initialize(auth_token:, process_orders_request:) ⇒ ProcessOrders
constructor
A new instance of ProcessOrders.
Constructor Details
#initialize(auth_token:, process_orders_request:) ⇒ ProcessOrders
Returns a new instance of ProcessOrders.
13 14 15 16 |
# File 'lib/we_ship_client/interactors/process_orders.rb', line 13 def initialize(auth_token:, process_orders_request:) @auth_token = auth_token @process_orders_request = process_orders_request end |
Instance Method Details
#call ⇒ Entities::Responses::ProcessOrders
Sends orders to be processed.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/we_ship_client/interactors/process_orders.rb', line 23 def call json_response = client.http_client.post( "#{client.base_url}/process_orders", data: process_orders_request.to_h, headers: { Authorization: "JWT #{auth_token}" } ) handle_exception(json_response) unless json_response.status == 200 response_hash = JSON.parse(json_response.body, symbolize_names: true) response_class.new(response_hash[:response]) end |