Class: WhatsAppCloudApi::TwoStepVerificationController
- Inherits:
-
BaseController
- Object
- BaseController
- WhatsAppCloudApi::TwoStepVerificationController
- Defined in:
- lib/whats_app_cloud_api/controllers/two_step_verification_controller.rb
Overview
TwoStepVerificationController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#initialize(config, http_call_back: nil) ⇒ TwoStepVerificationController
constructor
A new instance of TwoStepVerificationController.
-
#set_two_step_verification_code(phone_number_id, body) ⇒ SuccessResponse
You are required to set up two-step verification for your phone number, as this provides an extra layer of security to the business accounts.
Methods inherited from BaseController
#execute_request, #get_user_agent, #validate_parameters, #validate_response
Constructor Details
#initialize(config, http_call_back: nil) ⇒ TwoStepVerificationController
Returns a new instance of TwoStepVerificationController.
9 10 11 |
# File 'lib/whats_app_cloud_api/controllers/two_step_verification_controller.rb', line 9 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#set_two_step_verification_code(phone_number_id, body) ⇒ SuccessResponse
You are required to set up two-step verification for your phone number, as this provides an extra layer of security to the business accounts. You can use this endpoint to change two-step verification code associated with your account. After you change the verification code, future requests like changing the name, must use the new code. You set up two-factor verification and register a phone number in the same API call. Example:
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/whats_app_cloud_api/controllers/two_step_verification_controller.rb', line 25 def set_two_step_verification_code(phone_number_id, body) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/{Phone-Number-ID}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'Phone-Number-ID' => { 'value' => phone_number_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) validate_response(_response) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) SuccessResponse.from_hash(decoded) end |