Class: Io::Flow::V0::Clients::ShippingLabels
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::ShippingLabels
- 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_crossdock_and_labels_and_barcode_by_barcode(organization, barcode) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ ShippingLabels
constructor
A new instance of ShippingLabels.
- #post(organization, shipping_label_form, incoming = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ ShippingLabels
Returns a new instance of ShippingLabels.
4829 4830 4831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4829 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4833 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) }), :order_number => (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('order_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) }), :show_commercial_invoice => (x = opts.delete(:show_commercial_invoice); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('show_commercial_invoice', x)), :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)}/shipping_labels").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ShippingLabel.new(x) } end |
#get_by_id(organization, id) ⇒ Object
4886 4887 4888 4889 4890 4891 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4886 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)}/shipping_labels/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::ShippingLabel.new(r) end |
#get_crossdock_and_labels_and_barcode_by_barcode(organization, barcode) ⇒ Object
4865 4866 4867 4868 4869 4870 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4865 def (organization, ) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('barcode', , String) r = @client.request("/#{CGI.escape(organization)}/shipping_labels/crossdock/labels/#{CGI.escape()}/barcode").get ::Io::Flow::V0::Models::ShippingLabel.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4872 def get_versions(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) }), :label => (x = opts.delete(:label); x.nil? ? nil : HttpClient::Preconditions.assert_class('label', x, Array).map { |v| HttpClient::Preconditions.assert_class('label', 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? ? "journal_timestamp" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/shipping_labels/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ShippingLabelVersion.new(x) } end |
#post(organization, shipping_label_form, incoming = {}) ⇒ Object
4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4851 def post(organization, shipping_label_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :show_commercial_invoice => (x = opts.delete(:show_commercial_invoice); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('show_commercial_invoice', x)), :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String)), :force_new => (x = opts.delete(:force_new); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('force_new', x)), :include_pdf_data => (x = opts.delete(:include_pdf_data); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('include_pdf_data', x)) }.delete_if { |k, v| v.nil? } (x = shipping_label_form; x.is_a?(::Io::Flow::V0::Models::ShippingLabelForm) ? x : ::Io::Flow::V0::Models::ShippingLabelForm.from_json(x)) r = @client.request("/#{CGI.escape(organization)}/shipping_labels").with_query(query).with_json(shipping_label_form.to_json).post ::Io::Flow::V0::Models::ShippingLabel.new(r) end |