Class: KapsoClientRuby::Resources::Messages
- Inherits:
-
Object
- Object
- KapsoClientRuby::Resources::Messages
- Defined in:
- lib/kapso_client_ruby/resources/messages.rb
Instance Method Summary collapse
-
#initialize(client) ⇒ Messages
constructor
A new instance of Messages.
-
#list_by_conversation(phone_number_id:, conversation_id:, limit: nil, after: nil, before: nil, fields: nil) ⇒ Object
List Messages by Conversation (Kapso Proxy only).
-
#mark_read(phone_number_id:, message_id:) ⇒ Object
Mark Message as Read.
-
#query(phone_number_id:, direction: nil, status: nil, since: nil, until_time: nil, conversation_id: nil, limit: nil, after: nil, before: nil, fields: nil) ⇒ Object
Query Message History (Kapso Proxy only).
-
#send_audio(phone_number_id:, to:, audio:, voice: false, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Audio Messages.
-
#send_contacts(phone_number_id:, to:, contacts:, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Contact Messages.
-
#send_document(phone_number_id:, to:, document:, caption: nil, filename: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Document Messages.
-
#send_flow(phone_number_id:, to:, flow_id:, flow_cta:, flow_token:, screen: nil, flow_action: 'navigate', mode: 'published', flow_action_payload: nil, header: nil, body_text: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Send Flow Message.
-
#send_image(phone_number_id:, to:, image:, caption: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Image Messages.
-
#send_interactive_buttons(phone_number_id:, to:, body_text:, buttons:, header: nil, footer: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Interactive Button Messages.
-
#send_interactive_catalog_message(phone_number_id:, to:, body_text:, thumbnail_product_retailer_id:, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Send Interactive Catalog Message.
-
#send_interactive_cta_url(phone_number_id:, to:, body_text:, display_text:, url:, header: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Send Interactive CTA URL Message.
-
#send_interactive_list(phone_number_id:, to:, body_text:, button_text:, sections:, header: nil, footer: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Interactive List Messages.
-
#send_interactive_location_request(phone_number_id:, to:, body_text:, header: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Send Interactive Location Request.
-
#send_location(phone_number_id:, to:, latitude:, longitude:, name: nil, address: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Location Messages.
-
#send_reaction(phone_number_id:, to:, message_id:, emoji: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Reaction Messages.
-
#send_sticker(phone_number_id:, to:, sticker:, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Sticker Messages.
-
#send_template(phone_number_id:, to:, name:, language:, components: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Template Messages.
-
#send_text(phone_number_id:, to:, body:, preview_url: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Text Messages.
-
#send_typing_indicator(phone_number_id:, to:) ⇒ Object
Send Typing Indicator.
-
#send_video(phone_number_id:, to:, video:, caption: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Video Messages.
Constructor Details
#initialize(client) ⇒ Messages
Returns a new instance of Messages.
6 7 8 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#list_by_conversation(phone_number_id:, conversation_id:, limit: nil, after: nil, before: nil, fields: nil) ⇒ Object
List Messages by Conversation (Kapso Proxy only)
586 587 588 589 590 591 592 593 594 595 596 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 586 def list_by_conversation(phone_number_id:, conversation_id:, limit: nil, after: nil, before: nil, fields: nil) query( phone_number_id: phone_number_id, conversation_id: conversation_id, limit: limit, after: after, before: before, fields: fields ) end |
#mark_read(phone_number_id:, message_id:) ⇒ Object
Mark Message as Read
535 536 537 538 539 540 541 542 543 544 545 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 535 def mark_read(phone_number_id:, message_id:) payload = { messaging_product: 'whatsapp', status: 'read', message_id: } response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::GraphSuccessResponse.new(response) end |
#query(phone_number_id:, direction: nil, status: nil, since: nil, until_time: nil, conversation_id: nil, limit: nil, after: nil, before: nil, fields: nil) ⇒ Object
Query Message History (Kapso Proxy only)
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 563 def query(phone_number_id:, direction: nil, status: nil, since: nil, until_time: nil, conversation_id: nil, limit: nil, after: nil, before: nil, fields: nil) assert_kapso_proxy('Message history API') query_params = { phone_number_id: phone_number_id, direction: direction, status: status, since: since, until: until_time, conversation_id: conversation_id, limit: limit, after: after, before: before, fields: fields }.compact response = @client.request(:get, "#{phone_number_id}/messages", query: query_params, response_type: :json) Types::PagedResponse.new(response) end |
#send_audio(phone_number_id:, to:, audio:, voice: false, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Audio Messages
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 57 def send_audio(phone_number_id:, to:, audio:, voice: false, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'audio', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) audio_obj = build_media_object(audio) # Add voice flag for voice notes (OGG/OPUS format recommended) if voice audio_obj[:voice] = true end payload[:audio] = audio_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_contacts(phone_number_id:, to:, contacts:, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Contact Messages
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 165 def send_contacts(phone_number_id:, to:, contacts:, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'contacts', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) payload[:contacts] = contacts response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_document(phone_number_id:, to:, document:, caption: nil, filename: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Document Messages
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 82 def send_document(phone_number_id:, to:, document:, caption: nil, filename: nil, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'document', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) document_obj = build_media_object(document, caption) document_obj[:filename] = filename if filename payload[:document] = document_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_flow(phone_number_id:, to:, flow_id:, flow_cta:, flow_token:, screen: nil, flow_action: 'navigate', mode: 'published', flow_action_payload: nil, header: nil, body_text: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Send Flow Message
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 351 def send_flow(phone_number_id:, to:, flow_id:, flow_cta:, flow_token:, screen: nil, flow_action: 'navigate', mode: 'published', flow_action_payload: nil, header: nil, body_text: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'interactive', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) # Build Flow action parameters action_params = { flow_message_version: '3', flow_token: flow_token, flow_id: flow_id, flow_cta: flow_cta, flow_action: flow_action, mode: mode } # Add optional parameters action_params[:flow_action_payload] = flow_action_payload if flow_action_payload # Add screen parameter for navigate action if flow_action == 'navigate' && screen action_params[:flow_action_payload] ||= {} action_params[:flow_action_payload][:screen] = screen end interactive_obj = { type: 'flow', action: action_params } # Add optional header and body interactive_obj[:header] = header if header interactive_obj[:body] = { text: body_text } if body_text interactive_obj[:footer] = { text: } if payload[:interactive] = interactive_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_image(phone_number_id:, to:, image:, caption: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Image Messages
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 33 def send_image(phone_number_id:, to:, image:, caption: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'image', recipient_type: recipient_type, context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) image_obj = build_media_object(image, caption) payload[:image] = image_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_interactive_buttons(phone_number_id:, to:, body_text:, buttons:, header: nil, footer: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Interactive Button Messages
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 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 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 234 def (phone_number_id:, to:, body_text:, buttons:, header: nil, footer: nil, context_message_id: nil, biz_opaque_callback_data: nil) # Validate button count (max 3 buttons) if .length > 3 raise ArgumentError, "Maximum 3 buttons allowed (current: #{buttons.length})" end if .empty? raise ArgumentError, 'At least 1 button is required' end # Validate header if provided (now supports text, image, video, document) if header validate_interactive_header(header, 'button') end payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'interactive', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) interactive_obj = { type: 'button', body: { text: body_text }, action: { buttons: } } # Add header (supports text and media types) interactive_obj[:header] = header if header # Add footer (handle both string and hash formats) if interactive_obj[:footer] = .is_a?(String) ? { text: } : end payload[:interactive] = interactive_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_interactive_catalog_message(phone_number_id:, to:, body_text:, thumbnail_product_retailer_id:, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Send Interactive Catalog Message
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 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 456 def (phone_number_id:, to:, body_text:, thumbnail_product_retailer_id:, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) # Validate parameters (body_text, thumbnail_product_retailer_id, ) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'interactive', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) interactive_obj = { type: 'catalog_message', body: { text: body_text }, action: { name: 'catalog_message', parameters: { thumbnail_product_retailer_id: thumbnail_product_retailer_id } } } # Add optional footer interactive_obj[:footer] = { text: } if payload[:interactive] = interactive_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_interactive_cta_url(phone_number_id:, to:, body_text:, display_text:, url:, header: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Send Interactive CTA URL Message
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 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 408 def send_interactive_cta_url(phone_number_id:, to:, body_text:, display_text:, url:, header: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) # Validate parameters validate_cta_url_params(body_text, display_text, url, ) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'interactive', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) interactive_obj = { type: 'cta_url', body: { text: body_text }, action: { name: 'cta_url', parameters: { display_text: display_text, url: url } } } # Add optional header (supports text, image, video, document) if header validate_interactive_header(header, 'cta_url') interactive_obj[:header] = header end # Add optional footer interactive_obj[:footer] = { text: } if payload[:interactive] = interactive_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_interactive_list(phone_number_id:, to:, body_text:, button_text:, sections:, header: nil, footer: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Interactive List Messages
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 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 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 288 def send_interactive_list(phone_number_id:, to:, body_text:, button_text:, sections:, header: nil, footer: nil, context_message_id: nil, biz_opaque_callback_data: nil) # Validate body text length (updated to 4096) if body_text.length > 4096 raise ArgumentError, "Body text max 4096 characters (current: #{body_text.length})" end # Validate total row count (max 10 across all sections) total_rows = sections.sum do |section| rows = section[:rows] || section['rows'] || [] rows.length end if total_rows > 10 raise ArgumentError, "Maximum 10 rows total across all sections (current: #{total_rows})" end if total_rows == 0 raise ArgumentError, 'At least 1 row is required' end # Header for lists must be text type only if header header_type = header[:type] || header['type'] unless header_type.nil? || header_type.to_s == 'text' raise ArgumentError, "List messages only support text headers (received: #{header_type})" end validate_text_header(header) if header_type end payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'interactive', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) interactive_obj = { type: 'list', body: { text: body_text }, action: { button: , sections: sections } } interactive_obj[:header] = header if header # Add footer (handle both string and hash formats) if interactive_obj[:footer] = .is_a?(String) ? { text: } : end payload[:interactive] = interactive_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_interactive_location_request(phone_number_id:, to:, body_text:, header: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Send Interactive Location Request
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 498 def send_interactive_location_request(phone_number_id:, to:, body_text:, header: nil, footer_text: nil, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'interactive', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) interactive_obj = { type: 'location_request_message', body: { text: body_text }, action: { name: 'send_location' } } # Add optional header (supports text, image, video, document) if header validate_interactive_header(header, 'location_request') interactive_obj[:header] = header end # Add optional footer interactive_obj[:footer] = { text: } if payload[:interactive] = interactive_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_location(phone_number_id:, to:, latitude:, longitude:, name: nil, address: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Location Messages
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 140 def send_location(phone_number_id:, to:, latitude:, longitude:, name: nil, address: nil, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'location', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) location_obj = { latitude: latitude, longitude: longitude } location_obj[:name] = name if name location_obj[:address] = address if address payload[:location] = location_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_reaction(phone_number_id:, to:, message_id:, emoji: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Reaction Messages
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 207 def send_reaction(phone_number_id:, to:, message_id:, emoji: nil, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'reaction', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) reaction_obj = { message_id: } reaction_obj[:emoji] = emoji if emoji # nil emoji removes reaction payload[:reaction] = reaction_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_sticker(phone_number_id:, to:, sticker:, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Sticker Messages
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 122 def send_sticker(phone_number_id:, to:, sticker:, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'sticker', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) payload[:sticker] = build_media_object(sticker) response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_template(phone_number_id:, to:, name:, language:, components: nil, context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Template Messages
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 183 def send_template(phone_number_id:, to:, name:, language:, components: nil, context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'template', context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) template_obj = { name: name, language: { code: language } } template_obj[:components] = components if components payload[:template] = template_obj response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_text(phone_number_id:, to:, body:, preview_url: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Text Messages
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 12 def send_text(phone_number_id:, to:, body:, preview_url: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'text', recipient_type: recipient_type, context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) payload[:text] = { body: body } payload[:text][:preview_url] = preview_url unless preview_url.nil? response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |
#send_typing_indicator(phone_number_id:, to:) ⇒ Object
Send Typing Indicator
548 549 550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 548 def send_typing_indicator(phone_number_id:, to:) payload = { messaging_product: 'whatsapp', recipient_type: 'individual', to: to, type: 'text', text: { typing_indicator: { type: 'text' } } } response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::GraphSuccessResponse.new(response) end |
#send_video(phone_number_id:, to:, video:, caption: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) ⇒ Object
Video Messages
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/kapso_client_ruby/resources/messages.rb', line 103 def send_video(phone_number_id:, to:, video:, caption: nil, recipient_type: 'individual', context_message_id: nil, biz_opaque_callback_data: nil) payload = build_base_payload( phone_number_id: phone_number_id, to: to, type: 'video', recipient_type: recipient_type, context_message_id: , biz_opaque_callback_data: biz_opaque_callback_data ) payload[:video] = build_media_object(video, caption) response = @client.request(:post, "#{phone_number_id}/messages", body: payload.to_json, response_type: :json) Types::SendMessageResponse.new(response) end |