Class: MailinatorClient::Webhooks

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

Overview

Class containing all the actions for the Webhooks Resource

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Webhooks

Returns a new instance of Webhooks.



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

def initialize(client)
  @client = client
end

Instance Method Details

#private_custom_service_inbox_webhook(params = {}) ⇒ Object

The SMS message will arrive in the Private Mailinator inbox corresponding to the Twilio Phone Number. (only the digits, if a plus sign precedes the number it will be removed) If you wish the message to arrive in a different inbox, you may append the destination inbox to the URL.

Parameters:

  • string whToken - webhook token

  • string inbox - inbox

  • string customService - custom service name

  • string webhook - The Webhook object

Responses:

Raises:

  • (ArgumentError)


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

def private_custom_service_inbox_webhook(params = {})
  query_params = {}
  headers = {}
  body = nil

  raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
  raise ArgumentError.new("customService is required") unless params.has_key?(:customService)
  raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
  raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)

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

  path = "/domains/#{params[:whToken]}/#{params[:customService]}/#{params[:inbox]}"

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

#private_custom_service_webhook(params = {}) ⇒ Object

If you have a Twilio account which receives incoming SMS messages. You may direct those messages through this facility to inject those messages into the Mailinator system. Mailinator intends to apply specific mappings for certain services that commonly publish webhooks. If you test incoming Messages to SMS numbers via Twilio, you may use this endpoint to correctly map “to”, “from”, and “subject” of those messages to the Mailinator system.By default, the destination inbox is the Twilio phone number.

Parameters:

  • string whToken - webhook token

  • string customService - custom service name

  • string webhook - The Webhook object

Responses:

Raises:

  • (ArgumentError)


226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/mailinator_client/webhooks.rb', line 226

def private_custom_service_webhook(params = {})
  query_params = {}
  headers = {}
  body = nil

  raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
  raise ArgumentError.new("customService is required") unless params.has_key?(:customService)
  raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)

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

  path = "/domains/#{params[:whToken]}/#{params[:customService]}"

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

#private_inbox_webhook(params = {}) ⇒ Object

This command will deliver the message to the :inbox inbox Incoming Webhooks are delivered to Mailinator inboxes and from that point onward are not notably different than other messages in the system (i.e. emails). As normal, Mailinator will list all messages in the Inbox page and via the Inbox API calls. If the incoming JSON payload does not contain a “from” or “subject”, then dummy values will be inserted in these fields. You may retrieve such messages via the Web Interface, the API, or the Rule System

Parameters:

  • string whToken - webhook token

  • string inbox - inbox

  • string webhook - The Webhook object

Responses:

Raises:

  • (ArgumentError)


194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/mailinator_client/webhooks.rb', line 194

def private_inbox_webhook(params = {})
  query_params = {}
  headers = {}
  body = nil

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

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

  path = "/domains/#{params[:whToken]}/webhook/#{params[:inbox]}"

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

#private_webhook(params = {}) ⇒ Object

This command will Webhook messages into your Private Domain The incoming Webhook will arrive in the inbox designated by the “to” field in the incoming request payload. Webhooks into your Private System do NOT use your regular API Token. This is because a typical use case is to enter the Webhook URL into 3rd-party systems(i.e.Twilio, Zapier, IFTTT, etc) and you should never give out your API Token. Check your Team Settings where you can create “Webhook Tokens” designed for this purpose.

Parameters:

  • string whToken - webhook token

  • string webhook - The Webhook object

Responses:

Raises:

  • (ArgumentError)


161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/mailinator_client/webhooks.rb', line 161

def private_webhook(params = {})
  query_params = {}
  headers = {}
  body = nil

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

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

  path = "/domains/#{params[:whToken]}/webhook"

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

#public_custom_service_inbox_webhook(params = {}) ⇒ Object

The SMS message will arrive in the Public Mailinator inbox corresponding to the Twilio Phone Number. (only the digits, if a plus sign precedes the number it will be removed) If you wish the message to arrive in a different inbox, you may append the destination inbox to the URL.

Parameters:

  • string inbox - inbox

  • string customService - custom service name

  • string webhook - The Webhook object

Responses:

Raises:

  • (ArgumentError)


128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/mailinator_client/webhooks.rb', line 128

def public_custom_service_inbox_webhook(params = {})
  query_params = {}
  headers = {}
  body = nil

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

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

  path = "/domains/public/#{params[:customService]}/#{params[:inbox]}"

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

#public_custom_service_webhook(params = {}) ⇒ Object

If you have a Twilio account which receives incoming SMS messages. You may direct those messages through this facility to inject those messages into the Mailinator system.

Parameters:

  • string customService - custom service name

  • string webhook - The Webhook object

Responses:

Raises:

  • (ArgumentError)


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/mailinator_client/webhooks.rb', line 98

def public_custom_service_webhook(params = {})
  query_params = {}
  headers = {}
  body = nil

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

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

  path = "/domains/public/#{params[:customService]}"

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

#public_inbox_webhook(params = {}) ⇒ Object

This command will deliver the message to the :inbox inbox Note that if the Mailinator system cannot determine the destination inbox via the URL or a “to” field in the payload, the message will be rejected. If the message contains a “from” and “subject” field, these will be visible on the inbox page.

Parameters:

  • string inbox - inbox

  • string webhook - The Webhook object

Responses:

Raises:

  • (ArgumentError)


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/mailinator_client/webhooks.rb', line 70

def public_inbox_webhook(params = {})
  query_params = {}
  headers = {}
  body = nil

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

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

  path = "/domains/public/webhook/#{params[:inbox]}"

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

#public_webhook(params = {}) ⇒ Object

This command will deliver the message to the :to inbox that was set into request object

Parameters:

  • string webhook - The Webhook object

Responses:

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/mailinator_client/webhooks.rb', line 41

def public_webhook(params = {})
  query_params = {}
  headers = {}
  body = nil

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

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

  path = "/domains/public/webhook"

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