Class: Io::Flow::V0::Clients::ShopifyCarts

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ShopifyCarts

Returns a new instance of ShopifyCarts.



7087
7088
7089
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7087

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

Instance Method Details

#get_by_id(id, incoming = {}) ⇒ Object

Retrieve representation of a Shopify cart given the unique cart id.



7114
7115
7116
7117
7118
7119
7120
7121
7122
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7114

def get_by_id(id, incoming={})
  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? }
  r = @client.request("/shopify/carts/#{CGI.escape(id)}").with_query(query).get
  ::Io::Flow::V0::Models::ShopifyCart.new(r)
end

#get_by_id_html(id, incoming = {}) ⇒ Object

Retrieve representation of a Shopify cart given the unique cart id.



7103
7104
7105
7106
7107
7108
7109
7110
7111
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7103

def get_by_id_html(id, incoming={})
  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? }
  r = @client.request("/shopify/carts/#{CGI.escape(id)}").with_query(query).get
  r
end

#get_order_by_number(number, incoming = {}) ⇒ Object

Retrieve representation of a Shopify cart for the given order number.



7092
7093
7094
7095
7096
7097
7098
7099
7100
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7092

def get_order_by_number(number, incoming={})
  HttpClient::Preconditions.assert_class('number', number, 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? }
  r = @client.request("/shopify/carts/order/#{CGI.escape(number)}").with_query(query).get
  ::Io::Flow::V0::Models::ShopifyCart.new(r)
end

#post_add_by_id(id, shopify_cart_add_form, incoming = {}) ⇒ Object

Add an item to a Shopify cart given the unique cart id.



7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7125

def post_add_by_id(id, shopify_cart_add_form, incoming={})
  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 = 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_query(query).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, incoming = {}) ⇒ Object

Change/Update an item in a Shopify cart given the unique cart id.



7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7149

def post_change_by_id(id, shopify_cart_change_form, incoming={})
  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 = 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_query(query).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 .



7161
7162
7163
7164
7165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7161

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.



7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7180

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) }),
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, 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, incoming = {}) ⇒ Object

Update the attribute information for the cart.



7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7137

def put_attributes_by_id(id, shopify_order_attributes_form, incoming={})
  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 = 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_query(query).with_json(shopify_order_attributes_form.to_json).put
  ::Io::Flow::V0::Models::ShopifyCart.new(r)
end

#put_geo_by_id(id, geo_form, incoming = {}) ⇒ Object

Update the geo information for the cart.



7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7168

def put_geo_by_id(id, geo_form, incoming={})
  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 = 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_query(query).with_json(geo_form.to_json).put
  ::Io::Flow::V0::Models::ShopifyCart.new(r)
end