Class: Io::Flow::V0::Clients::DutyItems
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::DutyItems
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_number(organization, number) ⇒ Object
-
#get(organization, incoming = {}) ⇒ Object
Retrieve duty items.
-
#get_by_number(organization, number) ⇒ Object
Retrieve a duty item.
-
#initialize(client) ⇒ DutyItems
constructor
A new instance of DutyItems.
-
#post(organization, duty_item_form) ⇒ Object
Add a duty item.
- #put_by_number(organization, number, duty_item_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ DutyItems
Returns a new instance of DutyItems.
6638 6639 6640 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6638 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_number(organization, number) ⇒ Object
6683 6684 6685 6686 6687 6688 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6683 def delete_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/duty/items/#{CGI.escape(number)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
Retrieve duty items.
6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6643 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) }), :number => (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, Array).map { |v| HttpClient::Preconditions.assert_class('number', v, String) }), :product_id => (x = opts.delete(:product_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('product_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('product_id', v, String) }), :sku => (x = opts.delete(:sku); x.nil? ? nil : HttpClient::Preconditions.assert_class('sku', x, Array).map { |v| HttpClient::Preconditions.assert_class('sku', 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)}/duty/items").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::DutyItem.new(x) } end |
#get_by_number(organization, number) ⇒ Object
Retrieve a duty item.
6668 6669 6670 6671 6672 6673 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6668 def get_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/duty/items/#{CGI.escape(number)}").get ::Io::Flow::V0::Models::DutyItem.new(r) end |
#post(organization, duty_item_form) ⇒ Object
Add a duty item.
6660 6661 6662 6663 6664 6665 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6660 def post(organization, duty_item_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = duty_item_form; x.is_a?(::Io::Flow::V0::Models::DutyItemForm) ? x : ::Io::Flow::V0::Models::DutyItemForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/duty/items").with_json(duty_item_form.to_json).post ::Io::Flow::V0::Models::DutyItem.new(r) end |
#put_by_number(organization, number, duty_item_form) ⇒ Object
6675 6676 6677 6678 6679 6680 6681 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6675 def put_by_number(organization, number, duty_item_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) (x = duty_item_form; x.is_a?(::Io::Flow::V0::Models::DutyItemForm) ? x : ::Io::Flow::V0::Models::DutyItemForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/duty/items/#{CGI.escape(number)}").with_json(duty_item_form.to_json).put ::Io::Flow::V0::Models::DutyItem.new(r) end |