Class: EvolutionApi::Webhook
- Inherits:
-
Object
- Object
- EvolutionApi::Webhook
- Defined in:
- lib/evolution_api/webhook.rb
Overview
Classe para gerenciar webhooks da Evolution API
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#instance_name ⇒ Object
readonly
Returns the value of attribute instance_name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#configured? ⇒ Boolean
Verifica se o webhook está configurado.
-
#enabled_events ⇒ Object
Lista todos os eventos habilitados.
-
#event_enabled?(event) ⇒ Boolean
Verifica se um evento específico está habilitado.
-
#initialize(data, instance_name = nil) ⇒ Webhook
constructor
A new instance of Webhook.
-
#to_h ⇒ Object
Converte para hash.
-
#to_json(*args) ⇒ Object
Converte para JSON.
Constructor Details
#initialize(data, instance_name = nil) ⇒ Webhook
Returns a new instance of Webhook.
8 9 10 11 12 |
# File 'lib/evolution_api/webhook.rb', line 8 def initialize(data, instance_name = nil) @url = data['webhook'] @events = data['events'] || [] @instance_name = instance_name end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
6 7 8 |
# File 'lib/evolution_api/webhook.rb', line 6 def events @events end |
#instance_name ⇒ Object (readonly)
Returns the value of attribute instance_name.
6 7 8 |
# File 'lib/evolution_api/webhook.rb', line 6 def instance_name @instance_name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/evolution_api/webhook.rb', line 6 def url @url end |
Instance Method Details
#configured? ⇒ Boolean
Verifica se o webhook está configurado
15 16 17 |
# File 'lib/evolution_api/webhook.rb', line 15 def configured? !url.nil? && !url.empty? end |
#enabled_events ⇒ Object
Lista todos os eventos habilitados
25 26 27 |
# File 'lib/evolution_api/webhook.rb', line 25 def enabled_events events.dup end |
#event_enabled?(event) ⇒ Boolean
Verifica se um evento específico está habilitado
20 21 22 |
# File 'lib/evolution_api/webhook.rb', line 20 def event_enabled?(event) events.include?(event) end |
#to_h ⇒ Object
Converte para hash
30 31 32 33 34 35 36 37 |
# File 'lib/evolution_api/webhook.rb', line 30 def to_h { url: url, events: events, configured: configured?, instance_name: instance_name } end |
#to_json(*args) ⇒ Object
Converte para JSON
40 41 42 |
# File 'lib/evolution_api/webhook.rb', line 40 def to_json(*args) to_h.to_json(*args) end |