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.



10
11
12
# File 'lib/mailinator_client/messages.rb', line 10

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 simply 'private'

Responses:

Raises:

  • (ArgumentError)


834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
# File 'lib/mailinator_client/messages.rb', line 834

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 simply 'private'
  • string inbox - The Inbox name

Responses:

Raises:

  • (ArgumentError)


864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
# File 'lib/mailinator_client/messages.rb', line 864

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 simply 'private'
  • string inbox - The Inbox name
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
# File 'lib/mailinator_client/messages.rb', line 896

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 simply 'private'
  • 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)

Responses:

Raises:

  • (ArgumentError)


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
59
60
# File 'lib/mailinator_client/messages.rb', line 33

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)

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

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

  response
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 simply 'private'
  • 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)


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

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 simply 'private'
  • string inbox - The Inbox name
  • string messageId - The Message id
  • string attachmentId - The Attachment id

Responses:

Raises:

  • (ArgumentError)


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

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 simply 'private'
  • string inbox - The Inbox name
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


609
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 609

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 simply 'private'
  • string inbox - The Inbox name
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
# File 'lib/mailinator_client/messages.rb', line 803

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 simply 'private'
  • string inbox - The Inbox name
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
# File 'lib/mailinator_client/messages.rb', line 1059

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 simply 'private'
  • string inbox - The Inbox name
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
# File 'lib/mailinator_client/messages.rb', line 995

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 simply 'private'
  • string inbox - The Inbox name

Responses:

Raises:

  • (ArgumentError)


1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
# File 'lib/mailinator_client/messages.rb', line 1120

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 simply 'private'

Responses:

Raises:

  • (ArgumentError)


1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
# File 'lib/mailinator_client/messages.rb', line 1090

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 simply 'private'
  • string messageId - The Message id
  • string delete - [Optional] Auto-delete message after retrieval (e.g., "10s" = 10 seconds, "5m" = 5 minutes)

Responses:

Raises:

  • (ArgumentError)


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

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 simply 'private'
  • string messageId - The Message id
  • string attachmentId - The Attachment id

Responses:

Raises:

  • (ArgumentError)


708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
# File 'lib/mailinator_client/messages.rb', line 708

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 simply 'private'
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


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

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

#fetch_message_headers(params = {}) ⇒ Object

Retrieves headers for 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 simply 'private'
  • string messageId - The Message id

Responses:

  • Message headers response

Raises:

  • (ArgumentError)


268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/mailinator_client/messages.rb', line 268

def fetch_message_headers(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]}/headers"

  @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 simply 'private'
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
# File 'lib/mailinator_client/messages.rb', line 771

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 simply 'private'
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
# File 'lib/mailinator_client/messages.rb', line 740

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 simply 'private'
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/mailinator_client/messages.rb', line 1027

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 simply 'private'
  • string messageId - The Message id

Responses:

Raises:

  • (ArgumentError)


963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
# File 'lib/mailinator_client/messages.rb', line 963

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_message_summary(params = {}) ⇒ Object

Retrieves the summary for 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 simply 'private'
  • string messageId - The Message id

Responses:

  • Message summary

Raises:

  • (ArgumentError)


144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/mailinator_client/messages.rb', line 144

def fetch_message_summary(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]}/summary"

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

#fetch_message_text(params = {}) ⇒ Object

Retrieves text content for 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 simply 'private'
  • string messageId - The Message id

Responses:

  • Message text response

Raises:

  • (ArgumentError)


175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/mailinator_client/messages.rb', line 175

def fetch_message_text(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]}/text"

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

#fetch_message_texthtml(params = {}) ⇒ Object

Retrieves text/html content for 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 simply 'private'
  • string messageId - The Message id

Responses:

  • Message text/html response

Raises:

  • (ArgumentError)


237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/mailinator_client/messages.rb', line 237

def fetch_message_texthtml(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]}/texthtml"

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

#fetch_message_textplain(params = {}) ⇒ Object

Retrieves text/plain content for 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 simply 'private'
  • string messageId - The Message id

Responses:

  • Message text/plain response

Raises:

  • (ArgumentError)


206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/mailinator_client/messages.rb', line 206

def fetch_message_textplain(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]}/textplain"

  @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 simply 'private'
  • 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)


567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/mailinator_client/messages.rb', line 567

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)


929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
# File 'lib/mailinator_client/messages.rb', line 929

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

#stream_domain_messages(params = {}) ⇒ Object

Streams all messages from a domain.

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

Parameters:

  • string domainId - The Domain name or simply 'private'
  • boolean full - [Optional] Return full email content with body/attachments (true) or just metadata (false). Default: false
  • number limit - [Optional] Number of messages to fetch
  • number throttleInterval - [Optional] Throttle interval in milliseconds
  • string delete - [Optional] Auto-delete message after retrieval (e.g., "10s" = 10 seconds, "5m" = 5 minutes)

Responses:

  • Message stream response

Raises:

  • (ArgumentError)


302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/mailinator_client/messages.rb', line 302

def stream_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)

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

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

  uri = URI.parse(@client.url + path)
  query = Utils.fix_query_arrays(query_params)
  uri.query = URI.encode_www_form(query) unless query.nil? || query.empty?

  headers["Accept"] = "application/json"
  headers["Content-Type"] = "application/json"
  headers["User-Agent"] = "Mailinator SDK - Ruby V#{MailinatorClient::VERSION}"
  headers["Authorization"] = @client.auth_token if @client.auth_token

  response_body = +""
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme == "https"
  http.read_timeout = 20

  request = Net::HTTP::Get.new(uri)
  headers.each { |key, value| request[key] = value }

  http.request(request) do |response|
    if response.code.to_i >= 400
      raise ResponseError.new(response.code.to_i, nil, response.body)
    end

    catch(:done) do
      response.read_body do |chunk|
        response_body << chunk
        if response_body.include?("\n\n") || response_body.include?("}\n") || response_body.strip.end_with?("}")
          throw :done
        end
      end
    end
  end

  payload = response_body.strip
  if payload.start_with?("data:")
    payload_line = payload.lines.find { |line| line.start_with?("data:") }
    payload = payload_line.to_s.sub(/^data:\\s*/, "").strip
  end

  parsed = begin
    JSON.parse(payload)
  rescue JSON::ParserError
    cleaned = payload.encode("UTF-8", invalid: :replace, undef: :replace, replace: "")
    candidate = cleaned
    if candidate.include?("data:")
      data_line = candidate.lines.find { |line| line.start_with?("data:") }
      candidate = data_line.to_s.sub(/^data:\s*/, "")
    end

    in_string = false
    escape = false
    depth = 0
    start_idx = nil
    end_idx = nil

    candidate.each_char.with_index do |ch, idx|
      if start_idx.nil?
        if ch == "{"
          start_idx = idx
          depth = 1
        end
        next
      end

      if in_string
        if escape
          escape = false
        elsif ch == "\\"
          escape = true
        elsif ch == "\""
          in_string = false
        end
      else
        case ch
        when "\""
          in_string = true
        when "{"
          depth += 1
        when "}"
          depth -= 1
          if depth == 0
            end_idx = idx
            break
          end
        end
      end
    end

    if start_idx && end_idx && end_idx >= start_idx
      JSON.parse(candidate[start_idx..end_idx])
    end
  end

  raise ResponseError.new(500, nil, payload) if parsed.nil?

  return parsed if parsed.is_a?(Hash) && parsed.key?("domain") && parsed.key?("msgs")
  return { "domain" => parsed["domain"], "to" => parsed["to"], "msgs" => [parsed] } if parsed.is_a?(Hash)
  parsed
end

#stream_inbox_messages(params = {}) ⇒ Object

Streams all messages from an inbox.

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

Parameters:

  • string domainId - The Domain name or simply 'private'
  • string inbox - The Inbox name
  • boolean full - [Optional] Return full email content with body/attachments (true) or just metadata (false). Default: false
  • number limit - [Optional] Number of messages to fetch
  • number throttleInterval - [Optional] Throttle interval in milliseconds
  • string delete - [Optional] Auto-delete message after retrieval (e.g., "10s" = 10 seconds, "5m" = 5 minutes)

Responses:

  • Message stream response

Raises:

  • (ArgumentError)


432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/mailinator_client/messages.rb', line 432

def stream_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)

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

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

  uri = URI.parse(@client.url + path)
  query = Utils.fix_query_arrays(query_params)
  uri.query = URI.encode_www_form(query) unless query.nil? || query.empty?

  headers["Accept"] = "application/json"
  headers["Content-Type"] = "application/json"
  headers["User-Agent"] = "Mailinator SDK - Ruby V#{MailinatorClient::VERSION}"
  headers["Authorization"] = @client.auth_token if @client.auth_token

  response_body = +""
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme == "https"
  http.read_timeout = 20

  request = Net::HTTP::Get.new(uri)
  headers.each { |key, value| request[key] = value }

  http.request(request) do |response|
    if response.code.to_i >= 400
      raise ResponseError.new(response.code.to_i, nil, response.body)
    end

    catch(:done) do
      response.read_body do |chunk|
        response_body << chunk
        if response_body.include?("\n\n") || response_body.include?("}\n") || response_body.strip.end_with?("}")
          throw :done
        end
      end
    end
  end

  payload = response_body.strip
  if payload.start_with?("data:")
    payload_line = payload.lines.find { |line| line.start_with?("data:") }
    payload = payload_line.to_s.sub(/^data:\\s*/, "").strip
  end

  parsed = begin
    JSON.parse(payload)
  rescue JSON::ParserError
    cleaned = payload.encode("UTF-8", invalid: :replace, undef: :replace, replace: "")
    candidate = cleaned
    if candidate.include?("data:")
      data_line = candidate.lines.find { |line| line.start_with?("data:") }
      candidate = data_line.to_s.sub(/^data:\s*/, "")
    end

    in_string = false
    escape = false
    depth = 0
    start_idx = nil
    end_idx = nil

    candidate.each_char.with_index do |ch, idx|
      if start_idx.nil?
        if ch == "{"
          start_idx = idx
          depth = 1
        end
        next
      end

      if in_string
        if escape
          escape = false
        elsif ch == "\\"
          escape = true
        elsif ch == "\""
          in_string = false
        end
      else
        case ch
        when "\""
          in_string = true
        when "{"
          depth += 1
        when "}"
          depth -= 1
          if depth == 0
            end_idx = idx
            break
          end
        end
      end
    end

    if start_idx && end_idx && end_idx >= start_idx
      JSON.parse(candidate[start_idx..end_idx])
    end
  end

  raise ResponseError.new(500, nil, payload) if parsed.nil?

  return parsed if parsed.is_a?(Hash) && parsed.key?("domain") && parsed.key?("msgs")
  return { "domain" => parsed["domain"], "to" => parsed["to"], "msgs" => [parsed] } if parsed.is_a?(Hash)
  parsed
end