Class: TalkboxApi::Vouchers

Inherits:
Object
  • Object
show all
Defined in:
lib/talkbox_api/vouchers.rb

Overview

Vouchers resource class This class provides methods for interacting with the Talkbox API vouchers resource.

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Vouchers

Returns a new instance of Vouchers.



7
8
9
# File 'lib/talkbox_api/vouchers.rb', line 7

def initialize(conn)
  @conn = conn
end

Instance Method Details

#all(params = nil) ⇒ Array

Retrieves all vouchers

Parameters:

  • params (Hash) (defaults to: nil)

    Optional parameters for the request

Returns:

  • (Array)

    The list of vouchers



14
15
16
# File 'lib/talkbox_api/vouchers.rb', line 14

def all(params = nil)
  @conn.get("#{PATH_PREFIX}/vouchers", params).body
end

#get(id) ⇒ Hash

Retrieves a specific voucher

Parameters:

  • id (String)

    The ID of the voucher to retrieve

Returns:

  • (Hash)

    The retrieved voucher



21
22
23
# File 'lib/talkbox_api/vouchers.rb', line 21

def get(id)
  @conn.get("#{PATH_PREFIX}/vouchers/#{id}").body
end

#redeem(id) ⇒ Hash

Redeems a voucher

Parameters:

  • id (String)

    The ID of the voucher to redeem

Returns:

  • (Hash)

    The redeemed voucher



28
29
30
# File 'lib/talkbox_api/vouchers.rb', line 28

def redeem(id)
  @conn.put("#{PATH_PREFIX}/vouchers/#{id}").body
end