Class: Mudbase::MessagingApi

Inherits:
Object
  • Object
show all
Defined in:
lib/mudbase/api/messaging_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ MessagingApi

Returns a new instance of MessagingApi.



19
20
21
# File 'lib/mudbase/api/messaging_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/mudbase/api/messaging_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#messaging_get_history(project_id, opts = {}) ⇒ MessageHistoryResponse

Get message history Get message history (push, email, SMS) with filtering and pagination. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :type (String)

    Filter by message type (push, email, or sms).

  • :page (Integer)

    Page number for pagination (1-based). (default to 1)

  • :limit (Integer)

    Maximum number of messages per page. (default to 20)

  • :status (String)

    Filter by delivery status.

Returns:



31
32
33
34
# File 'lib/mudbase/api/messaging_api.rb', line 31

def messaging_get_history(project_id, opts = {})
  data, _status_code, _headers = messaging_get_history_with_http_info(project_id, opts)
  data
end

#messaging_get_history_with_http_info(project_id, opts = {}) ⇒ Array<(MessageHistoryResponse, Integer, Hash)>

Get message history Get message history (push, email, SMS) with filtering and pagination. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :type (String)

    Filter by message type (push, email, or sms).

  • :page (Integer)

    Page number for pagination (1-based). (default to 1)

  • :limit (Integer)

    Maximum number of messages per page. (default to 20)

  • :status (String)

    Filter by delivery status.

Returns:

  • (Array<(MessageHistoryResponse, Integer, Hash)>)

    MessageHistoryResponse data, response status code and response headers



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/mudbase/api/messaging_api.rb', line 45

def messaging_get_history_with_http_info(project_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.messaging_get_history ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling MessagingApi.messaging_get_history"
  end
  allowable_values = ["push", "email", "sms"]
  if @api_client.config.client_side_validation && opts[:'type'] && !allowable_values.include?(opts[:'type'])
    fail ArgumentError, "invalid value for \"type\", must be one of #{allowable_values}"
  end
  allowable_values = ["sent", "failed", "pending"]
  if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
    fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/messaging/projects/{projectId}/messaging/history'.sub('{' + 'projectId' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'MessageHistoryResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerToken']

  new_options = opts.merge(
    :operation => :"MessagingApi.messaging_get_history",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MessagingApi#messaging_get_history\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#messaging_get_stats(project_id, opts = {}) ⇒ MessageStatsResponse

Get message statistics Get messaging statistics including total messages, success rates, and breakdown by type (push, email, SMS). Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start_date (Time)

    Start of the date range for statistics (ISO 8601).

  • :end_date (Time)

    End of the date range for statistics (ISO 8601).

Returns:



112
113
114
115
# File 'lib/mudbase/api/messaging_api.rb', line 112

def messaging_get_stats(project_id, opts = {})
  data, _status_code, _headers = messaging_get_stats_with_http_info(project_id, opts)
  data
end

#messaging_get_stats_with_http_info(project_id, opts = {}) ⇒ Array<(MessageStatsResponse, Integer, Hash)>

Get message statistics Get messaging statistics including total messages, success rates, and breakdown by type (push, email, SMS). Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start_date (Time)

    Start of the date range for statistics (ISO 8601).

  • :end_date (Time)

    End of the date range for statistics (ISO 8601).

Returns:

  • (Array<(MessageStatsResponse, Integer, Hash)>)

    MessageStatsResponse data, response status code and response headers



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/mudbase/api/messaging_api.rb', line 124

def messaging_get_stats_with_http_info(project_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.messaging_get_stats ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling MessagingApi.messaging_get_stats"
  end
  # resource path
  local_var_path = '/api/messaging/projects/{projectId}/messaging/stats'.sub('{' + 'projectId' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil?
  query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'MessageStatsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerToken']

  new_options = opts.merge(
    :operation => :"MessagingApi.messaging_get_stats",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MessagingApi#messaging_get_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#messaging_send_email(project_id, email_request, opts = {}) ⇒ MessageSentResponse

Send transactional email Send a transactional email to one or more recipients. Supports HTML and plain text. Use for verification emails, password resets, notifications, and marketing. Attachments and templates can be configured per project. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • email_request (EmailRequest)

    Recipient(s), subject, HTML and/or plain text body; optional reply-to and attachments.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



180
181
182
183
# File 'lib/mudbase/api/messaging_api.rb', line 180

def messaging_send_email(project_id, email_request, opts = {})
  data, _status_code, _headers = messaging_send_email_with_http_info(project_id, email_request, opts)
  data
end

#messaging_send_email_with_http_info(project_id, email_request, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send transactional email Send a transactional email to one or more recipients. Supports HTML and plain text. Use for verification emails, password resets, notifications, and marketing. Attachments and templates can be configured per project. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • email_request (EmailRequest)

    Recipient(s), subject, HTML and/or plain text body; optional reply-to and attachments.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(MessageSentResponse, Integer, Hash)>)

    MessageSentResponse data, response status code and response headers



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/mudbase/api/messaging_api.rb', line 191

def messaging_send_email_with_http_info(project_id, email_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.messaging_send_email ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling MessagingApi.messaging_send_email"
  end
  # verify the required parameter 'email_request' is set
  if @api_client.config.client_side_validation && email_request.nil?
    fail ArgumentError, "Missing the required parameter 'email_request' when calling MessagingApi.messaging_send_email"
  end
  # resource path
  local_var_path = '/api/messaging/projects/{projectId}/messaging/email'.sub('{' + 'projectId' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(email_request)

  # return_type
  return_type = opts[:debug_return_type] || 'MessageSentResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerToken']

  new_options = opts.merge(
    :operation => :"MessagingApi.messaging_send_email",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MessagingApi#messaging_send_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#messaging_send_push(project_id, push_notification_request, opts = {}) ⇒ MessageSentResponse

Send push notification Send a push notification to one or more devices. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • push_notification_request (PushNotificationRequest)

    Device tokens, notification title/body, optional data payload and image URL.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



254
255
256
257
# File 'lib/mudbase/api/messaging_api.rb', line 254

def messaging_send_push(project_id, push_notification_request, opts = {})
  data, _status_code, _headers = messaging_send_push_with_http_info(project_id, push_notification_request, opts)
  data
end

#messaging_send_push_with_http_info(project_id, push_notification_request, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send push notification Send a push notification to one or more devices. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • push_notification_request (PushNotificationRequest)

    Device tokens, notification title/body, optional data payload and image URL.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(MessageSentResponse, Integer, Hash)>)

    MessageSentResponse data, response status code and response headers



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/mudbase/api/messaging_api.rb', line 265

def messaging_send_push_with_http_info(project_id, push_notification_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.messaging_send_push ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling MessagingApi.messaging_send_push"
  end
  # verify the required parameter 'push_notification_request' is set
  if @api_client.config.client_side_validation && push_notification_request.nil?
    fail ArgumentError, "Missing the required parameter 'push_notification_request' when calling MessagingApi.messaging_send_push"
  end
  # resource path
  local_var_path = '/api/messaging/projects/{projectId}/messaging/push'.sub('{' + 'projectId' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(push_notification_request)

  # return_type
  return_type = opts[:debug_return_type] || 'MessageSentResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerToken']

  new_options = opts.merge(
    :operation => :"MessagingApi.messaging_send_push",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MessagingApi#messaging_send_push\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#messaging_send_sms(project_id, sms_request, opts = {}) ⇒ MessageSentResponse

Send SMS to one or more recipients (E.164 format) Send an SMS message to one or more phone numbers in E.164 format. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • sms_request (SMSRequest)

    Recipient phone number(s), message body, and optional sender ID.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



328
329
330
331
# File 'lib/mudbase/api/messaging_api.rb', line 328

def messaging_send_sms(project_id, sms_request, opts = {})
  data, _status_code, _headers = messaging_send_sms_with_http_info(project_id, sms_request, opts)
  data
end

#messaging_send_sms_with_http_info(project_id, sms_request, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send SMS to one or more recipients (E.164 format) Send an SMS message to one or more phone numbers in E.164 format. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Parameters:

  • project_id (String)

    Project ID (MongoDB ObjectId) for the messaging project.

  • sms_request (SMSRequest)

    Recipient phone number(s), message body, and optional sender ID.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(MessageSentResponse, Integer, Hash)>)

    MessageSentResponse data, response status code and response headers



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
# File 'lib/mudbase/api/messaging_api.rb', line 339

def messaging_send_sms_with_http_info(project_id, sms_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.messaging_send_sms ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling MessagingApi.messaging_send_sms"
  end
  # verify the required parameter 'sms_request' is set
  if @api_client.config.client_side_validation && sms_request.nil?
    fail ArgumentError, "Missing the required parameter 'sms_request' when calling MessagingApi.messaging_send_sms"
  end
  # resource path
  local_var_path = '/api/messaging/projects/{projectId}/messaging/sms'.sub('{' + 'projectId' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(sms_request)

  # return_type
  return_type = opts[:debug_return_type] || 'MessageSentResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerToken']

  new_options = opts.merge(
    :operation => :"MessagingApi.messaging_send_sms",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MessagingApi#messaging_send_sms\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end