Class: Whatsapp::BusinessPhoneNumber::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/business_phone_number/response.rb

Overview

The response shared by all four phone-number actions: {success}, with an optional id that only VerifyCode ever populates. One class covers all of them — unlike SubscribedApp's Response::* namespace — since Register, Deregister, RequestCode, and VerifyCode all return this same shape, id included or not. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/registration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success: false, id: nil) ⇒ Response

Returns a new instance of Response.

Parameters:

  • success (Boolean) (defaults to: false)
  • id (String, nil) (defaults to: nil)


23
24
25
26
# File 'lib/ruby/whatsapp/business_phone_number/response.rb', line 23

def initialize(success: false, id: nil)
  @success = success
  @id = id
end

Instance Attribute Details

#idString?

Returns The phone number ID, only ever present on VerifyCode's response.

Returns:

  • (String, nil)

    The phone number ID, only ever present on VerifyCode's response.



19
20
21
# File 'lib/ruby/whatsapp/business_phone_number/response.rb', line 19

def id
  @id
end

#successBoolean

Returns Whether the action succeeded.

Returns:

  • (Boolean)

    Whether the action succeeded.



14
15
16
# File 'lib/ruby/whatsapp/business_phone_number/response.rb', line 14

def success
  @success
end

Class Method Details

.deserialize(response) ⇒ Response

Parameters:

  • response (Hash, nil)

    The parsed response body.

Returns:



31
32
33
34
35
# File 'lib/ruby/whatsapp/business_phone_number/response.rb', line 31

def deserialize(response)
  response ||= {}

  new(success: response["success"] == true, id: response["id"])
end