Module: TropoRest::Client::Address

Included in:
TropoRest::Client
Defined in:
lib/tropo_rest/client/address.rb

Constant Summary collapse

SINGULAR_PATH =
"applications/%d/addresses/%s/%s".freeze
PLURAL_PATH =
"applications/%d/addresses".freeze
RESOURCE =
TropoRest::Resource::Address

Instance Method Summary collapse

Instance Method Details

#address(application_id, type, identifier) ⇒ TropoRest::Resource::Address #address(href) ⇒ TropoRest::Resource::Address

Returns the specified address

Overloads:

  • #address(application_id, type, identifier) ⇒ TropoRest::Resource::Address

    Parameters:

    • application_id (String, Integer)

      The ID of the application.

    • type (String)

      The type of address (aim, gtalk, jabber, msn, skype, number, token, yahoo)

    • identifier (String)

      The address, number, or username

  • #address(href) ⇒ TropoRest::Resource::Address

    Parameters:

    • href (String)

      The HREF of the address

Returns:

Raises:



30
31
32
33
# File 'lib/tropo_rest/client/address.rb', line 30

def address(*args)
  path = get_path(SINGULAR_PATH, *args)
  get(path, RESOURCE)
end

#addresses(application_id) ⇒ Array

Returns the addresses for the specified application

Parameters:

  • application_id (String, Integer)

    The ID of the application.

Returns:

  • (Array)

    The addresses.

Raises:

See Also:



15
16
17
18
# File 'lib/tropo_rest/client/address.rb', line 15

def addresses(application_id)
  path = get_path(PLURAL_PATH, application_id)
  get(path, RESOURCE)
end

#create_address(application_id_or_href, params = {}) ⇒ Hashie::Mash

Creates a new address for the specified application

Parameters:

  • application_id_or_href (String, Integer)

    The ID or HREF of the application.

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

    The attributes of the address to be created.

Options Hash (params):

  • :type (String)

    The type of address to create (aim, gtalk, jabber, msn, number, token, yahoo). Required.

  • :prefix (String)

    The country and area code for a number

  • :number (String)

    A complete phone number already assigned to an existing application

  • :channel (String)

    Either “voice” or “messaging”, used when creating a token

  • :username (String)

    An IM username. Required when adding an IM account

  • :password (String)

    An IM password. Required when adding an IM account

Returns:

  • (Hashie::Mash)

    An object containing the “href” of the new application

Raises:

See Also:



53
54
55
56
# File 'lib/tropo_rest/client/address.rb', line 53

def create_address(application_id_or_href, params={})
  path = get_path(PLURAL_PATH, application_id_or_href)
  post(path, RESOURCE.new(params))
end

#delete_address(application_id, type, identifier) ⇒ Hashie::Mash #delete_address(href) ⇒ Hashie::Mash

Removes an address from an application

Overloads:

  • #delete_address(application_id, type, identifier) ⇒ Hashie::Mash

    Parameters:

    • application_id (String, Integer)

      The ID of the application.

    • type (String)

      The type of address (aim, gtalk, jabber, msn, skype, number, token, yahoo)

    • identifier (String)

      The address, number, or username

  • #delete_address(href) ⇒ Hashie::Mash

    Parameters:

    • href (String)

      The HREF of the address to be deleted.

Returns:

  • (Hashie::Mash)

    An object with a “message” attribute indicating success.

Raises:

See Also:



69
70
71
72
# File 'lib/tropo_rest/client/address.rb', line 69

def delete_address(*args)
  path = get_path(SINGULAR_PATH, *args)
  delete(path)
end