Class: Closeio::Rails::Webhook
- Defined in:
- app/models/closeio/rails/webhook.rb
Class Method Summary collapse
Methods included from Attributes
Class Method Details
.all ⇒ Object
4 5 6 7 8 |
# File 'app/models/closeio/rails/webhook.rb', line 4 def self.all Closeio::Rails.configuration.client.list_webhooks['data'].collect do |webhook| self.new(webhook) end end |
.create(params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/closeio/rails/webhook.rb', line 10 def self.create(params) response = Closeio::Rails.configuration.client.create_webhook(params) if response.has_key?('field-errors') raise Closeio::Error, "#{response['field-errors']['name']}" elsif response.has_key?('error') raise Closeio::Error, "#{response['error']}" else response end end |
.destroy!(id) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/closeio/rails/webhook.rb', line 21 def self.destroy!(id) response = Closeio::Rails.configuration.client.delete_webhook(id) if response.has_key?('field-errors') raise Closeio::Error, "#{response['field-errors']['name']}" elsif response.has_key?('error') raise Closeio::Error, "#{response['error']}" else response end end |