Class: Io::Flow::V0::Clients::OrderIdentifiers
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::OrderIdentifiers
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_identifier(organization, identifier) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_identifier(organization, identifier) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ OrderIdentifiers
constructor
A new instance of OrderIdentifiers.
- #post(organization, order_identifier_form) ⇒ Object
- #put_by_identifier(organization, identifier, order_identifier_put_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ OrderIdentifiers
Returns a new instance of OrderIdentifiers.
2548 2549 2550 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2548 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_identifier(organization, identifier) ⇒ Object
2602 2603 2604 2605 2606 2607 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2602 def delete_by_identifier(organization, identifier) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('identifier', identifier, String) r = @client.request("/#{CGI.escape(organization)}/order-identifiers/#{CGI.escape(identifier)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2552 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) }), :identifier => (x = opts.delete(:identifier); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifier', x, Array).map { |v| HttpClient::Preconditions.assert_class('identifier', 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) }), :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? ? "name" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/order-identifiers").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::OrderIdentifier.new(x) } end |
#get_by_identifier(organization, identifier) ⇒ Object
2587 2588 2589 2590 2591 2592 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2587 def get_by_identifier(organization, identifier) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('identifier', identifier, String) r = @client.request("/#{CGI.escape(organization)}/order-identifiers/#{CGI.escape(identifier)}").get ::Io::Flow::V0::Models::OrderIdentifier.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2574 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) }), :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)}/order-identifiers/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::OrderIdentifierVersion.new(x) } end |
#post(organization, order_identifier_form) ⇒ Object
2567 2568 2569 2570 2571 2572 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2567 def post(organization, order_identifier_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = order_identifier_form; x.is_a?(::Io::Flow::V0::Models::OrderIdentifierForm) ? x : ::Io::Flow::V0::Models::OrderIdentifierForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/order-identifiers").with_json(order_identifier_form.to_json).post ::Io::Flow::V0::Models::OrderIdentifier.new(r) end |
#put_by_identifier(organization, identifier, order_identifier_put_form) ⇒ Object
2594 2595 2596 2597 2598 2599 2600 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2594 def put_by_identifier(organization, identifier, order_identifier_put_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('identifier', identifier, String) (x = order_identifier_put_form; x.is_a?(::Io::Flow::V0::Models::OrderIdentifierPutForm) ? x : ::Io::Flow::V0::Models::OrderIdentifierPutForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/order-identifiers/#{CGI.escape(identifier)}").with_json(order_identifier_put_form.to_json).put ::Io::Flow::V0::Models::OrderIdentifier.new(r) end |