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_idObject (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

#listArray<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