Class: Posthubify::WhatsAppResource
- Inherits:
-
Object
- Object
- Posthubify::WhatsAppResource
- Defined in:
- lib/posthubify/resources/messaging.rb
Overview
WhatsApp Business — message templates (D1). account_id = the connected WhatsApp account. Only status=APPROVED templates can be sent; creation goes to Meta for approval (PENDING).
Instance Method Summary collapse
- #block(account_id, users) ⇒ Object
- #call_permissions(account_id, to) ⇒ Object
- #calling_disable(account_id) ⇒ Object
- #calling_enable(account_id, input) ⇒ Object
-
#calling_get_config(account_id) ⇒ Object
— Calling (D1g) — voice calls —.
- #calling_update(account_id, input) ⇒ Object
- #create_flow(account_id, input) ⇒ Object
- #create_template(account_id, input) ⇒ Object
- #delete_flow(account_id, flow_id) ⇒ Object
- #delete_template(account_id, name, hsm_id: nil) ⇒ Object
- #deprecate_flow(account_id, flow_id) ⇒ Object
- #edit_template(account_id, template_id, input) ⇒ Object
- #estimate_call(to, recording: nil) ⇒ Object
- #get_call(account_id, call_id) ⇒ Object
- #get_flow(account_id, flow_id) ⇒ Object
- #get_flow_preview(account_id, flow_id, invalidate: nil) ⇒ Object
- #get_profile(account_id) ⇒ Object
- #get_template(account_id, name) ⇒ Object
-
#initialize(http) ⇒ WhatsAppResource
constructor
A new instance of WhatsAppResource.
- #list_blocked(account_id, limit: nil) ⇒ Object
- #list_calls(account_id, limit: nil) ⇒ Object
-
#list_flows(account_id) ⇒ Object
— Flows (D1e) —.
- #list_templates(account_id, status: nil, limit: nil) ⇒ Object
- #place_call(account_id, input) ⇒ Object
- #publish_flow(account_id, flow_id) ⇒ Object
- #register(account_id, pin) ⇒ Object
- #request_code(account_id, input) ⇒ Object
- #sandbox_create_session(phone) ⇒ Object
-
#sandbox_list_sessions ⇒ Object
— Sandbox (D1f) — shared test number sessions —.
- #sandbox_revoke_session(session_id) ⇒ Object
- #send_template(account_id, input) ⇒ Object
- #set_two_step_pin(account_id, pin) ⇒ Object
- #unblock(account_id, users) ⇒ Object
- #update_flow(account_id, flow_id, input) ⇒ Object
- #update_profile(account_id, input) ⇒ Object
- #upload_flow_json(account_id, flow_id, flow_json) ⇒ Object
- #verify_code(account_id, code) ⇒ Object
Constructor Details
#initialize(http) ⇒ WhatsAppResource
Returns a new instance of WhatsAppResource.
487 488 489 |
# File 'lib/posthubify/resources/messaging.rb', line 487 def initialize(http) @http = http end |
Instance Method Details
#block(account_id, users) ⇒ Object
544 545 546 |
# File 'lib/posthubify/resources/messaging.rb', line 544 def block(account_id, users) @http.data('POST', "/whatsapp/#{account_id}/block", body: { 'users' => users }) end |
#call_permissions(account_id, to) ⇒ Object
620 621 622 |
# File 'lib/posthubify/resources/messaging.rb', line 620 def (account_id, to) @http.data('GET', '/whatsapp/call-permissions', query: { 'accountId' => account_id, 'to' => to }) end |
#calling_disable(account_id) ⇒ Object
616 617 618 |
# File 'lib/posthubify/resources/messaging.rb', line 616 def calling_disable(account_id) @http.data('DELETE', "/whatsapp/phone-numbers/#{account_id}/calling") end |
#calling_enable(account_id, input) ⇒ Object
608 609 610 |
# File 'lib/posthubify/resources/messaging.rb', line 608 def calling_enable(account_id, input) @http.data('POST', "/whatsapp/phone-numbers/#{account_id}/calling", body: input) end |
#calling_get_config(account_id) ⇒ Object
— Calling (D1g) — voice calls —
604 605 606 |
# File 'lib/posthubify/resources/messaging.rb', line 604 def calling_get_config(account_id) @http.data('GET', '/whatsapp/calling', query: { 'accountId' => account_id }) end |
#calling_update(account_id, input) ⇒ Object
612 613 614 |
# File 'lib/posthubify/resources/messaging.rb', line 612 def calling_update(account_id, input) @http.data('PATCH', "/whatsapp/phone-numbers/#{account_id}/calling", body: input) end |
#create_flow(account_id, input) ⇒ Object
561 562 563 |
# File 'lib/posthubify/resources/messaging.rb', line 561 def create_flow(account_id, input) @http.data('POST', "/whatsapp/#{account_id}/flows", body: input) end |
#create_template(account_id, input) ⇒ Object
500 501 502 |
# File 'lib/posthubify/resources/messaging.rb', line 500 def create_template(account_id, input) @http.data('POST', "/whatsapp/#{account_id}/templates", body: input) end |
#delete_flow(account_id, flow_id) ⇒ Object
569 570 571 |
# File 'lib/posthubify/resources/messaging.rb', line 569 def delete_flow(account_id, flow_id) @http.data('DELETE', "/whatsapp/#{account_id}/flows/#{flow_id}") end |
#delete_template(account_id, name, hsm_id: nil) ⇒ Object
508 509 510 |
# File 'lib/posthubify/resources/messaging.rb', line 508 def delete_template(account_id, name, hsm_id: nil) @http.data('DELETE', "/whatsapp/#{account_id}/templates/#{name}", query: { 'hsmId' => hsm_id }) end |
#deprecate_flow(account_id, flow_id) ⇒ Object
581 582 583 |
# File 'lib/posthubify/resources/messaging.rb', line 581 def deprecate_flow(account_id, flow_id) @http.data('POST', "/whatsapp/#{account_id}/flows/#{flow_id}/deprecate") end |
#edit_template(account_id, template_id, input) ⇒ Object
504 505 506 |
# File 'lib/posthubify/resources/messaging.rb', line 504 def edit_template(account_id, template_id, input) @http.data('PATCH', "/whatsapp/#{account_id}/templates/#{template_id}", body: input) end |
#estimate_call(to, recording: nil) ⇒ Object
636 637 638 |
# File 'lib/posthubify/resources/messaging.rb', line 636 def estimate_call(to, recording: nil) @http.data('GET', '/whatsapp/calls/estimate', query: { 'to' => to, 'recording' => recording }) end |
#get_call(account_id, call_id) ⇒ Object
632 633 634 |
# File 'lib/posthubify/resources/messaging.rb', line 632 def get_call(account_id, call_id) @http.data('GET', "/whatsapp/calls/#{call_id}", query: { 'accountId' => account_id }) end |
#get_flow(account_id, flow_id) ⇒ Object
557 558 559 |
# File 'lib/posthubify/resources/messaging.rb', line 557 def get_flow(account_id, flow_id) @http.data('GET', "/whatsapp/#{account_id}/flows/#{flow_id}") end |
#get_flow_preview(account_id, flow_id, invalidate: nil) ⇒ Object
585 586 587 588 |
# File 'lib/posthubify/resources/messaging.rb', line 585 def get_flow_preview(account_id, flow_id, invalidate: nil) @http.data('GET', "/whatsapp/#{account_id}/flows/#{flow_id}/preview", query: { 'invalidate' => invalidate }) end |
#get_profile(account_id) ⇒ Object
516 517 518 |
# File 'lib/posthubify/resources/messaging.rb', line 516 def get_profile(account_id) @http.data('GET', "/whatsapp/#{account_id}/profile") end |
#get_template(account_id, name) ⇒ Object
496 497 498 |
# File 'lib/posthubify/resources/messaging.rb', line 496 def get_template(account_id, name) @http.data('GET', "/whatsapp/#{account_id}/templates/#{name}") end |
#list_blocked(account_id, limit: nil) ⇒ Object
540 541 542 |
# File 'lib/posthubify/resources/messaging.rb', line 540 def list_blocked(account_id, limit: nil) @http.data('GET', "/whatsapp/#{account_id}/blocked", query: { 'limit' => limit }) end |
#list_calls(account_id, limit: nil) ⇒ Object
628 629 630 |
# File 'lib/posthubify/resources/messaging.rb', line 628 def list_calls(account_id, limit: nil) @http.data('GET', '/whatsapp/calls', query: { 'accountId' => account_id, 'limit' => limit }) end |
#list_flows(account_id) ⇒ Object
— Flows (D1e) —
553 554 555 |
# File 'lib/posthubify/resources/messaging.rb', line 553 def list_flows(account_id) @http.data('GET', "/whatsapp/#{account_id}/flows") end |
#list_templates(account_id, status: nil, limit: nil) ⇒ Object
491 492 493 494 |
# File 'lib/posthubify/resources/messaging.rb', line 491 def list_templates(account_id, status: nil, limit: nil) @http.data('GET', "/whatsapp/#{account_id}/templates", query: { 'status' => status, 'limit' => limit }) end |
#place_call(account_id, input) ⇒ Object
624 625 626 |
# File 'lib/posthubify/resources/messaging.rb', line 624 def place_call(account_id, input) @http.data('POST', '/whatsapp/calls', body: { 'accountId' => account_id }.merge(input)) end |
#publish_flow(account_id, flow_id) ⇒ Object
577 578 579 |
# File 'lib/posthubify/resources/messaging.rb', line 577 def publish_flow(account_id, flow_id) @http.data('POST', "/whatsapp/#{account_id}/flows/#{flow_id}/publish") end |
#register(account_id, pin) ⇒ Object
532 533 534 |
# File 'lib/posthubify/resources/messaging.rb', line 532 def register(account_id, pin) @http.data('POST', "/whatsapp/#{account_id}/register", body: { 'pin' => pin }) end |
#request_code(account_id, input) ⇒ Object
524 525 526 |
# File 'lib/posthubify/resources/messaging.rb', line 524 def request_code(account_id, input) @http.data('POST', "/whatsapp/#{account_id}/request-code", body: input) end |
#sandbox_create_session(phone) ⇒ Object
595 596 597 |
# File 'lib/posthubify/resources/messaging.rb', line 595 def sandbox_create_session(phone) @http.data('POST', '/whatsapp/sandbox/sessions', body: { 'phone' => phone }) end |
#sandbox_list_sessions ⇒ Object
— Sandbox (D1f) — shared test number sessions —
591 592 593 |
# File 'lib/posthubify/resources/messaging.rb', line 591 def sandbox_list_sessions @http.data('GET', '/whatsapp/sandbox/sessions') end |
#sandbox_revoke_session(session_id) ⇒ Object
599 600 601 |
# File 'lib/posthubify/resources/messaging.rb', line 599 def sandbox_revoke_session(session_id) @http.data('DELETE', "/whatsapp/sandbox/sessions/#{session_id}") end |
#send_template(account_id, input) ⇒ Object
512 513 514 |
# File 'lib/posthubify/resources/messaging.rb', line 512 def send_template(account_id, input) @http.data('POST', "/whatsapp/#{account_id}/template-messages", body: input) end |
#set_two_step_pin(account_id, pin) ⇒ Object
536 537 538 |
# File 'lib/posthubify/resources/messaging.rb', line 536 def set_two_step_pin(account_id, pin) @http.data('POST', "/whatsapp/#{account_id}/two-step", body: { 'pin' => pin }) end |
#unblock(account_id, users) ⇒ Object
548 549 550 |
# File 'lib/posthubify/resources/messaging.rb', line 548 def unblock(account_id, users) @http.data('POST', "/whatsapp/#{account_id}/unblock", body: { 'users' => users }) end |
#update_flow(account_id, flow_id, input) ⇒ Object
565 566 567 |
# File 'lib/posthubify/resources/messaging.rb', line 565 def update_flow(account_id, flow_id, input) @http.data('PATCH', "/whatsapp/#{account_id}/flows/#{flow_id}", body: input) end |
#update_profile(account_id, input) ⇒ Object
520 521 522 |
# File 'lib/posthubify/resources/messaging.rb', line 520 def update_profile(account_id, input) @http.data('PATCH', "/whatsapp/#{account_id}/profile", body: input) end |
#upload_flow_json(account_id, flow_id, flow_json) ⇒ Object
573 574 575 |
# File 'lib/posthubify/resources/messaging.rb', line 573 def upload_flow_json(account_id, flow_id, flow_json) @http.data('PUT', "/whatsapp/#{account_id}/flows/#{flow_id}/json", body: { 'flowJson' => flow_json }) end |
#verify_code(account_id, code) ⇒ Object
528 529 530 |
# File 'lib/posthubify/resources/messaging.rb', line 528 def verify_code(account_id, code) @http.data('POST', "/whatsapp/#{account_id}/verify-code", body: { 'code' => code }) end |