public class WebhookServiceImpl extends StravaServiceImpl implements WebhookService
api, requestRate, requestRateDaily| Modifier | Constructor and Description |
|---|---|
protected |
WebhookServiceImpl(Token token) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearCache()
Clear any and all cached data entries
|
StravaEventSubscription |
createSubscription(StravaEventSubscription subscription,
String verifyToken)
Creates a subscription to an allowed event
|
CompletableFuture<StravaEventSubscription> |
createSubscriptionAsync(StravaEventSubscription subscription,
String verifyToken)
Creates a subscription to an allowed event
|
void |
deleteSubscription(Integer subscriptionId)
This request is used to unsubscribe from events.
|
CompletableFuture<Void> |
deleteSubscriptionAsync(Integer subscriptionId)
This request is used to unsubscribe from events.
|
static WebhookService |
instance(Token token) |
List<StravaEventSubscription> |
listSubscriptions()
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
|
CompletableFuture<List<StravaEventSubscription>> |
listSubscriptionsAsync()
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
|
accessTokenIsValid, future, getToken, requestRateDailyPercentage, requestRatePercentageprotected WebhookServiceImpl(Token token)
token - The access token to use in calls to the APIpublic static WebhookService instance(Token token)
token - The access token to associate with the servicepublic void clearCache()
StravaServiceClear any and all cached data entries
Primarily used when revoking/deauthorising a token so that there are no entries remaining that are associated with the token that could mistakenly get returned
clearCache in interface StravaServiceStravaService.clearCache()public StravaEventSubscription createSubscription(StravaEventSubscription subscription, String verifyToken)
WebhookServiceCreates a subscription to an allowed event
The application must have permission to make use of the webhook API. Access can be requested by contacting developers -at- strava.com.
The above request will send a GET request to callback url to verify existence
Your response to this GET request must contain the hub.challenge token, ie. 15f7d1a91c1f40f8a748fd134752feb3 and have a response code of 200.
On callback verification we respond to the original POST with the created subscription. If there is an error, a response containing the reason for failure will be returned.
When an event occurs that corresponds to a push subscription, a POST request will be made to the callback url defined in the subscription. The payload will contain the object and aspect types affected, as well as information about the object and its owner if applicable.
You should acknowledge the POST within a 2 second timeout–if you need to do more processing of the received information, you can do so in an asynchronous task.
Additional metadata about the object is not included, and an application must decide how or if it wants to fetch updated data. For example, you may decide only to fetch new data for specific users, or after a certain number of activities have been uploaded.
createSubscription in interface WebhookServicesubscription - The subscription to create on StravaverifyToken - The verification token Strava should use when validating your endpointWebhookService.createSubscription(javastrava.api.v3.model.webhook.StravaEventSubscription, String)public CompletableFuture<StravaEventSubscription> createSubscriptionAsync(StravaEventSubscription subscription, String verifyToken)
WebhookServiceCreates a subscription to an allowed event
The application must have permission to make use of the webhook API. Access can be requested by contacting developers -at- strava.com.
The above request will send a GET request to callback url to verify existence
Your response to this GET request must contain the hub.challenge token, ie. 15f7d1a91c1f40f8a748fd134752feb3 and have a response code of 200.
On callback verification Strava responds to the original POST with the created subscription. If there is an error, a response containing the reason for failure will be returned.
When an event occurs that corresponds to a push subscription, a POST request will be made to the callback url defined in the subscription. The payload will contain the object and aspect types affected, as well as information about the object and its owner if applicable.
You should acknowledge the POST within a 2 second timeout–if you need to do more processing of the received information, you can do so in an asynchronous task.
Additional metadata about the object is not included, and an application must decide how or if it wants to fetch updated data. For example, you may decide only to fetch new data for specific users, or after a certain number of activities have been uploaded.
createSubscriptionAsync in interface WebhookServicesubscription - The subscription to create on StravaverifyToken - The verification token Strava should use when validating your endpointWebhookService.createSubscriptionAsync(javastrava.api.v3.model.webhook.StravaEventSubscription, String)public void deleteSubscription(Integer subscriptionId)
WebhookServiceThis request is used to unsubscribe from events.
If the delete is successful, a 204 will be returned. Otherwise, an error will be returned containing the reason for a failure.
deleteSubscription in interface WebhookServicesubscriptionId - Unique identifier of the subscription to be deletedWebhookService.deleteSubscription(java.lang.Integer)public CompletableFuture<Void> deleteSubscriptionAsync(Integer subscriptionId)
WebhookServiceThis request is used to unsubscribe from events.
If the delete is successful, a 204 will be returned. Otherwise, an error will be returned containing the reason for a failure.
deleteSubscriptionAsync in interface WebhookServicesubscriptionId - Unique identifier of the subscription to be deletedWebhookService.deleteSubscriptionAsync(java.lang.Integer)public List<StravaEventSubscription> listSubscriptions()
WebhookServiceThis request is used to retrieve the summary representations of the subscriptions in place for the current application.
listSubscriptions in interface WebhookServiceWebhookService.listSubscriptions()public CompletableFuture<List<StravaEventSubscription>> listSubscriptionsAsync()
WebhookServiceThis request is used to retrieve the summary representations of the subscriptions in place for the current application.
listSubscriptionsAsync in interface WebhookServiceWebhookService.listSubscriptionsAsync()Copyright © 2016 Dan Shannon. All rights reserved.