Class: TrackerApi::Endpoints::Webhook
- Defined in:
- lib/tracker_api/endpoints/webhook.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #create(project_id, params = {}) ⇒ Object
- #delete(webhook) ⇒ Object
- #delete_from_project(project_id, webhook_id) ⇒ Object
- #get(project_id, id, params = {}) ⇒ Object
-
#initialize(client) ⇒ Webhook
constructor
A new instance of Webhook.
- #update(webhook, params = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Webhook
Returns a new instance of Webhook.
6 7 8 |
# File 'lib/tracker_api/endpoints/webhook.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/tracker_api/endpoints/webhook.rb', line 4 def client @client end |
Instance Method Details
#create(project_id, params = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/tracker_api/endpoints/webhook.rb', line 16 def create(project_id, params={}) data = client.post("/projects/#{project_id}/webhooks", params: params).body Resources::Webhook.new({ client: client }.merge(data)) end |
#delete(webhook) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/tracker_api/endpoints/webhook.rb', line 32 def delete(webhook) raise ArgumentError, 'Valid webhook required to update.' unless webhook.instance_of?(Resources::Webhook) data = client.delete("/projects/#{webhook.project_id}/webhooks/#{webhook.id}") data.status == 204 end |
#delete_from_project(project_id, webhook_id) ⇒ Object
39 40 41 42 |
# File 'lib/tracker_api/endpoints/webhook.rb', line 39 def delete_from_project(project_id, webhook_id) data = client.delete("/projects/#{project_id}/webhooks/#{webhook_id}") data.status == 204 end |
#get(project_id, id, params = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/tracker_api/endpoints/webhook.rb', line 10 def get(project_id, id, params={}) data = client.get("/projects/#{project_id}/webhooks/#{id}", params: params).body Resources::Webhook.new({ client: client, project_id: project_id }.merge(data)) end |
#update(webhook, params = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/tracker_api/endpoints/webhook.rb', line 22 def update(webhook, params={}) raise ArgumentError, 'Valid webhook required to update.' unless webhook.instance_of?(Resources::Webhook) data = client.put("/projects/#{webhook.project_id}/webhooks/#{webhook.id}", params: params).body webhook.attributes = data webhook.clean! webhook end |