Class: Io::Flow::V0::Clients::DeliveryWindows
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::DeliveryWindows
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get_summary(organization, incoming = {}) ⇒ Object
Endpoint to request a delivery window.
-
#get_summary_and_all(organization, incoming = {}) ⇒ Object
Endpoint to request all delivery windows across multiple destinations.
-
#initialize(client) ⇒ DeliveryWindows
constructor
A new instance of DeliveryWindows.
Constructor Details
#initialize(client) ⇒ DeliveryWindows
Returns a new instance of DeliveryWindows.
3928 3929 3930 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3928 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get_summary(organization, incoming = {}) ⇒ Object
Endpoint to request a delivery window. Requires some knowledge of origin (based on organization, center, or specified address string) and destination (based on ip, lat/long, or address string). Other attributes allow us to narrow down delivery windows even more such as service level to be used and timestamp of expected shipment date.
3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3937 def get_summary(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :strategy => (x = (x = opts.delete(:strategy); x.nil? ? "range" : x); x.is_a?(::Io::Flow::V0::Models::Strategy) ? x : ::Io::Flow::V0::Models::Strategy.apply(x)).value, :center => (x = opts.delete(:center); x.nil? ? nil : HttpClient::Preconditions.assert_class('center', x, String)), :origin => (x = opts.delete(:origin); x.nil? ? nil : HttpClient::Preconditions.assert_class('origin', x, String)), :destination => (x = opts.delete(:destination); x.nil? ? nil : HttpClient::Preconditions.assert_class('destination', x, String)), :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)), :latitude => (x = opts.delete(:latitude); x.nil? ? nil : HttpClient::Preconditions.assert_class('latitude', x, String)), :longitude => (x = opts.delete(:longitude); x.nil? ? nil : HttpClient::Preconditions.assert_class('longitude', x, String)), :service => (x = opts.delete(:service); x.nil? ? nil : HttpClient::Preconditions.assert_class('service', x, String)), :item_number => (x = opts.delete(:item_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('item_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('item_number', v, String) }), :min_lead_days => (x = opts.delete(:min_lead_days); x.nil? ? nil : HttpClient::Preconditions.assert_class('min_lead_days', x, Integer)), :max_lead_days => (x = opts.delete(:max_lead_days); x.nil? ? nil : HttpClient::Preconditions.assert_class('max_lead_days', x, Integer)), :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String)) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/delivery-windows/summary").with_query(query).get ::Io::Flow::V0::Models::DeliveryWindow.new(r) end |
#get_summary_and_all(organization, incoming = {}) ⇒ Object
Endpoint to request all delivery windows across multiple destinations.
3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3959 def get_summary_and_all(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :destination => (x = opts.delete(:destination); x.nil? ? nil : HttpClient::Preconditions.assert_class('destination', x, Array).map { |v| HttpClient::Preconditions.assert_class('destination', 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), :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String)) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/delivery-windows/summary/all").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::DeliveryWindowSummary.new(x) } end |