Class: Shirtsio::Status::Webhook

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/shirtsio/status.rb

Overview

Provides the ability to have status updates pushed to a URL.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize, #method_missing, #respond_to?

Constructor Details

This class inherits a constructor from Shirtsio::Endpoint

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Shirtsio::Endpoint

Class Method Details

.create(url) ⇒ Boolean

Register a new webhook URL.

Parameters:

  • url (String)

    URL status updates will be pushed to

Returns:

  • (Boolean)

    true if successful; otherwise false

See Also:



44
45
46
# File 'lib/shirtsio/status.rb', line 44

def self.create(url)
  Shirtsio.post('/webhooks/register/', { :url => url })[:success]
end

.delete(url) ⇒ Boolean

Delete a registered webhook URL.

Parameters:

  • url (String)

    URL of webhook to be removed

Returns:

  • (Boolean)

    true if successful; otherwise false

See Also:



68
69
70
# File 'lib/shirtsio/status.rb', line 68

def self.delete(url)
  Shirtsio.post('/webhooks/delete/', { :url => url })[:success]
end

.listShirtsio::Status::Webhook

Retrieve all registered webhook URLs.

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
# File 'lib/shirtsio/status.rb', line 52

def self.list
  webhooks = []
  response = new(Shirtsio.get('/webhooks/list/'))
  if response.respond_to?(:listener_url)
    response.listener_url.each do |webhook|
      webhooks << new({ :url => webhook })
    end
  end
  webhooks
end

Instance Method Details

#deleteBoolean

Delete the current webhook.

Returns:

  • (Boolean)

    true if successful; otherwise false;

See Also:



35
36
37
# File 'lib/shirtsio/status.rb', line 35

def delete
  Webhook.delete(url)
end