Class: OneMsgSdk::MessagingApi

Inherits:
Object
  • Object
show all
Defined in:
lib/one_msg_sdk/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/one_msg_sdk/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/one_msg_sdk/api/messaging_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_read_message(token, opts = {}) ⇒ CreateReadMessage200Response

Mark message as read

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

  • :message_id (String)
  • :msg_id (String)
  • :typing_indicator (Boolean)

    Show WhatsApp typing indicator (max 25s or until reply) (default to false)

Returns:



29
30
31
32
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 29

def create_read_message(token, opts = {})
  data, _status_code, _headers = create_read_message_with_http_info(token, opts)
  data
end

#create_read_message_with_http_info(token, opts = {}) ⇒ Array<(CreateReadMessage200Response, Integer, Hash)>

Mark message as read

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

  • :message_id (String)
  • :msg_id (String)
  • :typing_indicator (Boolean)

    Show WhatsApp typing indicator (max 25s or until reply) (default to false)

Returns:



41
42
43
44
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
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 41

def create_read_message_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.create_read_message ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.create_read_message"
  end
  # resource path
  local_var_path = '/readMessage'

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

  # 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/x-www-form-urlencoded', 'application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['messageId'] = opts[:'message_id'] if !opts[:'message_id'].nil?
  form_params['msgId'] = opts[:'msg_id'] if !opts[:'msg_id'].nil?
  form_params['typingIndicator'] = opts[:'typing_indicator'] if !opts[:'typing_indicator'].nil?

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

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.create_read_message",
    :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#create_read_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_upload_media(token, opts = {}) ⇒ nil

Upload media

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

  • :request_body (Hash<String, Object>)

Returns:

  • (nil)


103
104
105
106
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 103

def create_upload_media(token, opts = {})
  create_upload_media_with_http_info(token, opts)
  nil
end

#create_upload_media_with_http_info(token, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Upload media

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

  • :request_body (Hash<String, Object>)

Returns:

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

    nil, response status code and response headers



113
114
115
116
117
118
119
120
121
122
123
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
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 113

def create_upload_media_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.create_upload_media ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.create_upload_media"
  end
  # resource path
  local_var_path = '/uploadMedia'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # 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(opts[:'request_body'])

  # return_type
  return_type = opts[:debug_return_type]

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

  new_options = opts.merge(
    :operation => :"MessagingApi.create_upload_media",
    :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#create_upload_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_media(token, media_id, opts = {}) ⇒ SuccessResponse

Delete media from WABA storage Delete previously uploaded media by numeric mediaId (from /uploadMedia). This is the canonical deletion endpoint and uses the REST DELETE verb on the media resource path. The older POST /deleteMedia is a deprecated alias.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • media_id (String)

    Numeric WABA media id

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

    the optional parameters

Returns:



171
172
173
174
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 171

def delete_media(token, media_id, opts = {})
  data, _status_code, _headers = delete_media_with_http_info(token, media_id, opts)
  data
end

#delete_media_legacy(token, delete_media_legacy_request, opts = {}) ⇒ SuccessResponse

Delete media from WABA storage (deprecated alias) Deprecated. Use DELETE /media/{mediaId} instead. This POST alias is kept for backward compatibility with earlier integrations. New integrations should call DELETE /media/{mediaId}: 1msg follows REST conventions for resource deletion going forward (delete a resource with the DELETE verb on its resource path).

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



241
242
243
244
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 241

def delete_media_legacy(token, delete_media_legacy_request, opts = {})
  data, _status_code, _headers = delete_media_legacy_with_http_info(token, delete_media_legacy_request, opts)
  data
end

#delete_media_legacy_with_http_info(token, delete_media_legacy_request, opts = {}) ⇒ Array<(SuccessResponse, Integer, Hash)>

Delete media from WABA storage (deprecated alias) Deprecated. Use `DELETE /media/mediaId` instead. This POST alias is kept for backward compatibility with earlier integrations. New integrations should call `DELETE /media/mediaId`: 1msg follows REST conventions for resource deletion going forward (delete a resource with the `DELETE` verb on its resource path).

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    SuccessResponse data, response status code and response headers



252
253
254
255
256
257
258
259
260
261
262
263
264
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
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 252

def delete_media_legacy_with_http_info(token, delete_media_legacy_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.delete_media_legacy ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.delete_media_legacy"
  end
  # verify the required parameter 'delete_media_legacy_request' is set
  if @api_client.config.client_side_validation && delete_media_legacy_request.nil?
    fail ArgumentError, "Missing the required parameter 'delete_media_legacy_request' when calling MessagingApi.delete_media_legacy"
  end
  # resource path
  local_var_path = '/deleteMedia'

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

  # 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(delete_media_legacy_request)

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.delete_media_legacy",
    :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#delete_media_legacy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_media_with_http_info(token, media_id, opts = {}) ⇒ Array<(SuccessResponse, Integer, Hash)>

Delete media from WABA storage Delete previously uploaded media by numeric `mediaId` (from `/uploadMedia`). This is the canonical deletion endpoint and uses the REST `DELETE` verb on the media resource path. The older `POST /deleteMedia` is a deprecated alias.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • media_id (String)

    Numeric WABA media id

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

    the optional parameters

Returns:

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

    SuccessResponse data, response status code and response headers



182
183
184
185
186
187
188
189
190
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
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 182

def delete_media_with_http_info(token, media_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.delete_media ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.delete_media"
  end
  # verify the required parameter 'media_id' is set
  if @api_client.config.client_side_validation && media_id.nil?
    fail ArgumentError, "Missing the required parameter 'media_id' when calling MessagingApi.delete_media"
  end
  # resource path
  local_var_path = '/media/{mediaId}'.sub('{mediaId}', CGI.escape(media_id.to_s))

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

  # 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] || 'SuccessResponse'

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

  new_options = opts.merge(
    :operation => :"MessagingApi.delete_media",
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MessagingApi#delete_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_mm_lite_status(token, opts = {}) ⇒ GetMmLiteStatus200Response

Get MM Lite availability and status

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



314
315
316
317
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 314

def get_mm_lite_status(token, opts = {})
  data, _status_code, _headers = get_mm_lite_status_with_http_info(token, opts)
  data
end

#get_mm_lite_status_with_http_info(token, opts = {}) ⇒ Array<(GetMmLiteStatus200Response, Integer, Hash)>

Get MM Lite availability and status

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    GetMmLiteStatus200Response data, response status code and response headers



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

def get_mm_lite_status_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.get_mm_lite_status ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.get_mm_lite_status"
  end
  # resource path
  local_var_path = '/mmLiteStatus'

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

  # 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] || 'GetMmLiteStatus200Response'

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

  new_options = opts.merge(
    :operation => :"MessagingApi.get_mm_lite_status",
    :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#get_mm_lite_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_messages(token, opts = {}) ⇒ ListMessages200Response

Get messages list

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



376
377
378
379
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 376

def list_messages(token, opts = {})
  data, _status_code, _headers = list_messages_with_http_info(token, opts)
  data
end

#list_messages_with_http_info(token, opts = {}) ⇒ Array<(ListMessages200Response, Integer, Hash)>

Get messages list

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    ListMessages200Response data, response status code and response headers



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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 385

def list_messages_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.list_messages ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.list_messages"
  end
  # resource path
  local_var_path = '/messages'

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

  # 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] || 'ListMessages200Response'

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

  new_options = opts.merge(
    :operation => :"MessagingApi.list_messages",
    :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#list_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#retrieve_media(token, media_id, opts = {}) ⇒ RetrieveMedia200Response

Retrieve uploaded media metadata Get WABA media URL and metadata by mediaId (from uploadMedia). The returned url is temporary and typically expires within ~5 minutes.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



440
441
442
443
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 440

def retrieve_media(token, media_id, opts = {})
  data, _status_code, _headers = retrieve_media_with_http_info(token, media_id, opts)
  data
end

#retrieve_media_with_http_info(token, media_id, opts = {}) ⇒ Array<(RetrieveMedia200Response, Integer, Hash)>

Retrieve uploaded media metadata Get WABA media URL and metadata by mediaId (from uploadMedia). The returned `url` is temporary and typically expires within ~5 minutes.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    RetrieveMedia200Response data, response status code and response headers



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

def retrieve_media_with_http_info(token, media_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.retrieve_media ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.retrieve_media"
  end
  # verify the required parameter 'media_id' is set
  if @api_client.config.client_side_validation && media_id.nil?
    fail ArgumentError, "Missing the required parameter 'media_id' when calling MessagingApi.retrieve_media"
  end
  # resource path
  local_var_path = '/retrieveMedia'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'token'] = token
  query_params[:'mediaId'] = media_id

  # 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] || 'RetrieveMedia200Response'

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

  new_options = opts.merge(
    :operation => :"MessagingApi.retrieve_media",
    :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#retrieve_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_address_message(token, send_address_message_request, opts = {}) ⇒ MessageSentResponse

Send address request message Request shipping address from the user (WhatsApp interactive address_message). India and Singapore only. Requires: - Business WhatsApp number registered in that country - Recipient phone matching the country (+91 ↔ IN, +65 ↔ SG) Pass country: \"IN\" or country: \"SG\". Eligibility is validated upstream; mismatches (e.g. Singapore phone with country: \"IN\") return errors such as Unsupported Interactive Message type (HTTP 200 with sent: false). Optional action parameters: values, saved_addresses, validation_errors.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



511
512
513
514
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 511

def send_address_message(token, send_address_message_request, opts = {})
  data, _status_code, _headers = send_address_message_with_http_info(token, send_address_message_request, opts)
  data
end

#send_address_message_with_http_info(token, send_address_message_request, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send address request message Request shipping address from the user (WhatsApp interactive `address_message`). India and Singapore only. Requires: - Business WhatsApp number registered in that country - Recipient phone matching the country (`+91` ↔ `IN`, `+65` ↔ `SG`) Pass `country: &quot;IN&quot;` or `country: &quot;SG&quot;`. Eligibility is validated upstream; mismatches (e.g. Singapore phone with `country: &quot;IN&quot;`) return errors such as `Unsupported Interactive Message type` (HTTP 200 with `sent: false`). Optional action parameters: `values`, `saved_addresses`, `validation_errors`.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    MessageSentResponse data, response status code and response headers



522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 522

def send_address_message_with_http_info(token, send_address_message_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_address_message ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_address_message"
  end
  # verify the required parameter 'send_address_message_request' is set
  if @api_client.config.client_side_validation && send_address_message_request.nil?
    fail ArgumentError, "Missing the required parameter 'send_address_message_request' when calling MessagingApi.send_address_message"
  end
  # resource path
  local_var_path = '/sendAddressMessage'

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

  # 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(send_address_message_request)

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_address_message",
    :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#send_address_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_button(token, opts = {}) ⇒ MessageSentResponse

Send Reply Buttons Message

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:



585
586
587
588
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 585

def send_button(token, opts = {})
  data, _status_code, _headers = send_button_with_http_info(token, opts)
  data
end

#send_button_with_http_info(token, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send Reply Buttons Message

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:

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

    MessageSentResponse data, response status code and response headers



595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 595

def send_button_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_button ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_button"
  end
  # resource path
  local_var_path = '/sendButton'

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

  # 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(opts[:'send_button_request'])

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_button",
    :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#send_button\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

Send Carousel You can send product cards via Carousel in two ways: Template messages: do not require a 24-hour customer service window between you and the recipient. Use sendTemplate. Free-form messages: can be sent only when a customer service window is open between you and the recipient. Use sendCarousel. The message structure in /sendCarousel is largely similar to sending a template. However, in this case you must explicitly specify all elements that are created in advance when working with templates. This is because the message is sent without using a template. In /sendCarousel, for sending a Catalog Carousel there can be either 1 URL button or one or more quick reply buttons.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • params (Array<Object>)

    Required. Template-like structure (same as sendTemplate params). Must include a CAROUSEL component and its cards. Structure: - params item with type CAROUSEL and cards (2..10) - cards item: - components items: - header: parameters with type image/video/product - image: {\\\"link\\\": \\\"https://...\\\"} - video: {\\\"link\\\": \\\"https://...\\\"} - product: {\\\"catalog_id\\\": \\\"...\\\", \\\"product_retailer_id\\\": \\\"...\\\"} - button: sub_type url or quick_reply - url: parameters \\\"Button\\\", \\\"url\\\": \\\"https://...\\\" - quick_reply: parameters of \\\"...\\\", \\\"text\\\": \\\"...\\\"

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

    the optional parameters

Options Hash (opts):

  • :body (String)

    Text shown above the carousel. Optional. If omitted and params include a body component, the body will be taken from params.

  • :quoted_msg_id (String)

    Quoted message ID (Cloud API)

  • :chat_id (String)

    Required if phone is not set. Chat ID from the message list. Examples: 12020721369@c.us or 120363046942338209@g.us(group)

  • :phone (Integer)

    Required if chatId is not set. A phone number starting with the country code. USA example: 12020721369.

Returns:



659
660
661
662
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 659

def send_carousel(token, params, opts = {})
  data, _status_code, _headers = send_carousel_with_http_info(token, params, opts)
  data
end

Send Carousel You can send product cards via Carousel in two ways: Template messages: do not require a 24-hour customer service window between you and the recipient. Use sendTemplate. Free-form messages: can be sent only when a customer service window is open between you and the recipient. Use sendCarousel. The message structure in /sendCarousel is largely similar to sending a template. However, in this case you must explicitly specify all elements that are created in advance when working with templates. This is because the message is sent without using a template. In /sendCarousel, for sending a Catalog Carousel there can be either 1 URL button or one or more quick reply buttons.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • params (Array<Object>)

    Required. Template-like structure (same as sendTemplate params). Must include a CAROUSEL component and its cards. Structure: - params item with type CAROUSEL and cards (2..10) - cards item: - components items: - header: parameters with type image/video/product - image: {\\\"link\\\": \\\"https://...\\\"} - video: {\\\"link\\\": \\\"https://...\\\"} - product: {\\\"catalog_id\\\": \\\"...\\\", \\\"product_retailer_id\\\": \\\"...\\\"} - button: sub_type url or quick_reply - url: parameters \\\"Button\\\", \\\"url\\\": \\\"https://...\\\" - quick_reply: parameters of \\\"...\\\", \\\"text\\\": \\\"...\\\"

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

    the optional parameters

Options Hash (opts):

  • :body (String)

    Text shown above the carousel. Optional. If omitted and params include a body component, the body will be taken from params.

  • :quoted_msg_id (String)

    Quoted message ID (Cloud API)

  • :chat_id (String)

    Required if phone is not set. Chat ID from the message list. Examples: 12020721369@c.us or 120363046942338209@g.us(group)

  • :phone (Integer)

    Required if chatId is not set. A phone number starting with the country code. USA example: 12020721369.

Returns:

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

    MessageSentResponse data, response status code and response headers



674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 674

def send_carousel_with_http_info(token, params, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_carousel ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_carousel"
  end
  # verify the required parameter 'params' is set
  if @api_client.config.client_side_validation && params.nil?
    fail ArgumentError, "Missing the required parameter 'params' when calling MessagingApi.send_carousel"
  end
  # resource path
  local_var_path = '/sendCarousel'

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

  # 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/x-www-form-urlencoded', 'application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['params'] = @api_client.build_collection_param(params, :csv)
  form_params['body'] = opts[:'body'] if !opts[:'body'].nil?
  form_params['quotedMsgId'] = opts[:'quoted_msg_id'] if !opts[:'quoted_msg_id'].nil?
  form_params['chatId'] = opts[:'chat_id'] if !opts[:'chat_id'].nil?
  form_params['phone'] = opts[:'phone'] if !opts[:'phone'].nil?

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

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_carousel",
    :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#send_carousel\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_contact(token, opts = {}) ⇒ MessageSentResponse

Send a Contact

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:



742
743
744
745
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 742

def send_contact(token, opts = {})
  data, _status_code, _headers = send_contact_with_http_info(token, opts)
  data
end

#send_contact_with_http_info(token, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send a Contact

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:

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

    MessageSentResponse data, response status code and response headers



752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 752

def send_contact_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_contact ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_contact"
  end
  # resource path
  local_var_path = '/sendContact'

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

  # 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(opts[:'send_contact_request'])

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_contact",
    :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#send_contact\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_cta_url(token, send_cta_url_request, opts = {}) ⇒ MessageSentResponse

Send CTA URL interactive message Send an interactive message with a single call-to-action URL button.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



812
813
814
815
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 812

def send_cta_url(token, send_cta_url_request, opts = {})
  data, _status_code, _headers = send_cta_url_with_http_info(token, send_cta_url_request, opts)
  data
end

#send_cta_url_with_http_info(token, send_cta_url_request, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send CTA URL interactive message Send an interactive message with a single call-to-action URL button.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    MessageSentResponse data, response status code and response headers



823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 823

def send_cta_url_with_http_info(token, send_cta_url_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_cta_url ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_cta_url"
  end
  # verify the required parameter 'send_cta_url_request' is set
  if @api_client.config.client_side_validation && send_cta_url_request.nil?
    fail ArgumentError, "Missing the required parameter 'send_cta_url_request' when calling MessagingApi.send_cta_url"
  end
  # resource path
  local_var_path = '/sendCtaUrl'

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

  # 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(send_cta_url_request)

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_cta_url",
    :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#send_cta_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_file(token, opts = {}) ⇒ MessageSentResponse

Send a File Send a file to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

  • :body (String)

    File source (required unless mediaId is set): - HTTP/HTTPS URL - Base64 data URI

  • :filename (String)

    File name with extension (required with body, not with mediaId)

  • :media_id (String)

    WABA media id from uploadMedia (alternative to body)

  • :media_type (String)

    Required when using mediaId

  • :voice (Boolean)

    Native WhatsApp voice note (audio/ogg only)

  • :caption (String)
  • :quoted_msg_id (String)
  • :chat_id (String)
  • :phone (Integer)

Returns:



895
896
897
898
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 895

def send_file(token, opts = {})
  data, _status_code, _headers = send_file_with_http_info(token, opts)
  data
end

#send_file_with_http_info(token, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send a File Send a file to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

  • :body (String)

    File source (required unless mediaId is set): - HTTP/HTTPS URL - Base64 data URI

  • :filename (String)

    File name with extension (required with body, not with mediaId)

  • :media_id (String)

    WABA media id from uploadMedia (alternative to body)

  • :media_type (String)

    Required when using mediaId

  • :voice (Boolean)

    Native WhatsApp voice note (audio/ogg only)

  • :caption (String)
  • :quoted_msg_id (String)
  • :chat_id (String)
  • :phone (Integer)

Returns:

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

    MessageSentResponse data, response status code and response headers



914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 914

def send_file_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_file ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_file"
  end
  allowable_values = ["image", "video", "audio", "document"]
  if @api_client.config.client_side_validation && opts[:'media_type'] && !allowable_values.include?(opts[:'media_type'])
    fail ArgumentError, "invalid value for \"media_type\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'caption'].nil? && opts[:'caption'].to_s.length > 1024
    fail ArgumentError, 'invalid value for "opts[:"caption"]" when calling MessagingApi.send_file, the character length must be smaller than or equal to 1024.'
  end

  # resource path
  local_var_path = '/sendFile'

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

  # 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/x-www-form-urlencoded', 'application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['body'] = opts[:'body'] if !opts[:'body'].nil?
  form_params['filename'] = opts[:'filename'] if !opts[:'filename'].nil?
  form_params['mediaId'] = opts[:'media_id'] if !opts[:'media_id'].nil?
  form_params['mediaType'] = opts[:'media_type'] if !opts[:'media_type'].nil?
  form_params['voice'] = opts[:'voice'] if !opts[:'voice'].nil?
  form_params['caption'] = opts[:'caption'] if !opts[:'caption'].nil?
  form_params['quotedMsgId'] = opts[:'quoted_msg_id'] if !opts[:'quoted_msg_id'].nil?
  form_params['chatId'] = opts[:'chat_id'] if !opts[:'chat_id'].nil?
  form_params['phone'] = opts[:'phone'] if !opts[:'phone'].nil?

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

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_file",
    :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#send_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_flow(token, body, flow_id, flow_token, flow_cta, opts = {}) ⇒ MessageSentResponse

Send WhatsApp Flow Message Send Interactive WhatsApp Flow message to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone. Use this method to send a published WhatsApp Flow as a service (interactive) message. If the 24-hour window is closed, send a template with a FLOW button via /sendTemplate.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • body (String)

    Flow message body text

  • flow_id (String)

    Published Flow ID

  • flow_token (String)

    Flow token generated by the business

  • flow_cta (String)

    CTA button text

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

    the optional parameters

Options Hash (opts):

  • :header (SendFlowRequestHeader)
  • :footer (String)

    Footer text

  • :flow_action (String)

    Flow action type

  • :flow_action_payload (Object)

    Required for flowAction=navigate (screen is required). Ignored for data_exchange. If data is provided, it must be a non-empty object.

  • :flow_message_version (String)

    Flow message version (default \&quot;3\&quot;)

  • :mode (String)

    Flow mode (draft or published). If omitted, provider default applies

  • :flow_action_data (Object)

    Shortcut for flowActionPayload.data (optional)

  • :flow_action_screen (String)

    Shortcut for flowActionPayload.screen (optional)

  • :quoted_msg_id (String)

    Quoted message ID (Cloud API)

  • :chat_id (String)

    Required if phone is not set. Chat ID from the message list. Examples: 12020721369@c.us or 120363046942338209@g.us(group)

  • :phone (Integer)

    Required if chatId is not set. A phone number starting with the country code. USA example: 12020721369.

Returns:



1005
1006
1007
1008
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1005

def send_flow(token, body, flow_id, flow_token, flow_cta, opts = {})
  data, _status_code, _headers = send_flow_with_http_info(token, body, flow_id, flow_token, flow_cta, opts)
  data
end

#send_flow_with_http_info(token, body, flow_id, flow_token, flow_cta, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send WhatsApp Flow Message Send Interactive WhatsApp Flow message to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone. Use this method to send a published WhatsApp Flow as a service (interactive) message. If the 24-hour window is closed, send a template with a FLOW button via /sendTemplate.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • body (String)

    Flow message body text

  • flow_id (String)

    Published Flow ID

  • flow_token (String)

    Flow token generated by the business

  • flow_cta (String)

    CTA button text

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

    the optional parameters

Options Hash (opts):

  • :header (SendFlowRequestHeader)
  • :footer (String)

    Footer text

  • :flow_action (String)

    Flow action type

  • :flow_action_payload (Object)

    Required for flowAction=navigate (screen is required). Ignored for data_exchange. If data is provided, it must be a non-empty object.

  • :flow_message_version (String)

    Flow message version (default \&quot;3\&quot;)

  • :mode (String)

    Flow mode (draft or published). If omitted, provider default applies

  • :flow_action_data (Object)

    Shortcut for flowActionPayload.data (optional)

  • :flow_action_screen (String)

    Shortcut for flowActionPayload.screen (optional)

  • :quoted_msg_id (String)

    Quoted message ID (Cloud API)

  • :chat_id (String)

    Required if phone is not set. Chat ID from the message list. Examples: 12020721369@c.us or 120363046942338209@g.us(group)

  • :phone (Integer)

    Required if chatId is not set. A phone number starting with the country code. USA example: 12020721369.

Returns:

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

    MessageSentResponse data, response status code and response headers



1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1030

def send_flow_with_http_info(token, body, flow_id, flow_token, flow_cta, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_flow ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_flow"
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling MessagingApi.send_flow"
  end
  # verify the required parameter 'flow_id' is set
  if @api_client.config.client_side_validation && flow_id.nil?
    fail ArgumentError, "Missing the required parameter 'flow_id' when calling MessagingApi.send_flow"
  end
  # verify the required parameter 'flow_token' is set
  if @api_client.config.client_side_validation && flow_token.nil?
    fail ArgumentError, "Missing the required parameter 'flow_token' when calling MessagingApi.send_flow"
  end
  # verify the required parameter 'flow_cta' is set
  if @api_client.config.client_side_validation && flow_cta.nil?
    fail ArgumentError, "Missing the required parameter 'flow_cta' when calling MessagingApi.send_flow"
  end
  allowable_values = ["navigate", "data_exchange"]
  if @api_client.config.client_side_validation && opts[:'flow_action'] && !allowable_values.include?(opts[:'flow_action'])
    fail ArgumentError, "invalid value for \"flow_action\", must be one of #{allowable_values}"
  end
  allowable_values = ["draft", "published"]
  if @api_client.config.client_side_validation && opts[:'mode'] && !allowable_values.include?(opts[:'mode'])
    fail ArgumentError, "invalid value for \"mode\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/sendFlow'

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

  # 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/x-www-form-urlencoded', 'application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['body'] = body
  form_params['flowId'] = flow_id
  form_params['flowToken'] = flow_token
  form_params['flowCta'] = flow_cta
  form_params['header'] = opts[:'header'] if !opts[:'header'].nil?
  form_params['footer'] = opts[:'footer'] if !opts[:'footer'].nil?
  form_params['flowAction'] = opts[:'flow_action'] if !opts[:'flow_action'].nil?
  form_params['flowActionPayload'] = opts[:'flow_action_payload'] if !opts[:'flow_action_payload'].nil?
  form_params['flowMessageVersion'] = opts[:'flow_message_version'] if !opts[:'flow_message_version'].nil?
  form_params['mode'] = opts[:'mode'] if !opts[:'mode'].nil?
  form_params['flowActionData'] = opts[:'flow_action_data'] if !opts[:'flow_action_data'].nil?
  form_params['flowActionScreen'] = opts[:'flow_action_screen'] if !opts[:'flow_action_screen'].nil?
  form_params['quotedMsgId'] = opts[:'quoted_msg_id'] if !opts[:'quoted_msg_id'].nil?
  form_params['chatId'] = opts[:'chat_id'] if !opts[:'chat_id'].nil?
  form_params['phone'] = opts[:'phone'] if !opts[:'phone'].nil?

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

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_flow",
    :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#send_flow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_list(token, opts = {}) ⇒ MessageSentResponse

Send List Message

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:



1128
1129
1130
1131
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1128

def send_list(token, opts = {})
  data, _status_code, _headers = send_list_with_http_info(token, opts)
  data
end

#send_list_with_http_info(token, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send List Message

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:

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

    MessageSentResponse data, response status code and response headers



1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1138

def send_list_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_list ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_list"
  end
  # resource path
  local_var_path = '/sendList'

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

  # 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(opts[:'send_list_request'])

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_list",
    :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#send_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_location(token, lat, lng, opts = {}) ⇒ MessageSentResponse

Send a Location Send a location to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • lat (String)

    Latitude of the location. Example: 45.018337

  • lng (String)

    Longitude of the location. Example: -73.968285

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

    the optional parameters

Options Hash (opts):

  • :address (String)

    Address of the location. Only displayed if name is present. Example: 9766 Valley View St., New York, NY 10024

  • :name (String)

    Name of the location. Example: Facebook HQ

  • :quoted_msg_id (String)

    Quoted message ID (Cloud API)

  • :chat_id (String)

    Required if phone is not set. Chat ID from the message list. Examples: 12020721369@c.us or 120363046942338209@g.us(group)

  • :phone (Integer)

    Required if chatId is not set. A phone number starting with the country code. USA example: 12020721369.

Returns:



1204
1205
1206
1207
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1204

def send_location(token, lat, lng, opts = {})
  data, _status_code, _headers = send_location_with_http_info(token, lat, lng, opts)
  data
end

#send_location_request(token, opts = {}) ⇒ MessageSentResponse

Send Location Request Message

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:



1295
1296
1297
1298
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1295

def send_location_request(token, opts = {})
  data, _status_code, _headers = send_location_request_with_http_info(token, opts)
  data
end

#send_location_request_with_http_info(token, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send Location Request Message

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:

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

    MessageSentResponse data, response status code and response headers



1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1305

def send_location_request_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_location_request ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_location_request"
  end
  # resource path
  local_var_path = '/sendLocationRequest'

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

  # 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(opts[:'send_location_request_request'])

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_location_request",
    :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#send_location_request\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_location_with_http_info(token, lat, lng, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send a Location Send a location to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • lat (String)

    Latitude of the location. Example: 45.018337

  • lng (String)

    Longitude of the location. Example: -73.968285

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

    the optional parameters

Options Hash (opts):

  • :address (String)

    Address of the location. Only displayed if name is present. Example: 9766 Valley View St., New York, NY 10024

  • :name (String)

    Name of the location. Example: Facebook HQ

  • :quoted_msg_id (String)

    Quoted message ID (Cloud API)

  • :chat_id (String)

    Required if phone is not set. Chat ID from the message list. Examples: 12020721369@c.us or 120363046942338209@g.us(group)

  • :phone (Integer)

    Required if chatId is not set. A phone number starting with the country code. USA example: 12020721369.

Returns:

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

    MessageSentResponse data, response status code and response headers



1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1221

def send_location_with_http_info(token, lat, lng, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_location ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_location"
  end
  # verify the required parameter 'lat' is set
  if @api_client.config.client_side_validation && lat.nil?
    fail ArgumentError, "Missing the required parameter 'lat' when calling MessagingApi.send_location"
  end
  # verify the required parameter 'lng' is set
  if @api_client.config.client_side_validation && lng.nil?
    fail ArgumentError, "Missing the required parameter 'lng' when calling MessagingApi.send_location"
  end
  # resource path
  local_var_path = '/sendLocation'

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

  # 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/x-www-form-urlencoded', 'application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['lat'] = lat
  form_params['lng'] = lng
  form_params['address'] = opts[:'address'] if !opts[:'address'].nil?
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['quotedMsgId'] = opts[:'quoted_msg_id'] if !opts[:'quoted_msg_id'].nil?
  form_params['chatId'] = opts[:'chat_id'] if !opts[:'chat_id'].nil?
  form_params['phone'] = opts[:'phone'] if !opts[:'phone'].nil?

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

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_location",
    :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#send_location\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_message(token, body, opts = {}) ⇒ MessageSentResponse

Send a Message Send a message to an existing chat. (Only if the dialogue has an Open Session). The message will be added to the queue for sending and delivered even if the phone is disconnected from the Internet or authorization is not passed. Only one of two parameters is needed to determine the destination - chatId or phone.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • body (String)

    Message text, UTF-8 or UTF-16 string with emoji

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

    the optional parameters

Options Hash (opts):

  • :quoted_msg_id (String)

    Message ID to quote/reply to (Cloud API wamid)

  • :chat_id (String)

    Chat ID in format: phone@c.us (individual) or phone@g.us (group)

  • :phone (Integer)

    Phone number starting with country code (alternative to chatId)

Returns:



1368
1369
1370
1371
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1368

def send_message(token, body, opts = {})
  data, _status_code, _headers = send_message_with_http_info(token, body, opts)
  data
end

#send_message_with_http_info(token, body, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send a Message Send a message to an existing chat. (Only if the dialogue has an Open Session). The message will be added to the queue for sending and delivered even if the phone is disconnected from the Internet or authorization is not passed. Only one of two parameters is needed to determine the destination - chatId or phone.

Parameters:

  • token (String)

    JWT token or API key for authorization

  • body (String)

    Message text, UTF-8 or UTF-16 string with emoji

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

    the optional parameters

Options Hash (opts):

  • :quoted_msg_id (String)

    Message ID to quote/reply to (Cloud API wamid)

  • :chat_id (String)

    Chat ID in format: phone@c.us (individual) or phone@g.us (group)

  • :phone (Integer)

    Phone number starting with country code (alternative to chatId)

Returns:

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

    MessageSentResponse data, response status code and response headers



1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1382

def send_message_with_http_info(token, body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_message ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_message"
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling MessagingApi.send_message"
  end
  if @api_client.config.client_side_validation && body.to_s.length > 4096
    fail ArgumentError, 'invalid value for "body" when calling MessagingApi.send_message, the character length must be smaller than or equal to 4096.'
  end

  if @api_client.config.client_side_validation && body.to_s.length < 1
    fail ArgumentError, 'invalid value for "body" when calling MessagingApi.send_message, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^wamid\..+$/)
  if @api_client.config.client_side_validation && !opts[:'quoted_msg_id'].nil? && opts[:'quoted_msg_id'] !~ pattern
    fail ArgumentError, "invalid value for 'opts[:\"quoted_msg_id\"]' when calling MessagingApi.send_message, must conform to the pattern #{pattern}."
  end

  pattern = Regexp.new(/^[0-9]+@[cg]\.us$/)
  if @api_client.config.client_side_validation && !opts[:'chat_id'].nil? && opts[:'chat_id'] !~ pattern
    fail ArgumentError, "invalid value for 'opts[:\"chat_id\"]' when calling MessagingApi.send_message, must conform to the pattern #{pattern}."
  end

  if @api_client.config.client_side_validation && !opts[:'phone'].nil? && opts[:'phone'] > 999999999999999
    fail ArgumentError, 'invalid value for "opts[:"phone"]" when calling MessagingApi.send_message, must be smaller than or equal to 999999999999999.'
  end

  if @api_client.config.client_side_validation && !opts[:'phone'].nil? && opts[:'phone'] < 1000000000
    fail ArgumentError, 'invalid value for "opts[:"phone"]" when calling MessagingApi.send_message, must be greater than or equal to 1000000000.'
  end

  # resource path
  local_var_path = '/sendMessage'

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

  # 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/x-www-form-urlencoded', 'application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['body'] = body
  form_params['quotedMsgId'] = opts[:'quoted_msg_id'] if !opts[:'quoted_msg_id'].nil?
  form_params['chatId'] = opts[:'chat_id'] if !opts[:'chat_id'].nil?
  form_params['phone'] = opts[:'phone'] if !opts[:'phone'].nil?

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

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_message",
    :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#send_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_order_details(token, send_order_details_request, opts = {}) ⇒ MessageSentResponse

Send order details (India payments template) Send a WhatsApp order details payment / invoice message using a pre-approved Utility template that has an ORDER_DETAILS button. India only (WhatsApp Payments India). Requires: - India WhatsApp Business number - Commerce enabled on the channel (GET/POST /commerce) - Approved template with an ORDER_DETAILS button Use this method when you need structured fields (order, referenceId, currency, paymentSettings). The API appends a template button sub_type: order_details and sends via the same path as POST /sendTemplate. Works outside the 24-hour session window (template message). You can also send the same payload yourself with POST /sendTemplate by including a button component in params: json { \"type\": \"button\", \"sub_type\": \"order_details\", \"index\": 0, \"parameters\": [{ \"type\": \"action\", \"action\": { \"order_details\": { \"reference_id\": \"order-123\", \"currency\": \"INR\", \"order\": { \"status\": \"pending\", \"items\": [], \"subtotal\": { \"offset\": 100, \"value\": 50000 } } } } }] }

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



1476
1477
1478
1479
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1476

def send_order_details(token, send_order_details_request, opts = {})
  data, _status_code, _headers = send_order_details_with_http_info(token, send_order_details_request, opts)
  data
end

#send_order_details_with_http_info(token, send_order_details_request, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send order details (India payments template) Send a WhatsApp order details payment / invoice message using a pre-approved Utility template that has an `ORDER_DETAILS` button. India only (WhatsApp Payments India). Requires: - India WhatsApp Business number - Commerce enabled on the channel (`GET`/`POST /commerce`) - Approved template with an `ORDER_DETAILS` button Use this method when you need structured fields (`order`, `referenceId`, `currency`, `paymentSettings`). The API appends a template button `sub_type: order_details` and sends via the same path as `POST /sendTemplate`. Works outside the 24-hour session window (template message). You can also send the same payload yourself with `POST /sendTemplate` by including a button component in `params`: ```json { &quot;type&quot;: &quot;button&quot;, &quot;sub_type&quot;: &quot;order_details&quot;, &quot;index&quot;: 0, &quot;parameters&quot;: [{ &quot;type&quot;: &quot;action&quot;, &quot;action&quot;: { &quot;order_details&quot;: { &quot;reference_id&quot;: &quot;order-123&quot;, &quot;currency&quot;: &quot;INR&quot;, &quot;order&quot;: { &quot;status&quot;: &quot;pending&quot;, &quot;items&quot;: [], &quot;subtotal&quot;: { &quot;offset&quot;: 100, &quot;value&quot;: 50000 } } } } }] } ```

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    MessageSentResponse data, response status code and response headers



1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1487

def send_order_details_with_http_info(token, send_order_details_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_order_details ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_order_details"
  end
  # verify the required parameter 'send_order_details_request' is set
  if @api_client.config.client_side_validation && send_order_details_request.nil?
    fail ArgumentError, "Missing the required parameter 'send_order_details_request' when calling MessagingApi.send_order_details"
  end
  # resource path
  local_var_path = '/sendOrderDetails'

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

  # 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(send_order_details_request)

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_order_details",
    :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#send_order_details\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_payment_request(token, send_payment_request_request, opts = {}) ⇒ MessageSentResponse

Send payment request (regional) Send a regional payment request interactive message (beta scaffold). region must be IN, SG, or BR. Payload shape follows Meta regional payments docs; verify on stage before production use. Full regional builders are not implemented yet.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



1551
1552
1553
1554
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1551

def send_payment_request(token, send_payment_request_request, opts = {})
  data, _status_code, _headers = send_payment_request_with_http_info(token, send_payment_request_request, opts)
  data
end

#send_payment_request_with_http_info(token, send_payment_request_request, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send payment request (regional) Send a regional payment request interactive message (beta scaffold). `region` must be IN, SG, or BR. Payload shape follows Meta regional payments docs; verify on stage before production use. Full regional builders are not implemented yet.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    MessageSentResponse data, response status code and response headers



1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1562

def send_payment_request_with_http_info(token, send_payment_request_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_payment_request ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_payment_request"
  end
  # verify the required parameter 'send_payment_request_request' is set
  if @api_client.config.client_side_validation && send_payment_request_request.nil?
    fail ArgumentError, "Missing the required parameter 'send_payment_request_request' when calling MessagingApi.send_payment_request"
  end
  # resource path
  local_var_path = '/sendPaymentRequest'

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

  # 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(send_payment_request_request)

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_payment_request",
    :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#send_payment_request\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_product(token, opts = {}) ⇒ MessageSentResponse

Send a Product

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

  • :request_body (Hash<String, Object>)

Returns:



1625
1626
1627
1628
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1625

def send_product(token, opts = {})
  data, _status_code, _headers = send_product_with_http_info(token, opts)
  data
end

#send_product_with_http_info(token, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send a Product

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

  • :request_body (Hash<String, Object>)

Returns:

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

    MessageSentResponse data, response status code and response headers



1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1635

def send_product_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_product ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_product"
  end
  # resource path
  local_var_path = '/sendProduct'

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

  # 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(opts[:'request_body'])

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_product",
    :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#send_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_reaction(token, opts = {}) ⇒ MessageSentResponse

Send Reaction

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:



1694
1695
1696
1697
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1694

def send_reaction(token, opts = {})
  data, _status_code, _headers = send_reaction_with_http_info(token, opts)
  data
end

#send_reaction_with_http_info(token, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send Reaction

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Options Hash (opts):

Returns:

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

    MessageSentResponse data, response status code and response headers



1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1704

def send_reaction_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_reaction ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_reaction"
  end
  # resource path
  local_var_path = '/sendReaction'

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

  # 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(opts[:'send_reaction_request'])

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_reaction",
    :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#send_reaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_sticker(token, send_sticker_request, opts = {}) ⇒ MessageSentResponse

Send sticker message Send a WhatsApp sticker by mediaId or link URL.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:



1764
1765
1766
1767
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1764

def send_sticker(token, send_sticker_request, opts = {})
  data, _status_code, _headers = send_sticker_with_http_info(token, send_sticker_request, opts)
  data
end

#send_sticker_with_http_info(token, send_sticker_request, opts = {}) ⇒ Array<(MessageSentResponse, Integer, Hash)>

Send sticker message Send a WhatsApp sticker by mediaId or link URL.

Parameters:

  • token (String)

    JWT token or API key for authorization

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

    the optional parameters

Returns:

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

    MessageSentResponse data, response status code and response headers



1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
# File 'lib/one_msg_sdk/api/messaging_api.rb', line 1775

def send_sticker_with_http_info(token, send_sticker_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessagingApi.send_sticker ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling MessagingApi.send_sticker"
  end
  # verify the required parameter 'send_sticker_request' is set
  if @api_client.config.client_side_validation && send_sticker_request.nil?
    fail ArgumentError, "Missing the required parameter 'send_sticker_request' when calling MessagingApi.send_sticker"
  end
  # resource path
  local_var_path = '/sendSticker'

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

  # 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(send_sticker_request)

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

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

  new_options = opts.merge(
    :operation => :"MessagingApi.send_sticker",
    :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#send_sticker\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end