Class: Whatsapp::BusinessPhoneNumber::Account::Details

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

Overview

The WhatsApp Business Account node returned by Get.

Only id and name are documented required; everything else arrives just when asked for via fields, so every attribute tolerates being absent. Status values are exposed as raw strings and are never validated on the way in — this is read-side data, and a value Meta adds later must still round-trip. The frozen constant modules below are for comparison, not enforcement, mirroring how MessageTemplates::Response::Node keeps Meta's echoed payloads raw. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-account/whatsapp-business-account-api

Defined Under Namespace

Modules: OwnershipTypes, ReviewStatuses, VerificationStatuses

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, name: nil, timezone_id: nil, message_template_namespace: nil, account_review_status: nil, business_verification_status: nil, country: nil, ownership_type: nil, primary_business_location: nil) ⇒ Details

Returns a new instance of Details.

Parameters:

  • id (String, nil) (defaults to: nil)
  • name (String, nil) (defaults to: nil)
  • timezone_id (String, nil) (defaults to: nil)
  • message_template_namespace (String, nil) (defaults to: nil)
  • account_review_status (String, nil) (defaults to: nil)
  • business_verification_status (String, nil) (defaults to: nil)
  • country (String, nil) (defaults to: nil)
  • ownership_type (String, nil) (defaults to: nil)
  • primary_business_location (String, nil) (defaults to: nil)


97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 97

def initialize(id: nil, name: nil, timezone_id: nil, message_template_namespace: nil,
  account_review_status: nil, business_verification_status: nil, country: nil,
  ownership_type: nil, primary_business_location: nil)
  @id = id
  @name = name
  @timezone_id = timezone_id
  @message_template_namespace = message_template_namespace
  @account_review_status = 
  @business_verification_status = business_verification_status
  @country = country
  @ownership_type = ownership_type
  @primary_business_location = primary_business_location
end

Instance Attribute Details

#account_review_statusString?



70
71
72
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 70

def 
  @account_review_status
end

#business_verification_statusString?



74
75
76
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 74

def business_verification_status
  @business_verification_status
end

#countryString?

Returns The account's country code.

Returns:

  • (String, nil)

    The account's country code.



78
79
80
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 78

def country
  @country
end

#idString?

Returns The account's unique identifier.

Returns:

  • (String, nil)

    The account's unique identifier.



54
55
56
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 54

def id
  @id
end

#message_template_namespaceString?

Returns The namespace the account's templates live in.

Returns:

  • (String, nil)

    The namespace the account's templates live in.



66
67
68
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 66

def message_template_namespace
  @message_template_namespace
end

#nameString?

Returns The account's human-readable name.

Returns:

  • (String, nil)

    The account's human-readable name.



58
59
60
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 58

def name
  @name
end

#ownership_typeString?



82
83
84
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 82

def ownership_type
  @ownership_type
end

#primary_business_locationString?

Returns The account's primary business location.

Returns:

  • (String, nil)

    The account's primary business location.



86
87
88
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 86

def primary_business_location
  @primary_business_location
end

#timezone_idString?

Returns The account's timezone identifier.

Returns:

  • (String, nil)

    The account's timezone identifier.



62
63
64
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 62

def timezone_id
  @timezone_id
end

Class Method Details

.deserialize(response) ⇒ Details

Parameters:

  • response (Hash, nil)

    The parsed response body.

Returns:



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 114

def deserialize(response)
  response ||= {}

  new(
    id: response["id"],
    name: response["name"],
    timezone_id: response["timezone_id"],
    message_template_namespace: response["message_template_namespace"],
    account_review_status: response["account_review_status"],
    business_verification_status: response["business_verification_status"],
    country: response["country"],
    ownership_type: response["ownership_type"],
    primary_business_location: response["primary_business_location"]
  )
end

Instance Method Details

#approved?Boolean

Returns Whether Meta has approved the account.

Returns:

  • (Boolean)

    Whether Meta has approved the account.



132
133
134
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 132

def approved?
   == ReviewStatuses::APPROVED
end

#self_owned?Boolean

Returns Whether the account belongs to your own business, rather than to a client or a partner acting on one's behalf.

Returns:

  • (Boolean)

    Whether the account belongs to your own business, rather than to a client or a partner acting on one's behalf.



143
144
145
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 143

def self_owned?
  ownership_type == OwnershipTypes::SELF
end

#verified?Boolean

Returns Whether the business behind the account is verified.

Returns:

  • (Boolean)

    Whether the business behind the account is verified.



137
138
139
# File 'lib/ruby/whatsapp/business_phone_number/account/details.rb', line 137

def verified?
  business_verification_status == VerificationStatuses::VERIFIED
end