Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.

Commit

Permalink
Added methods for reactions (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkonst authored and rogaldh committed Jan 16, 2020
1 parent be03b31 commit 60a024c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ulms/events",
"version": "0.1.2",
"version": "0.2.0",
"description": "JavaScript API-client for uLMS Events service",
"files": [
"es",
Expand Down
28 changes: 28 additions & 0 deletions src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,34 @@ export class HttpEventsResource {
)
)
}
createReaction (audience, roomId, type, eventId, data, params = {}) {
const { randomId } = params

return this.tokenProvider.getToken()
.then((token) =>
this.httpClient.post(
`${this.baseUrl}/${audience}/rooms/${roomId}/events/${type}/${eventId}/reaction`,
data,
{
headers: HttpEventsResource._headers(token, { randomId })
}
)
)
}
deleteReaction (audience, roomId, type, eventId, data, params = {}) {
const { randomId } = params

return this.tokenProvider.getToken()
.then((token) =>
this.httpClient.delete(
`${this.baseUrl}/${audience}/rooms/${roomId}/events/${type}/${eventId}/reaction`,
data,
{
headers: HttpEventsResource._headers(token, { randomId })
}
)
)
}
createNotification (audience, roomId, type, data, params = {}) {
const { randomId } = params

Expand Down
5 changes: 3 additions & 2 deletions src/http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ export class FetchHttpClient {
})
.then(FetchHttpClient._processResponse)
}
delete (url, config) {
delete (url, data, config) {
return fetch(url, {
method: 'DELETE',
headers: config.headers
headers: config.headers,
body: JSON.stringify(data)
})
.then(FetchHttpClient._processResponse)
}
Expand Down

0 comments on commit 60a024c

Please sign in to comment.