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.



9047
9048
9049
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9047

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

Instance Method Details

#delete_by_key(organization, key) ⇒ Object



9090
9091
9092
9093
9094
9095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9090

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.



9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9052

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.



9075
9076
9077
9078
9079
9080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9075

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.



9067
9068
9069
9070
9071
9072
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9067

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



9082
9083
9084
9085
9086
9087
9088
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9082

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