Module: Products

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

Instance Method Summary collapse

Instance Method Details

#create_product(data) ⇒ Object

Create product.

Create a product with data.

Parameters

data

(Hash) – Data to be submited.

Example

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

149
150
151
# File 'lib/user/ecommerce/products.rb', line 149

def create_product(data)
    return @client.raw("post", "/ecommerce/products/", nil, data_transform(data))
end

#delete_product(id) ⇒ Object

Delete product.

Delete a product.

Parameters

id

(Integer) – Product id.


32
33
34
# File 'lib/user/ecommerce/products.rb', line 32

def delete_product(id)
    return @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 = @mints_user.get_product(3)

Second Example

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

132
133
134
# File 'lib/user/ecommerce/products.rb', line 132

def get_product(id, options = nil)
    return @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 = @mints_user.get_product_variant_options_config(1)

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

def get_product_variant_options_config(id)
    return @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 = @mints_user.get_products

Second Example

options = {
  "fields": "id"
}
@data = @mints_user.get_products(options)

Third Example

options = {
  "fields": "id"
}
@data = @mints_user.get_products(options, false)

113
114
115
# File 'lib/user/ecommerce/products.rb', line 113

def get_products(options = nil, use_post = true)
    return 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 = @mints_user.get_products_support_data

22
23
24
# File 'lib/user/ecommerce/products.rb', line 22

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

#publish_product(id, data) ⇒ Object

Publish product.

Publish a product.

Parameters

id

(Integer) – Product id.

data

(Hash) – Data to be submited.

Example

data = {
  "title": "New Publish"
}
@data = @mints_user.publish_product(2, data)

48
49
50
# File 'lib/user/ecommerce/products.rb', line 48

def publish_product(id, data)
    return @client.raw("put", "/ecommerce/products/#{id}/publish", nil, data_transform(data))
end

#revert_published_product(id) ⇒ Object

Revert published product.

Revert a published product.

Parameters

id

(Integer) – Product id.

Example

@data = @mints_user.revert_published_product(2)

88
89
90
# File 'lib/user/ecommerce/products.rb', line 88

def revert_published_product(id)
    return @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 submited.

Example

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

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

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

#update_product(id, data) ⇒ Object

Update product.

Update a product info.

Parameters

id

(Integer) – Product id.

data

(Hash) – Data to be submited.

Example

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

166
167
168
# File 'lib/user/ecommerce/products.rb', line 166

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

#update_product_variations_config(productId, data) ⇒ Object

Update product variations config.

Update config of product variations of a product.

Parameters

productId

(Integer) – Product id.

data

(Hash) – Data to be submited.


13
14
15
# File 'lib/user/ecommerce/products.rb', line 13

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