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
#auth_method, #create, #destroy, #execute, included, #model_class, #persisted?, #reload, #resource_path, #resources_path, #to_json
Class Method Details
.resources_path(api:) ⇒ Object
90
91
92
|
# File 'lib/nylas/webhook.rb', line 90
def self.resources_path(api:)
"/a/#{api.app_id}/webhooks"
end
|
Instance Method Details
#save ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/nylas/webhook.rb', line 62
def save
result = if persisted?
update_call(update_payload)
else
create
end
attributes.merge(result)
end
|
#save_all_attributes ⇒ Object
72
73
74
|
# File 'lib/nylas/webhook.rb', line 72
def save_all_attributes
save
end
|
#update(**data) ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/nylas/webhook.rb', line 76
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
86
87
88
|
# File 'lib/nylas/webhook.rb', line 86
def update_all_attributes(**data)
update(**data)
end
|