Class: Io::Flow::V0::Clients::DutyItemProducers

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ DutyItemProducers

Returns a new instance of DutyItemProducers.



6710
6711
6712
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6710

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete_by_key(organization, key) ⇒ Object



6753
6754
6755
6756
6757
6758
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6753

def delete_by_key(organization, key)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  r = @client.request("/#{CGI.escape(organization)}/duty/item/producers/#{CGI.escape(key)}").delete
  nil
end

#get(organization, incoming = {}) ⇒ Object

Retrieve duty item producers.



6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6715

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) }),
    :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, 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)}/duty/item/producers").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::DutyItemProducer.new(x) }
end

#get_by_key(organization, key) ⇒ Object

Retrieve a duty item producer.



6738
6739
6740
6741
6742
6743
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6738

def get_by_key(organization, key)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  r = @client.request("/#{CGI.escape(organization)}/duty/item/producers/#{CGI.escape(key)}").get
  ::Io::Flow::V0::Models::DutyItemProducer.new(r)
end

#post(organization, duty_item_producer) ⇒ Object

Add a duty item producer.



6730
6731
6732
6733
6734
6735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6730

def post(organization, duty_item_producer)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = duty_item_producer; x.is_a?(::Io::Flow::V0::Models::DutyItemProducer) ? x : ::Io::Flow::V0::Models::DutyItemProducer.new(x))
  r = @client.request("/#{CGI.escape(organization)}/duty/item/producers").with_json(duty_item_producer.to_json).post
  ::Io::Flow::V0::Models::DutyItemProducer.new(r)
end

#put_by_key(organization, key, duty_item_producer) ⇒ Object



6745
6746
6747
6748
6749
6750
6751
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6745

def put_by_key(organization, key, duty_item_producer)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  (x = duty_item_producer; x.is_a?(::Io::Flow::V0::Models::DutyItemProducer) ? x : ::Io::Flow::V0::Models::DutyItemProducer.new(x))
  r = @client.request("/#{CGI.escape(organization)}/duty/item/producers/#{CGI.escape(key)}").with_json(duty_item_producer.to_json).put
  ::Io::Flow::V0::Models::DutyItemProducer.new(r)
end