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.



30
31
32
# File 'lib/mailinator_client/messages.rb', line 30

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)


376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/mailinator_client/messages.rb', line 376

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)


406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/mailinator_client/messages.rb', line 406

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)


438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/mailinator_client/messages.rb', line 438

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 - Skip this many emails in your Private Domain

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

  • string sort - Sort results by ascending or descending

  • boolean decodeSubject - true: decode encoded subjects

Responses:

Raises:

  • (ArgumentError)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/mailinator_client/messages.rb', line 50

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)

  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

Responses:

Raises:

  • (ArgumentError)


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/mailinator_client/messages.rb', line 87

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)

  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)


247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/mailinator_client/messages.rb', line 247

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)


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/mailinator_client/messages.rb', line 182

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)


345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/mailinator_client/messages.rb', line 345

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)


601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# File 'lib/mailinator_client/messages.rb', line 601

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)


537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/mailinator_client/messages.rb', line 537

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)


662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/mailinator_client/messages.rb', line 662

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)


632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/mailinator_client/messages.rb', line 632

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

Responses:

Raises:

  • (ArgumentError)


119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/mailinator_client/messages.rb', line 119

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)

  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)


281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/mailinator_client/messages.rb', line 281

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)


214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/mailinator_client/messages.rb', line 214

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)


313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/mailinator_client/messages.rb', line 313

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

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


569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
# File 'lib/mailinator_client/messages.rb', line 569

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)


505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'lib/mailinator_client/messages.rb', line 505

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

Responses:

Raises:

  • (ArgumentError)


150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/mailinator_client/messages.rb', line 150

def fetch_sms_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("team sms number is required") unless params.has_key?(:teamSmsNumber)

  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)


471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/mailinator_client/messages.rb', line 471

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