Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebHook transportType support for subscriptions? #53

Open
caselas opened this issue Feb 4, 2017 · 3 comments
Open

Add WebHook transportType support for subscriptions? #53

caselas opened this issue Feb 4, 2017 · 3 comments

Comments

@caselas
Copy link

caselas commented Feb 4, 2017

Is this something of interest? I wanted to check to see if there is a specific reason the ruby sdk doesn't currently support it, before I take the time to open a PR.

Thanks.

@grokify grokify self-assigned this Feb 7, 2017
@grokify
Copy link
Owner

grokify commented Feb 7, 2017

There's no specific reason it doesn't include a helper for webhooks yet and a helper can be added. There are two parts to webhook support today:

  • Creating a webhook is a simple REST API call. The SDK has wrapper methods for some, but not all or most API calls.
  • Renewing a webhook involves subscribing to a specific eventFilter, listening to the expiration warning event and then refreshing the webhook.

I've labeled this as an enhancement request. Feel free to send a PR.

@grokify grokify changed the title [question] Add WebHook transportType support for subscriptions? Add WebHook transportType support for subscriptions? Feb 7, 2017
@grokify grokify removed their assignment Feb 7, 2017
@grokify
Copy link
Owner

grokify commented Feb 8, 2017

Here is some information on creating the webhook using the SDK. This is based on the webhook documentation.

client.http.post do |req|
  req.url 'subscription'
  req.headers['Content-Type'] = 'application/json'
  req.body = {
    "eventFilters": [
      "/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true&sipData=true",
      "/restapi/v1.0/account/~/extension/~/message-store",
      "/restapi/v1.0/account/~/extension/~/presence/line",
      "/restapi/v1.0/account/~/extension"
    ],
    "deliveryMode": {
      "transportType": "WebHook",
      "address": "https://myapp.ngrok.io/hook?auth_token=MySecureToken"
    }
  }
end

To enable renewing of the webhook, you should subscribe to the renewal event filter:

/restapi/v1.0/subscription/~?threshold=XXX&interval=YYY

Then resubscribe when you receive the renewal event.

See the webhook renewal documentation for more info.

@caselas
Copy link
Author

caselas commented Feb 8, 2017

@grokify thanks for the quick response(s) on this.

Your example above is what I'm doing now, which of course works just fine. I'll find a moment to open a PR to add this functionality to the SDK, just to clean up the implementation for consumers of the SDK.

While I have your attention, one quick question: When creating a subscription, I believe the response includes an expireIn key (I don't recall the actual name of the key at the moment) with the value being number of seconds until the webhook subscription expires. Is this reliable? So I could potentially schedule a renewal off of that rather than subscribing to the renewal event filter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants