Module: Products

Included in:
Ecommerce
Defined in:
lib/user/ecommerce/products.rb

Instance Method Summary collapse

Instance Method Details

#create_product(data, options = nil) ⇒ Object

Create product.

Create a product with data.

Parameters

data

(Hash) – Data to be submitted.

Example

data = {
  title: 'New Product',
  slug: 'new-product',
  sku_prefix: 'sku_prefix'
}
@data = @cxf_user.create_product(data)


136
137
138
# File 'lib/user/ecommerce/products.rb', line 136

def create_product(data, options = nil)
  @client.raw('post', '/ecommerce/products/', options, data_transform(data))
end

#delete_product(id) ⇒ Object

Delete product.

Delete a product.

Parameters

id

(Integer) – Product id.



35
36
37
# File 'lib/user/ecommerce/products.rb', line 35

def delete_product(id)
  @client.raw('delete', "/ecommerce/products/#{id}")
end

#get_product(id, options = nil) ⇒ Object

Get product.

Get a product info.

Parameters

id

(Integer) – Product id.

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

First Example

@data = @cxf_user.get_product(3)

Second Example

options = {
  fields: "slug"
}
@data = @cxf_user.get_product(3, options)


119
120
121
# File 'lib/user/ecommerce/products.rb', line 119

def get_product(id, options = nil)
  @client.raw('get', "/ecommerce/products/#{id}", options)
end

#get_product_variant_options_config(id) ⇒ Object

Get product variant options config.

Get variant options config used in a product.

Parameters

id

(Integer) – Product id.

Example

@data = @cxf_user.get_product_variant_options_config(1)


63
64
65
# File 'lib/user/ecommerce/products.rb', line 63

def get_product_variant_options_config(id)
  @client.raw('get', "/ecommerce/products/#{id}/variant-options-config")
end

#get_products(options = nil, use_post = true) ⇒ Object

Get products.

Get a collection of products.

Parameters

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

use_post

(Boolean) – Variable to determine if the request is by ‘post’ or ‘get’ functions.

First Example

@data = @cxf_user.get_products

Second Example

options = {
  fields: 'id'
}
@data = @cxf_user.get_products(options)

Third Example

options = {
  fields: 'id'
}
@data = @cxf_user.get_products(options, false)


100
101
102
# File 'lib/user/ecommerce/products.rb', line 100

def get_products(options = nil, use_post = true)
  get_query_results('/ecommerce/products', options, use_post)
end

#get_products_support_dataObject

Get product support data.

Get support data used in products.

Example

@data = @cxf_user.get_products_support_data


25
26
27
# File 'lib/user/ecommerce/products.rb', line 25

def get_products_support_data
  @client.raw('get', '/ecommerce/products/support-data')
end

#revert_published_product(id) ⇒ Object

Revert published product.

Revert a published product.

Parameters

id

(Integer) – Product id.

Example

@data = @cxf_user.revert_published_product(2)


75
76
77
# File 'lib/user/ecommerce/products.rb', line 75

def revert_published_product(id)
  @client.raw('get', "/ecommerce/products/#{id}/revert-published-data")
end

#schedule_product(id, data) ⇒ Object

Schedule product.

Schedule a product.

Parameters

id

(Integer) – Product id.

data

(Hash) – Data to be submitted.

Example

data = {
  scheduled_at: '1970-01-01 00:00:00'
}
@data = @cxf_user.schedule_product(2, data)


51
52
53
# File 'lib/user/ecommerce/products.rb', line 51

def schedule_product(id, data)
  @client.raw('put', "/ecommerce/products/#{id}/schedule", nil, data_transform(data))
end

#update_product(id, data, options = nil) ⇒ Object

Update product.

Update a product info.

Parameters

id

(Integer) – Product id.

data

(Hash) – Data to be submitted.

Example

data = {
  title: 'New Product Modified',
  slug: 'new-product'
}
@data = @cxf_user.update_product(9, data)


153
154
155
# File 'lib/user/ecommerce/products.rb', line 153

def update_product(id, data, options = nil)
  @client.raw('put', "/ecommerce/products/#{id}", options, data_transform(data))
end

#update_product_variations_config(product_id, data) ⇒ Object

Update product variations config.

Update config of product variations of a product.

Parameters

product_id

(Integer) – Product id.

data

(Hash) – Data to be submitted.



15
16
17
18
# File 'lib/user/ecommerce/products.rb', line 15

def update_product_variations_config(product_id, data)
  # TODO: Method doesnt work, research use
  @client.raw('post', "/ecommerce/products/update-variations-config/#{product_id}", nil, data_transform(data))
end