mailinator_client 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ # Stats Actions
2
+
3
+ Details on the various actions that can be performed on the Stats resource, including the expected parameters and the potential responses.
4
+
5
+ ##### Contents
6
+
7
+ * [GetTeamStats](#getteamstats)
8
+ * [GetTeam](#getteam)
9
+
10
+ <br/>
11
+
12
+ ## GetTeamStats
13
+
14
+ Retrieves stats of team
15
+
16
+ ```ruby
17
+ result = client.stats.get_team_stats()
18
+
19
+ puts result
20
+ ```
21
+
22
+ <br/>
23
+
24
+ ## GetTeam
25
+
26
+ Retrieves team info
27
+
28
+ ```ruby
29
+ result = client.stats.get_team()
30
+
31
+ puts result
32
+ ```
@@ -0,0 +1,46 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2020 Manybrain, Inc.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require_relative "mailinator_client/version"
24
+ require_relative "mailinator_client/error"
25
+ require_relative "mailinator_client/utils"
26
+ require_relative "mailinator_client/domains"
27
+ require_relative "mailinator_client/stats"
28
+ require_relative "mailinator_client/messages"
29
+ require_relative "mailinator_client/rules"
30
+ require_relative "mailinator_client/client"
31
+
32
+ module MailinatorClient
33
+
34
+ def self.client
35
+ @client ||= Client.new
36
+ end
37
+
38
+ def self.method_missing(sym, *args, &block)
39
+ self.client.__send__(sym, *args, &block)
40
+ end
41
+
42
+ def respond_to_missing?(method_name, include_private = false)
43
+ self.client.respond_to?(method_name, include_private)
44
+ end
45
+
46
+ end
@@ -0,0 +1,75 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2020 Manybrain, Inc.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require "httparty"
24
+
25
+ module MailinatorClient
26
+ # Mailinator API
27
+ #
28
+ # User API for accessing Mailinator data
29
+ class Client
30
+ #attr_reader :auth_token, :url
31
+
32
+ def initialize(options = {})
33
+ @auth_token = options.fetch(:auth_token, nil)
34
+ @url = "https://mailinator.com/api/v2"
35
+ end
36
+
37
+ def domains
38
+ @domains ||= Domains.new(self)
39
+ end
40
+
41
+ def stats
42
+ @stats ||= Stats.new(self)
43
+ end
44
+
45
+ def messages
46
+ @messages ||= Messages.new(self)
47
+ end
48
+
49
+ def rules
50
+ @rules ||= Rules.new(self)
51
+ end
52
+
53
+ def request(options = {})
54
+ headers = options.fetch(:headers, {})
55
+ method = options.fetch(:method, :get)
56
+
57
+ headers["Accept"] = "application/json"
58
+ headers["Content-Type"] = "application/json"
59
+ headers["Authorization"] = @auth_token if @auth_token
60
+ path = @url + options.fetch(:path, "")
61
+
62
+ response = HTTParty.send(method, path,
63
+ query: Utils.fix_query_arrays(options[:query]),
64
+ body: options[:body] && options[:body].to_json(),
65
+ headers: headers)
66
+
67
+ result = response.parsed_response
68
+ if response.code >= 400
69
+ raise ResponseError.new(response.code, result)
70
+ end
71
+
72
+ result
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,87 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2020 Manybrain, Inc.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require "json"
24
+
25
+ module MailinatorClient
26
+
27
+ # Class containing all the actions for the Domains Resource
28
+ class Domains
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Fetches a list of all your domains.
35
+ #
36
+ # Authentication:
37
+ # The client must be configured with a valid api
38
+ # access token to call this action.
39
+ #
40
+ # Responses:
41
+ # * Collection of domains (https://manybrain.github.io/m8rdocs/#get-usage-statistica)
42
+ def get_domains()
43
+ query_params = {}
44
+ headers = {}
45
+ body = nil
46
+
47
+ path = "/domains"
48
+
49
+ response = @client.request(
50
+ method: :get,
51
+ path: path,
52
+ query: query_params,
53
+ headers: headers,
54
+ body: body)
55
+ end
56
+
57
+ # Fetches a specific domain
58
+ #
59
+ # Authentication:
60
+ # The client must be configured with a valid api
61
+ # access token to call this action.
62
+ #
63
+ # Parameters:
64
+ # * {string} domainId - The Domain name or the Domain id
65
+ #
66
+ # Responses:
67
+ # * Domain (https://manybrain.github.io/m8rdocs/#get-domain)
68
+ def get_domain(params = {})
69
+ params = Utils.symbolize_hash_keys(params)
70
+ query_params = { }
71
+ headers = {}
72
+ body = nil
73
+
74
+ raise ArgumentError.new("domain id is required") unless params.has_key?(:domainId)
75
+
76
+ path = "/domains/#{params[:domainId]}"
77
+
78
+ @client.request(
79
+ method: :get,
80
+ path: path,
81
+ query: query_params,
82
+ headers: headers,
83
+ body: body)
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,34 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2020 Manybrain, Inc.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ module MailinatorClient
24
+ class ResponseError < StandardError
25
+ attr_reader :code
26
+ attr_reader :type
27
+
28
+ def initialize(code, result)
29
+ @code = code
30
+ @type = result["type"]
31
+ super(result["message"])
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,371 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2020 Manybrain, Inc.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require "json"
24
+
25
+ module MailinatorClient
26
+
27
+ # Class containing all the actions for the Messages Resource
28
+ class Messages
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Retrieves a list of messages summaries. You can retreive a list by inbox, inboxes, or entire domain.
35
+ #
36
+ # Authentication:
37
+ # The client must be configured with a valid api
38
+ # access token to call this action.
39
+ #
40
+ # Parameters:
41
+ # * {string} domainId - The Domain name or the Domain id
42
+ # * {string} inbox - The Inbox name
43
+ # * {number} skip - Skip this many emails in your Private Domain
44
+ # * {number} limit - Number of emails to fetch from your Private Domain
45
+ # * {string} sort - Sort results by ascending or descending
46
+ # * {boolean} decodeSubject - true: decode encoded subjects
47
+ #
48
+ # Responses:
49
+ # * Collection of messages (https://manybrain.github.io/m8rdocs/#fetch-inbox-aka-fetch-message-summaries)
50
+ def fetch_inbox(params = {})
51
+ params = Utils.symbolize_hash_keys(params)
52
+ query_params = { skip: 0, limit: 50, sort: "acending", decodeSubject: false }
53
+ headers = {}
54
+ body = nil
55
+
56
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
57
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
58
+
59
+ query_params[:skip] = params[:skip] if params.has_key?(:skip)
60
+ query_params[:limit] = params[:limit] if params.has_key?(:limit)
61
+ query_params[:sort] = params[:sort] if params.has_key?(:sort)
62
+ query_params[:decodeSubject] = params[:decodeSubject] if params.has_key?(:decodeSubject)
63
+
64
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}"
65
+
66
+ @client.request(
67
+ method: :get,
68
+ path: path,
69
+ query: query_params,
70
+ headers: headers,
71
+ body: body)
72
+ end
73
+
74
+ # Retrieves a specific message by id.
75
+ #
76
+ # Authentication:
77
+ # The client must be configured with a valid api
78
+ # access token to call this action.
79
+ #
80
+ # Parameters:
81
+ # * {string} domainId - The Domain name or the Domain id
82
+ # * {string} inbox - The Inbox name
83
+ # * {string} messageId - The Message id
84
+ #
85
+ # Responses:
86
+ # * Message (https://manybrain.github.io/m8rdocs/#fetch-message)
87
+ def fetch_message(params = {})
88
+ params = Utils.symbolize_hash_keys(params)
89
+ query_params = { }
90
+ headers = {}
91
+ body = nil
92
+
93
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
94
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
95
+ raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
96
+
97
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}"
98
+
99
+ @client.request(
100
+ method: :get,
101
+ path: path,
102
+ query: query_params,
103
+ headers: headers,
104
+ body: body)
105
+ end
106
+
107
+ # Retrieves a specific SMS message by sms number.
108
+ #
109
+ # Authentication:
110
+ # The client must be configured with a valid api
111
+ # access token to call this action.
112
+ #
113
+ # Parameters:
114
+ # * {string} domainId - The Domain name or the Domain id
115
+ # * {string} inbox - The Inbox name
116
+ # * {string} teamSmsNumber - The Team sms number
117
+ #
118
+ # Responses:
119
+ # * Collection of messages (https://manybrain.github.io/m8rdocs/#fetch-an-sms-messages)
120
+ def fetch_sms_message(params = {})
121
+ params = Utils.symbolize_hash_keys(params)
122
+ query_params = { }
123
+ headers = {}
124
+ body = nil
125
+
126
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
127
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
128
+ raise ArgumentError.new("team sms number is required") unless params.has_key?(:teamSmsNumber)
129
+
130
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/#{params[:teamSmsNumber]}"
131
+
132
+ @client.request(
133
+ method: :get,
134
+ path: path,
135
+ query: query_params,
136
+ headers: headers,
137
+ body: body)
138
+ end
139
+
140
+ # Retrieves a list of attachments for a message. Note attachments are expected to be in Email format.
141
+ #
142
+ # Authentication:
143
+ # The client must be configured with a valid api
144
+ # access token to call this action.
145
+ #
146
+ # Parameters:
147
+ # * {string} domainId - The Domain name or the Domain id
148
+ # * {string} inbox - The Inbox name
149
+ # * {string} messageId - The Message id
150
+ #
151
+ # Responses:
152
+ # * Collection of attachments (https://manybrain.github.io/m8rdocs/#fetch-list-of-attachments)
153
+ def fetch_attachments(params = {})
154
+ params = Utils.symbolize_hash_keys(params)
155
+ query_params = { }
156
+ headers = {}
157
+ body = nil
158
+
159
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
160
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
161
+ raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
162
+
163
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}/attachments"
164
+
165
+ @client.request(
166
+ method: :get,
167
+ path: path,
168
+ query: query_params,
169
+ headers: headers,
170
+ body: body)
171
+ end
172
+
173
+
174
+ # Retrieves a specific attachment.
175
+ #
176
+ # Authentication:
177
+ # The client must be configured with a valid api
178
+ # access token to call this action.
179
+ #
180
+ # Parameters:
181
+ # * {string} domainId - The Domain name or the Domain id
182
+ # * {string} inbox - The Inbox name
183
+ # * {string} messageId - The Message id
184
+ # * {string} attachmentId - The Attachment id
185
+ #
186
+ # Responses:
187
+ # * Attachment (https://manybrain.github.io/m8rdocs/#fetch-attachment)
188
+ def fetch_attachment(params = {})
189
+ params = Utils.symbolize_hash_keys(params)
190
+ query_params = { }
191
+ headers = {}
192
+ body = nil
193
+
194
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
195
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
196
+ raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
197
+ raise ArgumentError.new("attachment id is required") unless params.has_key?(:attachmentId)
198
+
199
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}/attachments/#{params[:attachmentId]}"
200
+
201
+ @client.request(
202
+ method: :get,
203
+ path: path,
204
+ query: query_params,
205
+ headers: headers,
206
+ body: body)
207
+ end
208
+
209
+ # Retrieves all links found within a given email.
210
+ #
211
+ # Authentication:
212
+ # The client must be configured with a valid api
213
+ # access token to call this action.
214
+ #
215
+ # Parameters:
216
+ # * {string} domainId - The Domain name or the Domain id
217
+ # * {string} inbox - The Inbox name
218
+ # * {string} messageId - The Message id
219
+ #
220
+ # Responses:
221
+ # * Collection of links (https://manybrain.github.io/m8rdocs/#fetch-links)
222
+ def fetch_message_links(params = {})
223
+ params = Utils.symbolize_hash_keys(params)
224
+ query_params = { }
225
+ headers = {}
226
+ body = nil
227
+
228
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
229
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
230
+ raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
231
+
232
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}/links"
233
+
234
+ @client.request(
235
+ method: :get,
236
+ path: path,
237
+ query: query_params,
238
+ headers: headers,
239
+ body: body)
240
+ end
241
+
242
+ # Deletes ALL messages from a Private Domain. Caution: This action is irreversible.
243
+ #
244
+ # Authentication:
245
+ # The client must be configured with a valid api
246
+ # access token to call this action.
247
+ #
248
+ # Parameters:
249
+ # * {string} domainId - The Domain name or the Domain id
250
+ #
251
+ # Responses:
252
+ # * Status and count of removed messages (https://manybrain.github.io/m8rdocs/#delete-all-messages-by-domain)
253
+ def delete_all_domain_messages(params = {})
254
+ params = Utils.symbolize_hash_keys(params)
255
+ query_params = { }
256
+ headers = {}
257
+ body = nil
258
+
259
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
260
+
261
+ path = "/domains/#{params[:domain]}/inboxes"
262
+
263
+ @client.request(
264
+ method: :delete,
265
+ path: path,
266
+ query: query_params,
267
+ headers: headers,
268
+ body: body)
269
+ end
270
+
271
+ # Deletes ALL messages from a specific private inbox.
272
+ #
273
+ # Authentication:
274
+ # The client must be configured with a valid api
275
+ # access token to call this action.
276
+ #
277
+ # Parameters:
278
+ # * {string} domainId - The Domain name or the Domain id
279
+ # * {string} inbox - The Inbox name
280
+ #
281
+ # Responses:
282
+ # * Status and count of removed messages (https://manybrain.github.io/m8rdocs/#delete-all-messages-by-inbox)
283
+ def delete_all_inbox_messages(params = {})
284
+ params = Utils.symbolize_hash_keys(params)
285
+ query_params = { }
286
+ headers = {}
287
+ body = nil
288
+
289
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
290
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
291
+
292
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}"
293
+
294
+ @client.request(
295
+ method: :delete,
296
+ path: path,
297
+ query: query_params,
298
+ headers: headers,
299
+ body: body)
300
+ end
301
+
302
+ # Deletes a specific messages.
303
+ #
304
+ # Authentication:
305
+ # The client must be configured with a valid api
306
+ # access token to call this action.
307
+ #
308
+ # Parameters:
309
+ # * {string} domainId - The Domain name or the Domain id
310
+ # * {string} inbox - The Inbox name
311
+ # * {string} messageId - The Message id
312
+ #
313
+ # Responses:
314
+ # * Status and count of removed messages (https://manybrain.github.io/m8rdocs/#delete-a-message)
315
+ def delete_message(params = {})
316
+ params = Utils.symbolize_hash_keys(params)
317
+ query_params = { }
318
+ headers = {}
319
+ body = nil
320
+
321
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
322
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
323
+ raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
324
+
325
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages/#{params[:messageId]}"
326
+
327
+ @client.request(
328
+ method: :delete,
329
+ path: path,
330
+ query: query_params,
331
+ headers: headers,
332
+ body: body)
333
+ end
334
+
335
+ # Deliver a JSON message into your private domain.
336
+ #
337
+ # Authentication:
338
+ # The client must be configured with a valid api
339
+ # access token to call this action.
340
+ #
341
+ # Parameters:
342
+ # * {string} domainId - The Domain name or the Domain id
343
+ # * {string} inbox - The Inbox name
344
+ # * {string} messageToPost - The Message object (https://manybrain.github.io/m8rdocs/#inject-a-message-http-post-messages)
345
+ #
346
+ # Responses:
347
+ # * Status, Id and RulesToFired info (https://manybrain.github.io/m8rdocs/#fetch-an-sms-messages)
348
+ def inject_message(params = {})
349
+ params = Utils.symbolize_hash_keys(params)
350
+ query_params = { }
351
+ headers = {}
352
+ body = nil
353
+
354
+ raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
355
+ raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
356
+ raise ArgumentError.new("messageToPost is required") unless params.has_key?(:messageToPost)
357
+
358
+ body = params[:messageToPost] if params.has_key?(:messageToPost)
359
+
360
+ path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}/messages"
361
+
362
+ @client.request(
363
+ method: :post,
364
+ path: path,
365
+ query: query_params,
366
+ headers: headers,
367
+ body: body)
368
+ end
369
+
370
+ end
371
+ end