Class: Whatsapp::BusinessPhoneNumber::VerifyCode
- Inherits:
-
Object
- Object
- Whatsapp::BusinessPhoneNumber::VerifyCode
- Extended by:
- Transport, ResponseHandling
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/ruby/whatsapp/business_phone_number/verify_code.rb
Overview
Confirms the verification code sent by RequestCode, the second step of the
onboarding flow this module wraps end to end: RequestCode -> VerifyCode ->
Register.
Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-phone-number/verify-code-api
Defined Under Namespace
Modules: Defaults
Constant Summary
Constants included from ResponseHandling
ResponseHandling::MAX_ERROR_BODY
Instance Attribute Summary collapse
-
#code ⇒ String
The verification code received via SMS or voice call.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code:) ⇒ VerifyCode
constructor
A new instance of VerifyCode.
-
#inspect ⇒ String
Redacts the code so it never leaks into logs or console output, same as Register#inspect redacts the pin.
-
#serialize ⇒ Hash
The verify-code payload.
Constructor Details
#initialize(code:) ⇒ VerifyCode
Returns a new instance of VerifyCode.
28 29 30 31 32 |
# File 'lib/ruby/whatsapp/business_phone_number/verify_code.rb', line 28 def initialize(code:) @code = code validate! end |
Instance Attribute Details
#code ⇒ String
Returns The verification code received via SMS or voice call.
20 21 22 |
# File 'lib/ruby/whatsapp/business_phone_number/verify_code.rb', line 20 def code @code end |
Class Method Details
.call(code:, client: Client.new) ⇒ Response
52 53 54 55 56 57 58 59 |
# File 'lib/ruby/whatsapp/business_phone_number/verify_code.rb', line 52 def call(code:, client: Client.new) body = new(code:).serialize response = client.connection.post(edge_path(client, Defaults::EDGE), json: body) Response.deserialize( parse_json(handle_response!(response, error_class: Error, action: "verify code")) ) end |
Instance Method Details
#inspect ⇒ String
Redacts the code so it never leaks into logs or console output, same as Register#inspect redacts the pin.
42 43 44 |
# File 'lib/ruby/whatsapp/business_phone_number/verify_code.rb', line 42 def inspect "#<#{self.class.name} code=[REDACTED]>" end |
#serialize ⇒ Hash
Returns The verify-code payload.
35 36 37 |
# File 'lib/ruby/whatsapp/business_phone_number/verify_code.rb', line 35 def serialize { code: code.to_s } end |