Class: Io::Flow::V0::Clients::ShopifyCarts
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::ShopifyCarts
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get_by_id(id) ⇒ Object
Retrieve representation of a Shopify cart given the unique cart id.
-
#get_by_id_html(id) ⇒ Object
Retrieve representation of a Shopify cart given the unique cart id.
-
#get_order_by_number(number) ⇒ Object
Retrieve representation of a Shopify cart for the given order number.
-
#initialize(client) ⇒ ShopifyCarts
constructor
A new instance of ShopifyCarts.
-
#post_add_by_id(id, shopify_cart_add_form) ⇒ Object
Add an item to a Shopify cart given the unique cart id.
-
#post_change_by_id(id, shopify_cart_change_form) ⇒ Object
Change/Update an item in a Shopify cart given the unique cart id.
-
#post_clear_by_id(id) ⇒ Object
Remove all cart items given the unique cart id .
-
#post_orders_by_id(id, incoming = {}) ⇒ Object
Create an order from a cart.
-
#put_attributes_by_id(id, shopify_order_attributes_form) ⇒ Object
Update the attribute information for the cart.
-
#put_geo_by_id(id, geo_form) ⇒ Object
Update the geo information for the cart.
Constructor Details
#initialize(client) ⇒ ShopifyCarts
Returns a new instance of ShopifyCarts.
6017 6018 6019 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6017 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get_by_id(id) ⇒ Object
Retrieve representation of a Shopify cart given the unique cart id.
6036 6037 6038 6039 6040 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6036 def get_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/shopify/carts/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::ShopifyCart.new(r) end |
#get_by_id_html(id) ⇒ Object
Retrieve representation of a Shopify cart given the unique cart id.
6029 6030 6031 6032 6033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6029 def get_by_id_html(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/shopify/carts/#{CGI.escape(id)}").get r end |
#get_order_by_number(number) ⇒ Object
Retrieve representation of a Shopify cart for the given order number.
6022 6023 6024 6025 6026 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6022 def get_order_by_number(number) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/shopify/carts/order/#{CGI.escape(number)}").get ::Io::Flow::V0::Models::ShopifyCart.new(r) end |
#post_add_by_id(id, shopify_cart_add_form) ⇒ Object
Add an item to a Shopify cart given the unique cart id.
6043 6044 6045 6046 6047 6048 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6043 def post_add_by_id(id, shopify_cart_add_form) HttpClient::Preconditions.assert_class('id', id, String) (x = shopify_cart_add_form; x.is_a?(::Io::Flow::V0::Models::ShopifyCartAddForm) ? x : ::Io::Flow::V0::Models::ShopifyCartAddForm.from_json(x)) r = @client.request("/shopify/carts/#{CGI.escape(id)}/add").with_json(shopify_cart_add_form.to_json).post ::Io::Flow::V0::Models::ShopifyCart.new(r) end |
#post_change_by_id(id, shopify_cart_change_form) ⇒ Object
Change/Update an item in a Shopify cart given the unique cart id.
6059 6060 6061 6062 6063 6064 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6059 def post_change_by_id(id, shopify_cart_change_form) HttpClient::Preconditions.assert_class('id', id, String) (x = shopify_cart_change_form; x.is_a?(::Io::Flow::V0::Models::ShopifyCartChangeForm) ? x : ::Io::Flow::V0::Models::ShopifyCartChangeForm.new(x)) r = @client.request("/shopify/carts/#{CGI.escape(id)}/change").with_json(shopify_cart_change_form.to_json).post ::Io::Flow::V0::Models::ShopifyCart.new(r) end |
#post_clear_by_id(id) ⇒ Object
Remove all cart items given the unique cart id .
6067 6068 6069 6070 6071 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6067 def post_clear_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/shopify/carts/#{CGI.escape(id)}/clear").post ::Io::Flow::V0::Models::ShopifyCart.new(r) end |
#post_orders_by_id(id, incoming = {}) ⇒ Object
Create an order from a cart.
6082 6083 6084 6085 6086 6087 6088 6089 6090 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6082 def post_orders_by_id(id, incoming={}) HttpClient::Preconditions.assert_class('id', id, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/shopify/carts/#{CGI.escape(id)}/orders").with_query(query).post ::Io::Flow::V0::Models::Order.new(r) end |
#put_attributes_by_id(id, shopify_order_attributes_form) ⇒ Object
Update the attribute information for the cart.
6051 6052 6053 6054 6055 6056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6051 def put_attributes_by_id(id, shopify_order_attributes_form) HttpClient::Preconditions.assert_class('id', id, String) (x = shopify_order_attributes_form; x.is_a?(::Io::Flow::V0::Models::ShopifyOrderAttributesForm) ? x : ::Io::Flow::V0::Models::ShopifyOrderAttributesForm.new(x)) r = @client.request("/shopify/carts/#{CGI.escape(id)}/attributes").with_json(shopify_order_attributes_form.to_json).put ::Io::Flow::V0::Models::ShopifyCart.new(r) end |
#put_geo_by_id(id, geo_form) ⇒ Object
Update the geo information for the cart.
6074 6075 6076 6077 6078 6079 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6074 def put_geo_by_id(id, geo_form) HttpClient::Preconditions.assert_class('id', id, String) (x = geo_form; x.is_a?(::Io::Flow::V0::Models::GeoForm) ? x : ::Io::Flow::V0::Models::GeoForm.new(x)) r = @client.request("/shopify/carts/#{CGI.escape(id)}/geo").with_json(geo_form.to_json).put ::Io::Flow::V0::Models::ShopifyCart.new(r) end |