Module: Vindi::Rest::Discount

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

Overview

Methods for the discount API

Instance Method Summary collapse

Instance Method Details

#create_discount(options = {}) ⇒ Hash

Create a discount for a merchant vindi

Examples:

Create a discount for a merchant vindi

client.create_discount(product_item_id: 118,
                       discount_type: "percentage", percentage: 10,
                       amount: 1, quantity: 1, cycles: 1)

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :options (Hash)

    discount attributes

Returns:

  • (Hash)

    The discount created

See Also:



28
29
30
# File 'lib/vindi/rest/discount.rb', line 28

def create_discount(options = {})
  post('discounts', options)[:discount]
end

#delete_discount(discount_id, options = {}) ⇒ Object

Delete a discount from merchant vindi

Examples:

Delete discount #2

client.delete_discount(2)

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :options (Hash)

    discount attributes

See Also:



40
41
42
# File 'lib/vindi/rest/discount.rb', line 40

def delete_discount(discount_id, options = {})
  delete("discounts/#{discount_id}", options)[:discount]
end

#discount(discount_id, options = {}) ⇒ Hash

Get a single discount from a merchant

Examples:

Get discount #2 from vindi

client.discount(2)

Parameters:

  • discount_id (Integer)

    ID of the discount

Returns:

  • (Hash)

    The discount you requested, if it exists

See Also:



15
16
17
# File 'lib/vindi/rest/discount.rb', line 15

def discount(discount_id, options = {})
  get("discounts/#{discount_id}", options)[:discount]
end