Class: Mailtrap::SubAccountsAPI

Inherits:
Object
  • Object
show all
Includes:
BaseAPI
Defined in:
lib/mailtrap/sub_accounts_api.rb

Instance Attribute Summary collapse

Attributes included from BaseAPI

#account_id, #client

Instance Method Summary collapse

Methods included from BaseAPI

included

Constructor Details

#initialize(organization_id, client = Mailtrap::Client.new) ⇒ SubAccountsAPI

Returns a new instance of SubAccountsAPI.

Parameters:

  • organization_id (Integer) —

    The organization ID

  • client (Mailtrap::Client) (defaults to: Mailtrap::Client.new) —

    The client instance

Raises:

  • (ArgumentError) —

    If organization_id is nil



19
20
21
22
23
24
# File 'lib/mailtrap/sub_accounts_api.rb', line 19

def initialize(organization_id, client = Mailtrap::Client.new)
  raise ArgumentError, 'organization_id is required' if organization_id.nil?

  @organization_id = organization_id
  @client = client
end

Instance Attribute Details

#organization_id ⇒ Object (readonly)

Returns the value of attribute organization_id.



10
11
12
# File 'lib/mailtrap/sub_accounts_api.rb', line 10

def organization_id
  @organization_id
end

Instance Method Details

#create(options) ⇒ SubAccount

Creates a new sub account under the organization

Parameters:

  • options (Hash) —

    The parameters to create

Options Hash (options):

  • :name (String) —

    Name of the sub account

Returns:

Raises:



39
40
41
# File 'lib/mailtrap/sub_accounts_api.rb', line 39

def create(options)
  base_create(options)
end

#delete(sub_account_id) ⇒ Object

Permanently deletes a sub account under the organization

Requires organization admin permissions. The deletion is permanent and removes all data of the sub account. Deleting the last sub account also deletes the organization. A repeated call for the same sub account returns a 404 error. Rate limit: 10 requests per minute per organization.

Parameters:

  • sub_account_id (Integer) —

    The sub account ID

Returns:

  • nil

Raises:



52
53
54
# File 'lib/mailtrap/sub_accounts_api.rb', line 52

def delete()
  base_delete()
end

#list ⇒ Array<SubAccount>

Lists all sub accounts under the organization

Returns:

Raises:



29
30
31
# File 'lib/mailtrap/sub_accounts_api.rb', line 29

def list
  base_list
end