Class: ContextIO::Connection
- Inherits:
-
Object
- Object
- ContextIO::Connection
- Defined in:
- lib/last-resort/contextio.rb
Overview
Defines the API interface connection to ContextIO.
Constant Summary collapse
- VERSION =
"2.0"
Instance Method Summary collapse
- #createWebhook(accountId, parameters) ⇒ Object
- #deleteAllWebhooks(accountId) ⇒ Object
- #deleteWebhook(accountId, webhook_id) ⇒ Object
-
#initialize(key = '', secret = '', server = 'https://api.context.io') ⇒ Connection
constructor
A new instance of Connection.
- #listWebhooks(accountId) ⇒ Object
Constructor Details
#initialize(key = '', secret = '', server = 'https://api.context.io') ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 |
# File 'lib/last-resort/contextio.rb', line 10 def initialize(key='', secret='', server='https://api.context.io') @consumer = OAuth::Consumer.new(key, secret, {:site => server, :scheme => :header}) @token = OAuth::AccessToken.new @consumer end |
Instance Method Details
#createWebhook(accountId, parameters) ⇒ Object
15 16 17 |
# File 'lib/last-resort/contextio.rb', line 15 def createWebhook(accountId, parameters) post accountId, 'webhooks', parameters end |
#deleteAllWebhooks(accountId) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/last-resort/contextio.rb', line 27 def deleteAllWebhooks(accountId) webhooks = listWebhooks(accountId) webhooks.each do |webhook| deleteWebhook accountId, webhook["webhook_id"] end end |
#deleteWebhook(accountId, webhook_id) ⇒ Object
23 24 25 |
# File 'lib/last-resort/contextio.rb', line 23 def deleteWebhook(accountId, webhook_id) delete accountId, "webhooks/#{webhook_id}" end |
#listWebhooks(accountId) ⇒ Object
19 20 21 |
# File 'lib/last-resort/contextio.rb', line 19 def listWebhooks(accountId) get accountId, 'webhooks' end |