Module: TropoRest::Client::Application

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

Constant Summary collapse

SINGULAR_PATH =
"applications/%d".freeze
PLURAL_PATH =
"applications".freeze
RESOURCE =
TropoRest::Resource::Application

Instance Method Summary collapse

Instance Method Details

#application(id_or_href) ⇒ TropoRest::Resource::Application

Returns the application specified by an ID

Parameters:

  • id_or_href (String, Integer)

    The ID or HREF of the application.

Returns:

Raises:



22
23
24
25
# File 'lib/tropo_rest/client/application.rb', line 22

def application(id_or_href)
  path = get_path(SINGULAR_PATH, id_or_href)
  get(path, RESOURCE)
end

#applicationsArray

Returns the authenticated user’s applications

Returns:

  • (Array)

    The applications.

See Also:



13
14
15
# File 'lib/tropo_rest/client/application.rb', line 13

def applications
  get(PLURAL_PATH, RESOURCE)
end

#create_application(params = {}) ⇒ Hashie::Mash

Creates a new application

Parameters:

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

    The attributes of the application to be created.

Options Hash (params):

  • :name (String)

    The name of the application. Required.

  • :platform (String)

    Either “scripting” or “webapi”. Required.

  • :partition (String)

    Either “staging” or “production”. Defaults to “staging” if not specified.

  • :voice_url (String)

    The voice endpoint of the application. Optional.

  • :messaging_url (String)

    The messaging endpoint of the application. Optional.

Returns:

  • (Hashie::Mash)

    An object containing the “href” of the new application

Raises:

See Also:



38
39
40
# File 'lib/tropo_rest/client/application.rb', line 38

def create_application(params={})
  post(PLURAL_PATH, RESOURCE.new(params))
end

#delete_application(id_or_href) ⇒ Hashie::Mash

Permanently destroys the application specified by an ID

Parameters:

  • id_or_href (String, Integer)

    The ID or HREF of the application to be deleted.

Returns:

  • (Hashie::Mash)

    An object with a “message” attribute indicating success.

Raises:



47
48
49
50
# File 'lib/tropo_rest/client/application.rb', line 47

def delete_application(id_or_href)
  path = get_path(SINGULAR_PATH, id_or_href)
  delete(path)
end

#update_application(id_or_href, params = {}) ⇒ Hashie::Mash

Updates an application

Parameters:

  • id_or_href (String, Integer)

    The ID or HREF of the application to be updated.

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

    The attributes to be updated. of the application.

Options Hash (params):

  • :name (String)

    The name of the application. Required.

  • :platform (String)

    Either “scripting” or “webapi”. Required.

  • :partition (String)

    Either “staging” or “production”. Defaults to “staging” if not specified.

  • :voice_url (String)

    The voice endpoint of the application. Optional.

  • :messaging_url (String)

    The messaging endpoint of the application. Optional.

Returns:

  • (Hashie::Mash)

    An object containing the “href” of the new application

Raises:

See Also:



65
66
67
68
# File 'lib/tropo_rest/client/application.rb', line 65

def update_application(id_or_href, params={})
  path = get_path(SINGULAR_PATH, id_or_href)
  put(path, RESOURCE.new(params))
end