ExTwilio.Account

Represents an Account or Subaccount resource.

Examples

An ExTwilio.Account can represent either an Account or a SubAccount. To see all accounts and subaccounts that your auth_token has access to, run:

ExTwilio.Account.all

If you want to find a SubAccount, use find/1.

ExTwilio.Account.find("sid")

If you want to see items associated with a SubAccount, you can do so by passing in an account: option in all other ExTwilio resources. For example:

ExTwilio.Call.list(account: "subaccount_sid")
Source

Summary

all(options \\ [])

Retrieve all of the Account records from the Twilio API, paging through all the API response pages

children()
close(sid)

Permanently close an Account by updating its status to "closed". This cannot be undone, so use it carefully!

create(data, options \\ [])

Create a new Account in the Twilio API. Any field supported by Twilio's Account API can be passed in the 'data' keyword list

find(sid, options \\ [])

Find any Account by its Twilio SID

first_page(metadata)

Get the first page of accounts, using metadata from any page's response

last_page(metadata)

Get the last page of accounts, using metadta from any page's response

list(options \\ [])

Retrieve a list of Accounts from the API

new()

Creates a new ExTwilio.Account struct. Optionally, you can pass in attributes to set their initial value in the struct

new(attrs)
next_page(metadata)

Get the next page of accounts, using the metadata from the previous response. See all/0 for an easy way to get all the records

parents()
previous_page(metadata)

Get the previous page of accounts, using metadata from a previous response

reactivate(sid)

Reactivate a suspended Account by updating its status to "active"

resource_collection_name()

Underscored and lowercased collection name for a given resource. Delegates the real work to ExTwilio.Api.resource_collection_name/1 by default

resource_name()

CamelCase resource name as it would be used in Twilio's API. Delegates the real work to ExTwilio.Api.resource_name/1 by default

stream(options \\ [])

Create a stream of all Account records from the Twilio API

suspend(sid)

Suspend an Account by updating its status to "suspended"

update(sid, data, options \\ [])

Update an Account in the Twilio API. You can pass it a binary SID as the identifier, or a whole %ExTwilio.Account{} struct

Functions

all(options \\ [])

Specs:

  • all(list) :: [%{}]

Retrieve all of the Account records from the Twilio API, paging through all the API response pages.

Delegates to ExTwilio.Api.all/2.

Examples

accounts = ExTwilio.Account.all
Source
children()

Specs:

  • children :: list
Source
close(sid)

Specs:

Permanently close an Account by updating its status to "closed". This cannot be undone, so use it carefully!

Example

{:ok, account} = ExTwilio.Account.find("<sid>")
ExTwilio.Account.close(account)
Source
create(data, options \\ [])

Specs:

Create a new Account in the Twilio API. Any field supported by Twilio's Account API can be passed in the 'data' keyword list.

Delegates to ExTwilio.Api.create/3.

Source
find(sid, options \\ [])

Specs:

Find any Account by its Twilio SID.

Delegates to ExTwilio.Api.find/3.

Examples

{:ok, account} = ExTwilio.Account.find("...")
{:error, msg, http_status} = ExTwilio.Account.find("...")
Source
first_page(metadata)

Specs:

Get the first page of accounts, using metadata from any page's response.

Delegates to ExTwilio.Api.fetch_page/2.

Examples

{:ok, page10, meta} = ExTwilio.Account.list(page: 10)
{:ok, page1, meta}  = ExTwilio.Account.first_page(meta)
Source
last_page(metadata)

Specs:

Get the last page of accounts, using metadta from any page's response.

Delegates to ExTwilio.Api.fetch_page/2.

Examples

{:ok, page10, meta}    = ExTwilio.Account.list(page: 10)
{:ok, last_page, meta} = ExTwilio.Account.last_page(meta)
Source
list(options \\ [])

Specs:

Retrieve a list of Accounts from the API.

Delegates to ExTwilio.Api.list/2.

Examples

# Successful response
{:ok, accounts, metadata} = ExTwilio.Account.list

# Error response
{:error, msg, http_code} = ExTwilio.Account.list
Source
new()

Specs:

  • new :: %ExTwilio.Account{auth_token: term, date_created: term, date_updated: term, friendly_name: term, owner_account_sid: term, sid: term, status: term, subresource_uris: term, type: term, uri: term}

Creates a new ExTwilio.Account struct. Optionally, you can pass in attributes to set their initial value in the struct.

Example

%ExTwilio.Account{} = ExTwilio.Account.new
%ExTwilio.Account{sid: "sid"} = ExTwilio.Account.new(sid: "sid")
Source
new(attrs)

Specs:

  • new(list) :: %ExTwilio.Account{auth_token: term, date_created: term, date_updated: term, friendly_name: term, owner_account_sid: term, sid: term, status: term, subresource_uris: term, type: term, uri: term}
Source
next_page(metadata)

Specs:

Get the next page of accounts, using the metadata from the previous response. See all/0 for an easy way to get all the records.

Delegates to ExTwilio.Api.fetch_page/2.

Examples

{:ok, page1, meta} = ExTwilio.Account.list
{:ok, page2, meta} = ExTwilio.Account.next_page(meta)
Source
parents()

Specs:

  • parents :: list
Source
previous_page(metadata)

Specs:

Get the previous page of accounts, using metadata from a previous response.

Delegates to ExTwilio.Api.fetch_page/2.

Examples

{:ok, page2, meta} = ExTwilio.Account.list(page: 2)
{:ok, page1, meta} = ExTwilio.Account.previous_page(meta)
Source
reactivate(sid)

Specs:

Reactivate a suspended Account by updating its status to "active".

Example

{:ok, account} = ExTwilio.Account.find("<sid>")
ExTwilio.Account.reactivate(account)
Source
resource_collection_name()

Underscored and lowercased collection name for a given resource. Delegates the real work to ExTwilio.Api.resource_collection_name/1 by default.

Override in your module before use ExTwilio.Resource if you need something different.

Source
resource_name()

CamelCase resource name as it would be used in Twilio's API. Delegates the real work to ExTwilio.Api.resource_name/1 by default.

Override in your module before use ExTwilio.Resource if you need something different.

Source
stream(options \\ [])

Create a stream of all Account records from the Twilio API.

Delegates to ExTwilio.Api.stream/2.

Source
suspend(sid)

Specs:

Suspend an Account by updating its status to "suspended".

Example

{:ok, account} = ExTwilio.Account.find("<sid>")
ExTwilio.Account.suspend(account)
Source
update(sid, data, options \\ [])

Specs:

Update an Account in the Twilio API. You can pass it a binary SID as the identifier, or a whole %ExTwilio.Account{} struct.

Delegates to ExTwilio.Api.update/4.

Examples

{:ok, account} = ExTwilio.Account.update(%ExTwilio.Account{...}, field: "new_value")
{:ok, account} = ExTwilio.Account.update("<SID HERE>", field: "new_value")
Source