Class: Amorail::Webhook
- Defined in:
- lib/amorail/entities/webhook.rb
Overview
AmoCRM webhook entity
Class Method Summary collapse
Methods inherited from Entity
amo_field, amo_names, amo_property, attributes, find, find!, find_all, find_by_query, inherited, #initialize, #load_record, #new_record?, #params, #persisted?, properties, #reload, #reload_model, remote_url, #save, #save!, #update, #update!, where
Constructor Details
This class inherits a constructor from Amorail::Entity
Class Method Details
.list ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/amorail/entities/webhook.rb', line 10 def self.list response = client.safe_request(:get, remote_url('list')) return [] if response.body.blank? response.body['response'].fetch(amo_response_name, []).map do |attributes| new.reload_model(attributes) end end |
.subscribe(webhooks) ⇒ Object
20 21 22 23 24 |
# File 'lib/amorail/entities/webhook.rb', line 20 def self.subscribe(webhooks) perform_webhooks_request('subscribe', webhooks) do |data| data.map { |attrs| new.reload_model(attrs) } end end |
.unsubscribe(webhooks) ⇒ Object
26 27 28 |
# File 'lib/amorail/entities/webhook.rb', line 26 def self.unsubscribe(webhooks) perform_webhooks_request('unsubscribe', webhooks) end |