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_number(organization, number, incoming = {}) ⇒ 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_number(organization, number, order_estimate_form, incoming = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ OrderEstimates
Returns a new instance of OrderEstimates.
1416 1417 1418 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1416 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get_by_number(organization, number, incoming = {}) ⇒ Object
1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1440 def get_by_number(organization, number, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/order-estimates/#{CGI.escape(number)}").with_query(query).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.
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1424 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)), :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, 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_number(organization, number, order_estimate_form, incoming = {}) ⇒ Object
1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1451 def put_by_number(organization, number, order_estimate_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, 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)), :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, 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(number)}").with_query(query).with_json(order_estimate_form.to_json).put ::Io::Flow::V0::Models::OrderEstimate.new(r) end |