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 Flow 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.
6800 6801 6802 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6800 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.
6819 6820 6821 6822 6823 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6819 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.
6812 6813 6814 6815 6816 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6812 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.
6805 6806 6807 6808 6809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6805 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.
6826 6827 6828 6829 6830 6831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6826 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.
6842 6843 6844 6845 6846 6847 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6842 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 .
6850 6851 6852 6853 6854 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6850 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 Flow cart.
6865 6866 6867 6868 6869 6870 6871 6872 6873 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6865 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.
6834 6835 6836 6837 6838 6839 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6834 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.
6857 6858 6859 6860 6861 6862 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6857 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 |