Module: Vindi::Rest::Product

Included in:
Vindi::Rest
Defined in:
lib/vindi/rest/product.rb

Overview

Methods for the products API

Instance Method Summary collapse

Instance Method Details

#create_product(options = {}) ⇒ Hash

Create a product for a merchant vindi

Examples:

Create a product for a merchant vindi

client.create_product(name: 'My product', interval: 12)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :options (Hash)

    product attributes

Returns:

  • (Hash)

    The product created

See Also:



35
36
37
# File 'lib/vindi/rest/product.rb', line 35

def create_product(options = {})
  post('products', options)[:product]
end

#list_products(options = {}) ⇒ Array<Hash>

List products for the authenticate user

Examples:

Get all products from merchant vindi


Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :page (Integer) — default: 1

    Page number.

  • :merchant (Integer)

    Merchant account

Returns:

  • (Array<Hash>)

    A list of products for a merchant.



13
14
15
# File 'lib/vindi/rest/product.rb', line 13

def list_products(options = {})
  get('products', options)[:products]
end

#product(product_id, options = {}) ⇒ Hash

Get a single product from a merchant

Examples:

Get product #2 from vindi

client.product(2)

Parameters:

  • product_id (Integer)

    ID of the product

Returns:

  • (Hash)

    The product you requested, if it exists

See Also:



24
25
26
# File 'lib/vindi/rest/product.rb', line 24

def product(product_id, options = {})
  get("products/#{product_id}", options)[:product]
end

#update_product(product_id, options = {}) ⇒ Object

Edit a product

Examples:

Update product #2

client.update_product(2, name: 'My product', interval: 3)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :options (Hash)

    product attributes

See Also:



46
47
48
# File 'lib/vindi/rest/product.rb', line 46

def update_product(product_id, options = {})
  put("products/#{product_id}", options)[:product]
end