Class: Mailtrap::InboundInboxesAPI
- Inherits:
-
Object
- Object
- Mailtrap::InboundInboxesAPI
- Includes:
- BaseAPI
- Defined in:
- lib/mailtrap/inbound_inboxes_api.rb
Constant Summary collapse
- CREATE_OPTIONS =
%i[name domain_id].freeze
- UPDATE_OPTIONS =
%i[name].freeze
Instance Attribute Summary
Attributes included from BaseAPI
Instance Method Summary collapse
-
#create(folder_id, options) ⇒ InboundInbox
Creates a new inbox in a folder.
-
#delete(folder_id, inbox_id) ⇒ Object
Deletes an inbox.
-
#get(folder_id, inbox_id) ⇒ InboundInbox
Retrieves a specific inbox.
-
#initialize(client = Mailtrap::Client.new) ⇒ InboundInboxesAPI
constructor
Inbound is scoped to the token's account, so no account_id is required.
-
#list(folder_id) ⇒ Array<InboundInbox>
Lists all inboxes in a folder.
-
#update(folder_id, inbox_id, options) ⇒ InboundInbox
Updates an inbox.
Methods included from BaseAPI
Constructor Details
#initialize(client = Mailtrap::Client.new) ⇒ InboundInboxesAPI
Inbound is scoped to the token's account, so no account_id is required.
17 18 19 |
# File 'lib/mailtrap/inbound_inboxes_api.rb', line 17 def initialize(client = Mailtrap::Client.new) @client = client end |
Instance Method Details
#create(folder_id, options) ⇒ InboundInbox
Creates a new inbox in a folder
46 47 48 49 |
# File 'lib/mailtrap/inbound_inboxes_api.rb', line 46 def create(folder_id, ) (, CREATE_OPTIONS) handle_response(client.post(inboxes_path(folder_id), )) end |
#delete(folder_id, inbox_id) ⇒ Object
Deletes an inbox
69 70 71 |
# File 'lib/mailtrap/inbound_inboxes_api.rb', line 69 def delete(folder_id, inbox_id) client.delete("#{inboxes_path(folder_id)}/#{inbox_id}") end |
#get(folder_id, inbox_id) ⇒ InboundInbox
Retrieves a specific inbox
34 35 36 |
# File 'lib/mailtrap/inbound_inboxes_api.rb', line 34 def get(folder_id, inbox_id) handle_response(client.get("#{inboxes_path(folder_id)}/#{inbox_id}")) end |
#list(folder_id) ⇒ Array<InboundInbox>
Lists all inboxes in a folder
25 26 27 |
# File 'lib/mailtrap/inbound_inboxes_api.rb', line 25 def list(folder_id) client.get(inboxes_path(folder_id)).map { |item| handle_response(item) } end |
#update(folder_id, inbox_id, options) ⇒ InboundInbox
Updates an inbox
59 60 61 62 |
# File 'lib/mailtrap/inbound_inboxes_api.rb', line 59 def update(folder_id, inbox_id, ) (, UPDATE_OPTIONS) handle_response(client.patch("#{inboxes_path(folder_id)}/#{inbox_id}", )) end |