Class: FulfilApi::CustomerShipment
- Defined in:
- lib/fulfil_api/customer_shipment.rb
Overview
The CustomerShipment represents a single StockShipmentOut resource returned
by the API endpoints of Fulfil.
Constant Summary collapse
- MODEL_NAME =
"stock.shipment.out"
Class Method Summary collapse
-
.hold!(id_or_ids, note:) ⇒ Boolean
Sets the fulfillment status of the customer shipment on hold.
-
.unhold!(id_or_ids, note:) ⇒ Boolean
Unholds the fulfillment status of the customer shipment.
Instance Method Summary collapse
-
#hold(note) ⇒ Boolean
Sets the current customer shipment on hold, rescuing any errors that occur and handling them based on error type.
-
#unhold(note) ⇒ Boolean
Unholds the current customer shipment, rescuing any errors that occur and handling them based on error type.
Methods inherited from Resource
#[], #errors, #id, #initialize, relation, #to_h
Methods included from Resource::Serializable
Methods included from Resource::Persistable
#create, #create!, #save, #save!, #update, #update!
Methods included from Resource::Comparable
Methods included from Resource::AttributeAssignable
#assign_attribute, #assign_attributes
Constructor Details
This class inherits a constructor from FulfilApi::Resource
Class Method Details
.hold!(id_or_ids, note:) ⇒ Boolean
Sets the fulfillment status of the customer shipment on hold
22 23 24 25 |
# File 'lib/fulfil_api/customer_shipment.rb', line 22 def hold!(id_or_ids, note:) FulfilApi.client.put("/model/#{MODEL_NAME}/hold", body: [[*id_or_ids].flatten, note]) true end |
.unhold!(id_or_ids, note:) ⇒ Boolean
Unholds the fulfillment status of the customer shipment
40 41 42 43 |
# File 'lib/fulfil_api/customer_shipment.rb', line 40 def unhold!(id_or_ids, note:) FulfilApi.client.put("/model/#{MODEL_NAME}/unhold", body: [[*id_or_ids].flatten, note]) true end |
Instance Method Details
#hold(note) ⇒ Boolean
Sets the current customer shipment on hold, rescuing any errors that occur and handling them based on error type.
53 54 55 56 57 58 |
# File 'lib/fulfil_api/customer_shipment.rb', line 53 def hold(note) self.class.hold!(id, note: note) rescue FulfilApi::Error => e handle_exception(e) false end |
#unhold(note) ⇒ Boolean
Unholds the current customer shipment, rescuing any errors that occur and handling them based on error type.
67 68 69 70 71 72 |
# File 'lib/fulfil_api/customer_shipment.rb', line 67 def unhold(note) self.class.unhold!(id, note: note) rescue FulfilApi::Error => e handle_exception(e) false end |