Skip to content

Commit

Permalink
v10.2.0 add delete subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
iamruinous committed Aug 29, 2017
1 parent e2da469 commit 386176b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@ meshbluHttp.deleteSubscription(
)
```

### Delete Subscriptions
| Parameter | Type | Required| Description |
| ----------| -------| --------| -------------------------------------|
| options | object | yes    | an object containing three keys: subscriberUuid, emitterUuid, and type. Type and emitterUuid are optional and will be used to filter the subscriptions to delete. |
| callback |function| yes | a function that returns error and response |
------------------------------------------
```javascript
meshbluHttp.deleteSubscriptions(
{
subscriberUuid: 'fancy_uuid',
emitterUuid: 'another_fancy_uuid',
type: 'fancy_type'
},
function(error, response){
// code goes here
}
)
```

### Device
| Parameter | Type | Required| Description |
| ----------| -------| --------| -------------------------------------|
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meshblu-http",
"version": "10.1.0",
"version": "10.2.0",
"description": "Meshblu HTTP API",
"main": "dist/index.js",
"scripts": {
Expand Down
13 changes: 13 additions & 0 deletions src/meshblu-http.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ class MeshbluHttp
debug 'createSubscription', error, JSON.stringify(body)
@_handleResponse {error, response, body}, callback

deleteSubscriptions: ({subscriberUuid, emitterUuid, type}, rest...) =>
[callback] = rest
[metadata, callback] = rest if _.isPlainObject callback

url = "/v2/devices/#{subscriberUuid}/subscriptions"
options = @_getDefaultRequestOptions()
options.headers = _.extend {}, @_getMetadataHeaders(metadata), options.headers
options.json = { emitterUuid, type }

@request.delete url, options, (error, response, body) =>
debug 'deleteSubscriptions', error, JSON.stringify(body)
@_handleResponse {error, response, body}, callback

deleteSubscription: ({subscriberUuid, emitterUuid, type}, rest...) =>
[callback] = rest
[metadata, callback] = rest if _.isPlainObject callback
Expand Down

0 comments on commit 386176b

Please sign in to comment.