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.



645
646
647
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 645

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

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



686
687
688
689
690
691
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 686

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



649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 649

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



671
672
673
674
675
676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 671

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) ⇒ Object



664
665
666
667
668
669
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 664

def post(organization, checkout_attribute_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (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_json(checkout_attribute_form.to_json).post
  ::Io::Flow::V0::Models::CheckoutAttribute.new(r)
end

#put_by_id(organization, id, checkout_attribute_form) ⇒ Object



678
679
680
681
682
683
684
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 678

def put_by_id(organization, id, checkout_attribute_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (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_json(checkout_attribute_form.to_json).put
  ::Io::Flow::V0::Models::CheckoutAttribute.new(r)
end