Class: Whatsapp::Webhook::Change
- Inherits:
-
Object
- Object
- Whatsapp::Webhook::Change
- Defined in:
- lib/ruby/whatsapp/webhook/change.rb
Overview
A single entry[].changes[] item: field names which of Meta's ~19 documented
webhook notification types this is, value is the deserialized payload for it.
FIELDS is populated incrementally as each field's value class is implemented
(see Whatsapp::Webhook::CLAUDE.md) — never const_get on the field name, which
comes straight from the internet; a field not yet in the registry falls back to
UnknownField rather than raising.
Constant Summary collapse
- FIELDS =
{ messages: Messages, account_alerts: AccountAlerts, account_review_update: AccountReviewUpdate, account_update: AccountUpdate, automatic_events: AutomaticEvents, business_capability_update: BusinessCapabilityUpdate, history: History, message_template_components_update: MessageTemplateComponentsUpdate, message_template_quality_update: MessageTemplateQualityUpdate, message_template_status_update: MessageTemplateStatusUpdate, partner_solutions: PartnerSolutions, payment_configuration_update: PaymentConfigurationUpdate, phone_number_name_update: PhoneNumberNameUpdate, phone_number_quality_update: PhoneNumberQualityUpdate, security: Security, smb_app_state_sync: SmbAppStateSync, smb_message_echoes: SmbMessageEchoes, template_category_update: TemplateCategoryUpdate, user_preferences: UserPreferences, }.freeze
Instance Attribute Summary collapse
- #field ⇒ String
-
#value ⇒ Object
One of the classes registered in FIELDS, or UnknownField.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(field:, value:) ⇒ Change
constructor
A new instance of Change.
Constructor Details
#initialize(field:, value:) ⇒ Change
Returns a new instance of Change.
43 44 45 46 |
# File 'lib/ruby/whatsapp/webhook/change.rb', line 43 def initialize(field:, value:) @field = field @value = value end |
Instance Attribute Details
#field ⇒ String
37 38 39 |
# File 'lib/ruby/whatsapp/webhook/change.rb', line 37 def field @field end |
#value ⇒ Object
Returns One of the classes registered in FIELDS, or UnknownField.
41 42 43 |
# File 'lib/ruby/whatsapp/webhook/change.rb', line 41 def value @value end |
Class Method Details
.deserialize(data) ⇒ Change
51 52 53 54 55 56 57 |
# File 'lib/ruby/whatsapp/webhook/change.rb', line 51 def deserialize(data) data ||= {} field = data["field"] klass = FIELDS.fetch(field.to_s.to_sym) { UnknownField } new(field:, value: klass.deserialize(data["value"])) end |