Class: MailinatorClient::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/mailinator_client/messages.rb

Overview

Class containing all the actions for the Messages Resource

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Messages

Returns a new instance of Messages.



8
9
10
# File 'lib/mailinator_client/messages.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#delete_all_domain_messages(params = {}) ⇒ Object

Deletes ALL messages from a Private Domain. Caution: This action is irreversible.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

Responses:

Raises:

  • (ArgumentError)


417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/mailinator_client/messages.rb', line 417

def delete_all_domain_messages(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)

  path = "/domains/#{params[:domain]}/inboxes"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#delete_all_inbox_messages(params = {}) ⇒ Object

Deletes ALL messages from a specific private inbox.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

Responses:

Raises:

  • (ArgumentError)


447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/mailinator_client/messages.rb', line 447

def delete_all_inbox_messages(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#delete_message(params = {}) ⇒ Object

Deletes a specific messages.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/mailinator_client/messages.rb', line 479

def delete_message(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_inbox(params = {}) ⇒ Object

Retrieves a list of messages summaries. You can retreive a list by inbox, inboxes, or entire domain.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

  • number skip - [Optional] Skip this many emails in your Private Domain

  • number limit - [Optional] Number of emails to fetch from your Private Domain

  • string sort - [Optional] Sort results by ascending or descending

  • boolean decodeSubject - [Optional] true: decode encoded subjects

  • string cursor - [Optional] Pagination cursor for large result sets (obtained from previous response)

  • boolean full - [Optional] Return full email content with body/attachments (true) or just metadata (false). Default: false

  • string delete - [Optional] Auto-delete message after retrieval (e.g., “10s” = 10 seconds, “5m” = 5 minutes)

  • string wait - [Optional] Maximum time to wait for new messages (e.g., “30s” = 30 seconds)

Responses:

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/mailinator_client/messages.rb', line 32

def fetch_inbox(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { skip: 0, limit: 50, sort: "ascending", decodeSubject: false }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)

  query_params[:skip] = params[:skip] if params.has_key?(:skip)
  query_params[:limit] = params[:limit] if params.has_key?(:limit)
  query_params[:sort] = params[:sort] if params.has_key?(:sort)
  query_params[:decodeSubject] = params[:decodeSubject] if params.has_key?(:decodeSubject)
  query_params[:cursor] = params[:cursor] if params.has_key?(:cursor)
  query_params[:full] = params[:full] if params.has_key?(:full)
  query_params[:delete] = params[:delete] if params.has_key?(:delete)
  query_params[:wait] = params[:wait] if params.has_key?(:wait)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_inbox_message(params = {}) ⇒ Object

Retrieves a specific message by id for specific inbox.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

  • string messageId - The Message id

  • string delete - [Optional] Auto-delete message after retrieval (e.g., “10s” = 10 seconds, “5m” = 5 minutes)

Responses:

Raises:

  • (ArgumentError)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/mailinator_client/messages.rb', line 74

def fetch_inbox_message(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  query_params[:delete] = params[:delete] if params.has_key?(:delete)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_inbox_message_attachment(params = {}) ⇒ Object

Retrieves a specific attachment for specific inbox.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

  • string messageId - The Message id

  • string attachmentId - The Attachment id

Responses:

Raises:

  • (ArgumentError)


257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/mailinator_client/messages.rb', line 257

def fetch_inbox_message_attachment(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
  raise ArgumentError.new("attachment id is required") unless params.has_key?(:attachmentId)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}/attachments/#{params[:attachmentId]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_inbox_message_attachments(params = {}) ⇒ Object

Retrieves a list of attachments for a message for specific inbox. Note attachments are expected to be in Email format.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/mailinator_client/messages.rb', line 192

def fetch_inbox_message_attachments(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}/attachments"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

Retrieves all links found within a given email for specific inbox.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/mailinator_client/messages.rb', line 386

def fetch_inbox_message_links(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}/links"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_inbox_message_raw(params = {}) ⇒ Object

Retrieves all raw data found within a given email for specific inbox.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/mailinator_client/messages.rb', line 642

def fetch_inbox_message_raw(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}/raw"
  
  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_inbox_message_smtp_log(params = {}) ⇒ Object

Retrieves all smtp log found within a given email for specific inbox.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
# File 'lib/mailinator_client/messages.rb', line 578

def fetch_inbox_message_smtp_log(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}/smtplog"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_latest_inbox_messages(params = {}) ⇒ Object

That fetches the latest 5 FULL messages for specific inbox.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string inbox - The Inbox name

Responses:

Raises:

  • (ArgumentError)


703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
# File 'lib/mailinator_client/messages.rb', line 703

def fetch_latest_inbox_messages(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/*"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_latest_messages(params = {}) ⇒ Object

That fetches the latest 5 FULL messages.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

Responses:

Raises:

  • (ArgumentError)


673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# File 'lib/mailinator_client/messages.rb', line 673

def fetch_latest_messages(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)

  path = "/domains/#{params[:domain]}/messages/*"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_message(params = {}) ⇒ Object

Retrieves a specific message by id.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string messageId - The Message id

  • string delete - [Optional] Auto-delete message after retrieval (e.g., “10s” = 10 seconds, “5m” = 5 minutes)

Responses:

Raises:

  • (ArgumentError)


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/mailinator_client/messages.rb', line 109

def fetch_message(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  query_params[:delete] = params[:delete] if params.has_key?(:delete)

  path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_message_attachment(params = {}) ⇒ Object

Retrieves a specific attachment.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string messageId - The Message id

  • string attachmentId - The Attachment id

Responses:

Raises:

  • (ArgumentError)


291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/mailinator_client/messages.rb', line 291

def fetch_message_attachment(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
  raise ArgumentError.new("attachment id is required") unless params.has_key?(:attachmentId)

  path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}/attachments/#{params[:attachmentId]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_message_attachments(params = {}) ⇒ Object

Retrieves a list of attachments for a message. Note attachments are expected to be in Email format.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/mailinator_client/messages.rb', line 224

def fetch_message_attachments(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}/attachments"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

Retrieves all links found within a given email.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/mailinator_client/messages.rb', line 354

def fetch_message_links(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}/links"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

Retrieves all links full info found within a given email.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/mailinator_client/messages.rb', line 323

def fetch_message_links_full(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}/linksfull"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_message_raw(params = {}) ⇒ Object

Retrieves all raw data found within a given email.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# File 'lib/mailinator_client/messages.rb', line 610

def fetch_message_raw(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}/raw"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_message_smtp_log(params = {}) ⇒ Object

Retrieves all smtp log found within a given email.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/mailinator_client/messages.rb', line 546

def fetch_message_smtp_log(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)

  path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}/smtplog"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#fetch_sms_message(params = {}) ⇒ Object

Retrieves a specific SMS message by sms number.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

  • string domainId - The Domain name or the Domain id

  • string teamSmsNumber - The Team sms number

  • number skip - [Optional] Skip this many emails in your Private Domain

  • number limit - [Optional] Number of emails to fetch from your Private Domain

  • string sort - [Optional] Sort results by ascending or descending

  • boolean decode_subject - [Optional] true: decode encoded subjects

  • string cursor - [Optional] Pagination cursor for large result sets (obtained from previous response)

  • boolean full - [Optional] Return full email content with body/attachments (true) or just metadata (false). Default: false

  • string delete - [Optional] Auto-delete message after retrieval (e.g., “10s” = 10 seconds, “5m” = 5 minutes)

  • string wait - [Optional] Maximum time to wait for new messages (e.g., “30s” = 30 seconds)

Responses:

Raises:

  • (ArgumentError)


150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/mailinator_client/messages.rb', line 150

def fetch_sms_message(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { skip: 0, limit: 50, sort: "ascending", decode_subject: false }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("team sms number is required") unless params.has_key?(:teamSmsNumber)

  query_params[:skip] = params[:skip] if params.has_key?(:skip)
  query_params[:limit] = params[:limit] if params.has_key?(:limit)
  query_params[:sort] = params[:sort] if params.has_key?(:sort)
  query_params[:decode_subject] = params[:decode_subject] if params.has_key?(:decode_subject)
  query_params[:decode_subject] = params[:decodeSubject] if params.has_key?(:decodeSubject)
  query_params[:cursor] = params[:cursor] if params.has_key?(:cursor)
  query_params[:full] = params[:full] if params.has_key?(:full)
  query_params[:delete] = params[:delete] if params.has_key?(:delete)
  query_params[:wait] = params[:wait] if params.has_key?(:wait)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:teamSmsNumber]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#post_message(params = {}) ⇒ Object

Deliver a JSON message into your private domain.

Authentication: The client must be configured with a valid api access token to call this action.

Parameters:

Responses:

Raises:

  • (ArgumentError)


512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/mailinator_client/messages.rb', line 512

def post_message(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { }
  headers = {}
  body = nil

  raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("messageToPost is required") unless params.has_key?(:messageToPost)

  body = params[:messageToPost] if params.has_key?(:messageToPost)

  path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages"

  @client.request(
    method: :post,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end