Class: Io::Flow::V0::Clients::CheckoutAttributes

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ CheckoutAttributes

Returns a new instance of CheckoutAttributes.



970
971
972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 970

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

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



1019
1020
1021
1022
1023
1024
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1019

def delete_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/checkout/attributes/#{CGI.escape(id)}").delete
  nil
end

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



974
975
976
977
978
979
980
981
982
983
984
985
986
987
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 974

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, Array).map { |v| HttpClient::Preconditions.assert_class('key', v, String) }),
    :experience_key => (x = opts.delete(:experience_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience_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? ? "position" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/checkout/attributes").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::CheckoutAttribute.new(x) }
end

#get_by_id(organization, id) ⇒ Object



1000
1001
1002
1003
1004
1005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1000

def get_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/checkout/attributes/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::CheckoutAttribute.new(r)
end

#post(organization, checkout_attribute_form, incoming = {}) ⇒ Object



989
990
991
992
993
994
995
996
997
998
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 989

def post(organization, checkout_attribute_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String))
  }.delete_if { |k, v| v.nil? }
  (x = checkout_attribute_form; x.is_a?(::Io::Flow::V0::Models::CheckoutAttributeForm) ? x : ::Io::Flow::V0::Models::CheckoutAttributeForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/checkout/attributes").with_query(query).with_json(checkout_attribute_form.to_json).post
  ::Io::Flow::V0::Models::CheckoutAttribute.new(r)
end

#put_by_id(organization, id, checkout_attribute_form, incoming = {}) ⇒ Object



1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1007

def put_by_id(organization, id, checkout_attribute_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String))
  }.delete_if { |k, v| v.nil? }
  (x = checkout_attribute_form; x.is_a?(::Io::Flow::V0::Models::CheckoutAttributeForm) ? x : ::Io::Flow::V0::Models::CheckoutAttributeForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/checkout/attributes/#{CGI.escape(id)}").with_query(query).with_json(checkout_attribute_form.to_json).put
  ::Io::Flow::V0::Models::CheckoutAttribute.new(r)
end