Class: Mailtrap::InboxesAPI

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

Instance Attribute Summary

Attributes included from BaseAPI

#account_id, #client

Instance Method Summary collapse

Methods included from BaseAPI

included, #initialize

Instance Method Details

#clean(inbox_id) ⇒ Inbox

Delete all messages (emails) from Inbox

Parameters:

  • inbox_id (Integer)

    The Inbox identifier

Returns:

  • (Inbox)

    Updated Inbox object

Raises:



65
66
67
68
# File 'lib/mailtrap/inboxes_api.rb', line 65

def clean(inbox_id)
  response = client.patch("#{base_path}/#{inbox_id}/clean")
  handle_response(response)
end

#create(options) ⇒ Inbox

Creates a new inbox

Parameters:

  • options (Hash)

    The parameters to create

Options Hash (options):

  • :name (String)

    The inbox name

Returns:

  • (Inbox)

    Created inbox object

Raises:



34
35
36
37
38
39
# File 'lib/mailtrap/inboxes_api.rb', line 34

def create(options)
  validate_options!(options, supported_options + [:project_id])
  response = client.post("/api/accounts/#{account_id}/projects/#{options[:project_id]}/inboxes",
                         wrap_request(options))
  handle_response(response)
end

#delete(inbox_id) ⇒ Object

Deletes an inbox

Parameters:

  • inbox_id (Integer)

    The Inbox identifier

Returns:

  • nil

Raises:



45
46
47
# File 'lib/mailtrap/inboxes_api.rb', line 45

def delete(inbox_id)
  base_delete(inbox_id)
end

#get(inbox_id) ⇒ Inbox

Retrieves a specific inbox

Parameters:

  • inbox_id (Integer)

    The inbox identifier

Returns:

  • (Inbox)

    Inbox object

Raises:



24
25
26
# File 'lib/mailtrap/inboxes_api.rb', line 24

def get(inbox_id)
  base_get(inbox_id)
end

#listArray<Inbox>

Lists all Inboxes for the account

Returns:

  • (Array<Inbox>)

    Array of Inboxes

Raises:



16
17
18
# File 'lib/mailtrap/inboxes_api.rb', line 16

def list
  base_list
end

#mark_as_read(inbox_id) ⇒ Inbox

Mark all messages in the inbox as read

Parameters:

  • inbox_id (Integer)

    The Inbox identifier

Returns:

  • (Inbox)

    Updated Inbox object

Raises:



74
75
76
77
# File 'lib/mailtrap/inboxes_api.rb', line 74

def mark_as_read(inbox_id)
  response = client.patch("#{base_path}/#{inbox_id}/all_read")
  handle_response(response)
end

#reset_credentials(inbox_id) ⇒ Inbox

Reset SMTP credentials of the inbox

Parameters:

  • inbox_id (Integer)

    The Inbox identifier

Returns:

  • (Inbox)

    Updated Inbox object

Raises:



83
84
85
86
# File 'lib/mailtrap/inboxes_api.rb', line 83

def reset_credentials(inbox_id)
  response = client.patch("#{base_path}/#{inbox_id}/reset_credentials")
  handle_response(response)
end

#update(inbox_id, options) ⇒ Inbox

Updates an existing Inbox

Parameters:

  • inbox_id (Integer)

    The Inbox identifier

  • options (Hash)

    The parameters to update

Options Hash (options):

  • :name (String)

    The inbox name

  • :email_username (String)

    The inbox email username

Returns:

  • (Inbox)

    Updated Inbox object

Raises:



57
58
59
# File 'lib/mailtrap/inboxes_api.rb', line 57

def update(inbox_id, options)
  base_update(inbox_id, options, supported_options + [:email_username])
end