Class: Io::Flow::V0::Clients::CheckoutAttributes
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::CheckoutAttributes
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(organization, id) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
-
#initialize(client) ⇒ CheckoutAttributes
constructor
A new instance of CheckoutAttributes.
- #post(organization, checkout_attribute_form, incoming = {}) ⇒ Object
- #put_by_id(organization, id, checkout_attribute_form, incoming = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ CheckoutAttributes
Returns a new instance of CheckoutAttributes.
833 834 835 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 833 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
882 883 884 885 886 887 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 882 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
837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 837 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
863 864 865 866 867 868 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 863 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
852 853 854 855 856 857 858 859 860 861 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 852 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
870 871 872 873 874 875 876 877 878 879 880 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 870 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 |