Class: SurgeAPI::Resources::Accounts

Inherits:
Object
  • Object
show all
Defined in:
lib/surge_api/resources/accounts.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Accounts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Accounts.

Parameters:



126
127
128
# File 'lib/surge_api/resources/accounts.rb', line 126

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(id, request_options: {}) ⇒ SurgeAPI::Models::Account

Archives an account and releases all associated resources.

Warning: This action will:

  • Release all phone numbers associated with the account

  • Deactivate all campaigns

  • Make the account unusable for sending messages

This operation is irreversible. If you need to send SMS in the future, you will need to re-register new phone numbers and campaigns.

Parameters:

  • id (String)

    The ID of the account to archive.

  • request_options (SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



90
91
92
93
94
95
96
97
# File 'lib/surge_api/resources/accounts.rb', line 90

def archive(id, params = {})
  @client.request(
    method: :delete,
    path: ["accounts/%1$s", id],
    model: SurgeAPI::Account,
    options: params[:request_options]
  )
end

#create(name:, brand_name: nil, organization: nil, time_zone: nil, request_options: {}) ⇒ SurgeAPI::Models::Account

Some parameter documentations has been truncated, see Models::AccountCreateParams for more details.

Creates a new Account within the calling Platform.

Parameters:

  • name (String)

    The name of the account that will be visible for your internal organizational pu

  • brand_name (String, nil)

    The name by which the people this account communicates with know it. If not prov

  • organization (SurgeAPI::Models::AccountCreateParams::Organization)

    Parameters describing the legal entity on whose behalf the account will be opera

  • time_zone (String)

    This is the time zone in which the account is headquartered. This time zone may

  • request_options (SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
# File 'lib/surge_api/resources/accounts.rb', line 26

def create(params)
  parsed, options = SurgeAPI::AccountCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "accounts",
    body: parsed,
    model: SurgeAPI::Account,
    options: options
  )
end

#retrieve_status(account_id, capabilities: nil, request_options: {}) ⇒ SurgeAPI::Models::AccountStatus

Check an account’s status and capabilities

Parameters:

Returns:

See Also:



112
113
114
115
116
117
118
119
120
121
# File 'lib/surge_api/resources/accounts.rb', line 112

def retrieve_status(, params = {})
  parsed, options = SurgeAPI::AccountRetrieveStatusParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["accounts/%1$s/status", ],
    query: parsed,
    model: SurgeAPI::AccountStatus,
    options: options
  )
end

#update(id, brand_name: nil, name: nil, organization: nil, time_zone: nil, request_options: {}) ⇒ SurgeAPI::Models::Account

Some parameter documentations has been truncated, see Models::AccountUpdateParams for more details.

Updates an Account

Parameters:

  • id (String)

    The ID for the account to update.

  • brand_name (String)

    The name by which the people this account communicates with know it. If not prov

  • name (String)

    The name of the account that will be visible for your internal organizational pu

  • organization (SurgeAPI::Models::AccountUpdateParams::Organization)

    Parameters describing the legal entity on whose behalf the account will be opera

  • time_zone (String, nil)

    The time zone for the account

  • request_options (SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



59
60
61
62
63
64
65
66
67
68
# File 'lib/surge_api/resources/accounts.rb', line 59

def update(id, params = {})
  parsed, options = SurgeAPI::AccountUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["accounts/%1$s", id],
    body: parsed,
    model: SurgeAPI::Account,
    options: options
  )
end