Class: Particle::Webhook
Overview
Domain model for one Particle device
Class Method Summary collapse
Instance Method Summary collapse
-
#create ⇒ Object
Add a Particle webhook.
-
#error ⇒ Object
The error from the web server to a test message If nil, check response.
-
#get_attributes ⇒ Object
Force reloading the attributes for the webhook.
-
#initialize(client, attributes) ⇒ Webhook
constructor
A new instance of Webhook.
- #path ⇒ Object
-
#remove ⇒ Object
Remove a Particle webhook.
-
#response ⇒ Object
The response of the web server to a test message If nil, check error.
Methods inherited from Model
attribute_reader, #attributes, #id, #inspect
Constructor Details
#initialize(client, attributes) ⇒ Webhook
Returns a new instance of Webhook.
7 8 9 |
# File 'lib/particle/webhook.rb', line 7 def initialize(client, attributes) super(client, attributes) end |
Class Method Details
.create_path ⇒ Object
53 54 55 |
# File 'lib/particle/webhook.rb', line 53 def self.create_path "v1/webhooks" end |
.list_path ⇒ Object
49 50 51 |
# File 'lib/particle/webhook.rb', line 49 def self.list_path "v1/webhooks" end |
Instance Method Details
#create ⇒ Object
Add a Particle webhook
38 39 40 41 42 |
# File 'lib/particle/webhook.rb', line 38 def create new_webhook = @client.create_webhook(@attributes) @attributes = new_webhook.attributes self end |
#error ⇒ Object
The error from the web server to a test message If nil, check response
23 24 25 26 |
# File 'lib/particle/webhook.rb', line 23 def error get_attributes unless @loaded @error end |
#get_attributes ⇒ Object
Force reloading the attributes for the webhook
29 30 31 32 33 34 35 |
# File 'lib/particle/webhook.rb', line 29 def get_attributes @loaded = true result = @client.webhook_attributes(self) @response = result[:response] @error = result[:error] @attributes = result[:webhook] end |
#path ⇒ Object
57 58 59 |
# File 'lib/particle/webhook.rb', line 57 def path "/v1/webhooks/#{id}" end |
#remove ⇒ Object
Remove a Particle webhook
45 46 47 |
# File 'lib/particle/webhook.rb', line 45 def remove @client.remove_webhook(self) end |
#response ⇒ Object
The response of the web server to a test message If nil, check error
16 17 18 19 |
# File 'lib/particle/webhook.rb', line 16 def response get_attributes unless @loaded @response end |