Class: Io::Flow::V0::Clients::Manifests
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Manifests
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
-
#get_services_and_outstanding_by_service(organization, service) ⇒ Object
Generates a new manifest with all outstanding labels and redirects to a downloadable PDF of carrier-generated manifest or bill of lading (BOL).
-
#initialize(client) ⇒ Manifests
constructor
A new instance of Manifests.
-
#post(organization, manifest_form) ⇒ Object
Creates a new manifest/carrier BOL with specific tracking numbers.
Constructor Details
#initialize(client) ⇒ Manifests
Returns a new instance of Manifests.
3779 3780 3781 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3779 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3783 def get(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :carrier_tracking_number => (x = opts.delete(:carrier_tracking_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('carrier_tracking_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('carrier_tracking_number', v, String) }), :flow_tracking_number => (x = opts.delete(:flow_tracking_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('flow_tracking_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('flow_tracking_number', v, String) }), :service => (x = opts.delete(:service); x.nil? ? nil : HttpClient::Preconditions.assert_class('service', x, Array).map { |v| HttpClient::Preconditions.assert_class('service', v, String) }), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/manifests").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Manifest.new(x) } end |
#get_by_id(organization, id) ⇒ Object
3817 3818 3819 3820 3821 3822 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3817 def get_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/manifests/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Manifest.new(r) end |
#get_services_and_outstanding_by_service(organization, service) ⇒ Object
Generates a new manifest with all outstanding labels and redirects to a downloadable PDF of carrier-generated manifest or bill of lading (BOL). If no outstanding labels, this will generate a 422 error.
3810 3811 3812 3813 3814 3815 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3810 def get_services_and_outstanding_by_service(organization, service) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('service', service, String) r = @client.request("/#{CGI.escape(organization)}/manifests/services/#{CGI.escape(service)}/outstanding").get r end |
#post(organization, manifest_form) ⇒ Object
Creates a new manifest/carrier BOL with specific tracking numbers
3800 3801 3802 3803 3804 3805 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3800 def post(organization, manifest_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = manifest_form; x.is_a?(::Io::Flow::V0::Models::ManifestForm) ? x : ::Io::Flow::V0::Models::ManifestForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/manifests").with_json(manifest_form.to_json).post ::Io::Flow::V0::Models::Manifest.new(r) end |