Class: Whatsapp::Webhook::UserPreferences

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/webhook/user_preferences.rb

Overview

User marketing message preference changes (e.g. a customer opting out of marketing messages).

Best-effort schema: Meta's public docs describe this field in one line with no published JSON example. Validate against a real payload (App Dashboard "send test payload") before relying on these attribute names in production. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/webhooks/overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wa_id:, detail:, value:, timestamp:) ⇒ UserPreferences

Returns a new instance of UserPreferences.



29
30
31
32
33
34
# File 'lib/ruby/whatsapp/webhook/user_preferences.rb', line 29

def initialize(wa_id:, detail:, value:, timestamp:)
  @wa_id = wa_id
  @detail = detail
  @value = value
  @timestamp = timestamp
end

Instance Attribute Details

#detailString?

Returns:

  • (String, nil)


19
20
21
# File 'lib/ruby/whatsapp/webhook/user_preferences.rb', line 19

def detail
  @detail
end

#timestampString?

Returns:

  • (String, nil)


27
28
29
# File 'lib/ruby/whatsapp/webhook/user_preferences.rb', line 27

def timestamp
  @timestamp
end

#valueString?

Returns e.g. "stop", "resume".

Returns:

  • (String, nil)

    e.g. "stop", "resume".



23
24
25
# File 'lib/ruby/whatsapp/webhook/user_preferences.rb', line 23

def value
  @value
end

#wa_idString?

Returns:

  • (String, nil)


15
16
17
# File 'lib/ruby/whatsapp/webhook/user_preferences.rb', line 15

def wa_id
  @wa_id
end

Class Method Details

.deserialize(data) ⇒ UserPreferences

Parameters:

  • data (Hash)

    The raw value hash.

Returns:



39
40
41
42
43
# File 'lib/ruby/whatsapp/webhook/user_preferences.rb', line 39

def deserialize(data)
  data ||= {}

  new(wa_id: data["wa_id"], detail: data["detail"], value: data["value"], timestamp: data["timestamp"])
end