Class: Io::Flow::V0::Clients::OrderEstimates
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::OrderEstimates
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get_by_id(organization, id) ⇒ Object
-
#initialize(client) ⇒ OrderEstimates
constructor
A new instance of OrderEstimates.
-
#post(organization, order_estimate_form, incoming = {}) ⇒ Object
Create an order estimate, using the localized information from the experience selected by the query parameters.
- #put_by_id(organization, id, order_estimate_form, incoming = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ OrderEstimates
Returns a new instance of OrderEstimates.
1107 1108 1109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1107 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get_by_id(organization, id) ⇒ Object
1130 1131 1132 1133 1134 1135 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1130 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)}/order-estimates/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Experience.new(r) end |
#post(organization, order_estimate_form, incoming = {}) ⇒ Object
Create an order estimate, using the localized information from the experience selected by the query parameters. This is similar to the POST orders endpoint, except this just returns an estimate and cannot be submitted.
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1115 def post(organization, order_estimate_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, String)), :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)), :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)), :currency => (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String)), :language => (x = opts.delete(:language); x.nil? ? nil : HttpClient::Preconditions.assert_class('language', x, String)) }.delete_if { |k, v| v.nil? } (x = order_estimate_form; x.is_a?(::Io::Flow::V0::Models::OrderEstimateForm) ? x : ::Io::Flow::V0::Models::OrderEstimateForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/order-estimates").with_query(query).with_json(order_estimate_form.to_json).post ::Io::Flow::V0::Models::OrderEstimate.new(r) end |
#put_by_id(organization, id, order_estimate_form, incoming = {}) ⇒ Object
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1137 def put_by_id(organization, id, order_estimate_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, String)), :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)), :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)), :currency => (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String)), :language => (x = opts.delete(:language); x.nil? ? nil : HttpClient::Preconditions.assert_class('language', x, String)) }.delete_if { |k, v| v.nil? } (x = order_estimate_form; x.is_a?(::Io::Flow::V0::Models::OrderEstimateForm) ? x : ::Io::Flow::V0::Models::OrderEstimateForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/order-estimates/#{CGI.escape(id)}").with_query(query).with_json(order_estimate_form.to_json).put ::Io::Flow::V0::Models::OrderEstimate.new(r) end |