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.
922 923 924 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 922 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
971 972 973 974 975 976 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 971 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
926 927 928 929 930 931 932 933 934 935 936 937 938 939 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 926 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
952 953 954 955 956 957 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 952 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
941 942 943 944 945 946 947 948 949 950 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 941 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
959 960 961 962 963 964 965 966 967 968 969 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 959 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 |