Class: Sendly::WhatsAppSignupResource
- Inherits:
-
Object
- Object
- Sendly::WhatsAppSignupResource
- Defined in:
- lib/sendly/whatsapp_resource.rb
Overview
Connect numbers to WhatsApp. Starting a signup returns a connect_url
a human must complete in a browser.
Instance Method Summary collapse
-
#create(phone_number:) ⇒ WhatsAppSignupSession
Start connecting a number to WhatsApp.
-
#get(id) ⇒ WhatsAppSignup
Get the status of a WhatsApp signup.
-
#initialize(client) ⇒ WhatsAppSignupResource
constructor
A new instance of WhatsAppSignupResource.
Constructor Details
#initialize(client) ⇒ WhatsAppSignupResource
Returns a new instance of WhatsAppSignupResource.
294 295 296 |
# File 'lib/sendly/whatsapp_resource.rb', line 294 def initialize(client) @client = client end |
Instance Method Details
#create(phone_number:) ⇒ WhatsAppSignupSession
Start connecting a number to WhatsApp.
Charges a one-time $19 setup fee (no monthly fee) and returns a
connect_url. Completing the connection requires a human: hand the
URL to your user — they open it in a browser and log in with Facebook
to link their WhatsApp Business Account. Then poll #get until the
status is "active".
Calling again for a number with an in-flight signup returns the
existing signup (same connect_url) without charging again. Requires
a live API key.
317 318 319 320 321 322 |
# File 'lib/sendly/whatsapp_resource.rb', line 317 def create(phone_number:) raise ValidationError, "phone_number is required" if phone_number.nil? || phone_number.to_s.empty? response = @client.post("/whatsapp/signup", { phoneNumber: phone_number }) WhatsAppSignupSession.new(response) end |
#get(id) ⇒ WhatsAppSignup
Get the status of a WhatsApp signup.
333 334 335 336 337 338 339 |
# File 'lib/sendly/whatsapp_resource.rb', line 333 def get(id) raise ValidationError, "id is required" if id.nil? || id.to_s.empty? encoded_id = URI.encode_www_form_component(id) response = @client.get("/whatsapp/signup/#{encoded_id}") WhatsAppSignup.new(response) end |