Class: Nylas::Webhook
- Inherits:
-
Object
show all
- Includes:
- Model
- Defined in:
- lib/nylas/webhook.rb
Overview
Represents a webhook attached to your application.
Constant Summary
collapse
- STATE =
[:inactive].freeze
Instance Attribute Summary
Attributes included from Model
#api
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Model
#create, #destroy, #execute, included, #model_class, #persisted?, #reload, #resource_path, #resources_path, #to_json
Class Method Details
.resources_path(api:) ⇒ Object
84
85
86
|
# File 'lib/nylas/webhook.rb', line 84
def self.resources_path(api:)
"/a/#{api.app_id}/webhooks"
end
|
Instance Method Details
#save ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/nylas/webhook.rb', line 56
def save
result = if persisted?
update_call(update_payload)
else
create
end
attributes.merge(result)
end
|
#save_all_attributes ⇒ Object
66
67
68
|
# File 'lib/nylas/webhook.rb', line 66
def save_all_attributes
save
end
|
#update(**data) ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'lib/nylas/webhook.rb', line 70
def update(**data)
raise ArgumentError, "Only 'state' is allowed to be updated" if data.length > 1 || !data.key?(:state)
attributes.merge(**data)
payload = JSON.dump(data)
update_call(payload)
true
end
|
#update_all_attributes(**data) ⇒ Object
80
81
82
|
# File 'lib/nylas/webhook.rb', line 80
def update_all_attributes(**data)
update(**data)
end
|