Class: Io::Flow::V0::Clients::TradeAgreementCertifiers

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TradeAgreementCertifiers

Returns a new instance of TradeAgreementCertifiers.



8601
8602
8603
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8601

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

Instance Method Details

#delete_by_key(organization, key) ⇒ Object



8644
8645
8646
8647
8648
8649
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8644

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)}/trade/agreement/certifiers/#{CGI.escape(key)}").delete
  nil
end

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

Retrieve trade agreement certifiers.



8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8606

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)}/trade/agreement/certifiers").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::TradeAgreementCertifier.new(x) }
end

#get_by_key(organization, key) ⇒ Object

Retrieve a trade agreement certifier.



8629
8630
8631
8632
8633
8634
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8629

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)}/trade/agreement/certifiers/#{CGI.escape(key)}").get
  ::Io::Flow::V0::Models::TradeAgreementCertifier.new(r)
end

#post(organization, trade_agreement_certifier) ⇒ Object

Add a trade agreement certifier.



8621
8622
8623
8624
8625
8626
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8621

def post(organization, trade_agreement_certifier)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = trade_agreement_certifier; x.is_a?(::Io::Flow::V0::Models::TradeAgreementCertifier) ? x : ::Io::Flow::V0::Models::TradeAgreementCertifier.new(x))
  r = @client.request("/#{CGI.escape(organization)}/trade/agreement/certifiers").with_json(trade_agreement_certifier.to_json).post
  ::Io::Flow::V0::Models::TradeAgreementCertifier.new(r)
end

#put_by_key(organization, key, trade_agreement_certifier) ⇒ Object



8636
8637
8638
8639
8640
8641
8642
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8636

def put_by_key(organization, key, trade_agreement_certifier)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  (x = trade_agreement_certifier; x.is_a?(::Io::Flow::V0::Models::TradeAgreementCertifier) ? x : ::Io::Flow::V0::Models::TradeAgreementCertifier.new(x))
  r = @client.request("/#{CGI.escape(organization)}/trade/agreement/certifiers/#{CGI.escape(key)}").with_json(trade_agreement_certifier.to_json).put
  ::Io::Flow::V0::Models::TradeAgreementCertifier.new(r)
end