Class: Io::Flow::V0::Clients::Quotes
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Quotes
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get(organization, incoming = {}) ⇒ Object
Search quotes.
- #get_by_id(organization, id) ⇒ Object
-
#initialize(client) ⇒ Quotes
constructor
A new instance of Quotes.
- #post(organization, quote_form, incoming = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Quotes
Returns a new instance of Quotes.
4224 4225 4226 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4224 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
Search quotes. Always paginated.
4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4229 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) }), :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)}/quotes").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Quote.new(x) } end |
#get_by_id(organization, id) ⇒ Object
4253 4254 4255 4256 4257 4258 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4253 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)}/quotes/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Quote.new(r) end |
#post(organization, quote_form, incoming = {}) ⇒ Object
4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4242 def post(organization, quote_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String)) }.delete_if { |k, v| v.nil? } (x = quote_form; x.is_a?(::Io::Flow::V0::Models::QuoteForm) ? x : ::Io::Flow::V0::Models::QuoteForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/quotes").with_query(query).with_json(quote_form.to_json).post ::Io::Flow::V0::Models::Quote.new(r) end |