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)


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

def private_custom_service_inbox_webhook(params = {})
  query_params = { whtoken: "" }
  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)
  
  query_params[:whtoken] = params[:whToken] if params.has_key?(:whToken)

  path = "/domains/private/#{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)


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/mailinator_client/webhooks.rb', line 113

def private_custom_service_webhook(params = {})
  query_params = { whtoken: "" }
  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)
  
  query_params[:whtoken] = params[:whToken] if params.has_key?(:whToken)

  path = "/domains/private/#{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)


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/mailinator_client/webhooks.rb', line 79

def private_inbox_webhook(params = {})
  query_params = { whtoken: "" }
  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)

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

  path = "/domains/private/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)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/mailinator_client/webhooks.rb', line 46

def private_webhook(params = {})
  query_params = { whtoken: "" }
  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)
  
  query_params[:whtoken] = params[:whToken] if params.has_key?(:whToken)

  path = "/domains/private/webhook"
  
  response = @client.request(
    method: :post,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end