Class: Mailtrap::InboundThreadsAPI
- Inherits:
-
Object
- Object
- Mailtrap::InboundThreadsAPI
- Includes:
- BaseAPI
- Defined in:
- lib/mailtrap/inbound_threads_api.rb
Instance Attribute Summary
Attributes included from BaseAPI
Instance Method Summary collapse
-
#delete(inbox_id, thread_id) ⇒ Object
Deletes a thread.
-
#get(inbox_id, thread_id) ⇒ InboundThread
Fetches a single thread with its messages embedded (oldest first).
-
#initialize(client = Mailtrap::Client.new) ⇒ InboundThreadsAPI
constructor
A new instance of InboundThreadsAPI.
-
#list(inbox_id, last_id: nil, search: nil) ⇒ InboundThreadsListResponse
Lists threads in an inbox (cursor-paginated).
Methods included from BaseAPI
Constructor Details
#initialize(client = Mailtrap::Client.new) ⇒ InboundThreadsAPI
Returns a new instance of InboundThreadsAPI.
18 19 20 |
# File 'lib/mailtrap/inbound_threads_api.rb', line 18 def initialize(client = Mailtrap::Client.new) @client = client end |
Instance Method Details
#delete(inbox_id, thread_id) ⇒ Object
Deletes a thread
53 54 55 |
# File 'lib/mailtrap/inbound_threads_api.rb', line 53 def delete(inbox_id, thread_id) client.delete("#{threads_path(inbox_id)}/#{thread_id}") end |
#get(inbox_id, thread_id) ⇒ InboundThread
Fetches a single thread with its messages embedded (oldest first)
44 45 46 |
# File 'lib/mailtrap/inbound_threads_api.rb', line 44 def get(inbox_id, thread_id) build_thread(client.get("#{threads_path(inbox_id)}/#{thread_id}")) end |
#list(inbox_id, last_id: nil, search: nil) ⇒ InboundThreadsListResponse
Lists threads in an inbox (cursor-paginated)
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mailtrap/inbound_threads_api.rb', line 28 def list(inbox_id, last_id: nil, search: nil) query_params = { last_id:, search: }.compact response = client.get(threads_path(inbox_id), query_params) InboundThreadsListResponse.new( data: Array(response[:data]).map { |item| build_thread(item) }, total_count: response[:total_count], last_id: response[:last_id] ) end |