Class: Posthubify::WhatsAppResource

Inherits:
Object
  • Object
show all
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

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(, users)
  @http.data('POST', "/whatsapp/#{}/block", body: { 'users' => users })
end

#call_permissions(account_id, to) ⇒ Object



620
621
622
# File 'lib/posthubify/resources/messaging.rb', line 620

def call_permissions(, to)
  @http.data('GET', '/whatsapp/call-permissions', query: { 'accountId' => , 'to' => to })
end

#calling_disable(account_id) ⇒ Object



616
617
618
# File 'lib/posthubify/resources/messaging.rb', line 616

def calling_disable()
  @http.data('DELETE', "/whatsapp/phone-numbers/#{}/calling")
end

#calling_enable(account_id, input) ⇒ Object



608
609
610
# File 'lib/posthubify/resources/messaging.rb', line 608

def calling_enable(, input)
  @http.data('POST', "/whatsapp/phone-numbers/#{}/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()
  @http.data('GET', '/whatsapp/calling', query: { 'accountId' =>  })
end

#calling_update(account_id, input) ⇒ Object



612
613
614
# File 'lib/posthubify/resources/messaging.rb', line 612

def calling_update(, input)
  @http.data('PATCH', "/whatsapp/phone-numbers/#{}/calling", body: input)
end

#create_flow(account_id, input) ⇒ Object



561
562
563
# File 'lib/posthubify/resources/messaging.rb', line 561

def create_flow(, input)
  @http.data('POST', "/whatsapp/#{}/flows", body: input)
end

#create_template(account_id, input) ⇒ Object



500
501
502
# File 'lib/posthubify/resources/messaging.rb', line 500

def create_template(, input)
  @http.data('POST', "/whatsapp/#{}/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(, flow_id)
  @http.data('DELETE', "/whatsapp/#{}/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(, name, hsm_id: nil)
  @http.data('DELETE', "/whatsapp/#{}/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(, flow_id)
  @http.data('POST', "/whatsapp/#{}/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(, template_id, input)
  @http.data('PATCH', "/whatsapp/#{}/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(, call_id)
  @http.data('GET', "/whatsapp/calls/#{call_id}", query: { 'accountId' =>  })
end

#get_flow(account_id, flow_id) ⇒ Object



557
558
559
# File 'lib/posthubify/resources/messaging.rb', line 557

def get_flow(, flow_id)
  @http.data('GET', "/whatsapp/#{}/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(, flow_id, invalidate: nil)
  @http.data('GET', "/whatsapp/#{}/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()
  @http.data('GET', "/whatsapp/#{}/profile")
end

#get_template(account_id, name) ⇒ Object



496
497
498
# File 'lib/posthubify/resources/messaging.rb', line 496

def get_template(, name)
  @http.data('GET', "/whatsapp/#{}/templates/#{name}")
end

#list_blocked(account_id, limit: nil) ⇒ Object



540
541
542
# File 'lib/posthubify/resources/messaging.rb', line 540

def list_blocked(, limit: nil)
  @http.data('GET', "/whatsapp/#{}/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(, limit: nil)
  @http.data('GET', '/whatsapp/calls', query: { 'accountId' => , 'limit' => limit })
end

#list_flows(account_id) ⇒ Object

— Flows (D1e) —



553
554
555
# File 'lib/posthubify/resources/messaging.rb', line 553

def list_flows()
  @http.data('GET', "/whatsapp/#{}/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(, status: nil, limit: nil)
  @http.data('GET', "/whatsapp/#{}/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(, input)
  @http.data('POST', '/whatsapp/calls', body: { 'accountId' =>  }.merge(input))
end

#publish_flow(account_id, flow_id) ⇒ Object



577
578
579
# File 'lib/posthubify/resources/messaging.rb', line 577

def publish_flow(, flow_id)
  @http.data('POST', "/whatsapp/#{}/flows/#{flow_id}/publish")
end

#register(account_id, pin) ⇒ Object



532
533
534
# File 'lib/posthubify/resources/messaging.rb', line 532

def register(, pin)
  @http.data('POST', "/whatsapp/#{}/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(, input)
  @http.data('POST', "/whatsapp/#{}/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_sessionsObject

— 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(, input)
  @http.data('POST', "/whatsapp/#{}/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(, pin)
  @http.data('POST', "/whatsapp/#{}/two-step", body: { 'pin' => pin })
end

#unblock(account_id, users) ⇒ Object



548
549
550
# File 'lib/posthubify/resources/messaging.rb', line 548

def unblock(, users)
  @http.data('POST', "/whatsapp/#{}/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(, flow_id, input)
  @http.data('PATCH', "/whatsapp/#{}/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(, input)
  @http.data('PATCH', "/whatsapp/#{}/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(, flow_id, flow_json)
  @http.data('PUT', "/whatsapp/#{}/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(, code)
  @http.data('POST', "/whatsapp/#{}/verify-code", body: { 'code' => code })
end