Class: TalkboxApi::Promotions

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

Overview

Promotions resource class This class provides methods for interacting with the Talkbox API promotions resource.

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Promotions

Returns a new instance of Promotions.



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

def initialize(conn)
  @conn = conn
end

Instance Method Details

#create(params) ⇒ Hash

Creates a new promotion

Parameters:

  • params (Hash)

    The parameters for the new promotion

Returns:

  • (Hash)

    The created promotion



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

def create(params)
  @conn.post("#{PATH_PREFIX}/promotions", params.to_json, { "Content-Type" => "application/json" }).body
end

#delete(id) ⇒ Hash

Deletes a promotion

Parameters:

  • id (String)

    The ID of the promotion to delete

Returns:

  • (Hash)

    The deleted promotion



29
30
31
# File 'lib/talkbox_api/promotions.rb', line 29

def delete(id)
  @conn.delete("#{PATH_PREFIX}/promotions/#{id}").body
end

#update(id, params) ⇒ Hash

Updates an existing promotion

Parameters:

  • id (String)

    The ID of the promotion to update

  • params (Hash)

    The parameters for the updated promotion

Returns:

  • (Hash)

    The updated promotion



22
23
24
# File 'lib/talkbox_api/promotions.rb', line 22

def update(id, params)
  @conn.put("#{PATH_PREFIX}/promotions/#{id}", params.to_json, { "Content-Type" => "application/json" }).body
end