Class: TalkboxApi::Sections

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

Overview

Sections resource class This class provides methods for interacting with the Talkbox API sections resource.

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Sections

Returns a new instance of Sections.



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

def initialize(conn)
  @conn = conn
end

Instance Method Details

#allArray

Retrieves all sections

Returns:

  • (Array)

    The list of sections



13
14
15
# File 'lib/talkbox_api/sections.rb', line 13

def all
  @conn.get("#{PATH_PREFIX}/sections").body
end

#create(params) ⇒ Hash

Creates a new section

Parameters:

  • params (Hash)

    The parameters for the new section

Returns:

  • (Hash)

    The created section



27
28
29
# File 'lib/talkbox_api/sections.rb', line 27

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

#delete(id) ⇒ Hash

Deletes a section

Parameters:

  • id (String)

    The ID of the section to delete

Returns:

  • (Hash)

    The deleted section



42
43
44
# File 'lib/talkbox_api/sections.rb', line 42

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

#get(id) ⇒ Hash

Retrieves a specific section

Parameters:

  • id (String)

    The ID of the section to retrieve

Returns:

  • (Hash)

    The retrieved section



20
21
22
# File 'lib/talkbox_api/sections.rb', line 20

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

#update(id, params) ⇒ Hash

Updates an existing section

Parameters:

  • id (String)

    The ID of the section to update

  • params (Hash)

    The parameters for the updated section

Returns:

  • (Hash)

    The updated section



35
36
37
# File 'lib/talkbox_api/sections.rb', line 35

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