class Io::Flow::V0::Clients::DutyItemProducers

Public Class Methods

new(client) click to toggle source
# 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

Public Instance Methods

delete_by_key(organization, key) click to toggle source
# 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={}) click to toggle source

Retrieve duty item producers.

# 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) click to toggle source

Retrieve a duty item producer.

# 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) click to toggle source

Add a duty item producer.

# 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) click to toggle source
# 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