Skip to content

Commit fbe8045

Browse files
author
meow12
committed
feat(push, iam): attach user to device
Can attach user to already existing device. This allows to firstly register device and later, after user registers, attach device.
1 parent 7d93bb2 commit fbe8045

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/components/push.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,32 @@ export async function updateDevice({
157157
return response;
158158
}
159159

160+
export async function updateDeviceUser({
161+
secretKey,
162+
idOrKey,
163+
userId,
164+
}) {
165+
const response = await server.loadJson(
166+
`${Config.apiUrl}${Endpoints.PROJECT.NOTIFICATIONS.PUSH.UPDATE_DEVICE_USER(
167+
idOrKey
168+
)}`,
169+
{
170+
method: 'PATCH',
171+
headers: {
172+
'X-CM-ProjectId': Config.projectId,
173+
Authorization: `Bearer ${secretKey || Config.secretKey}`,
174+
Accept: 'application/json',
175+
'Content-Type': 'application/json',
176+
},
177+
body: JSON.stringify({
178+
userId
179+
}),
180+
}
181+
);
182+
183+
return response;
184+
}
185+
160186
export async function deleteDevice({secretKey, idOrKey}) {
161187
const response = await server.loadJson(
162188
`${Config.apiUrl}${Endpoints.PROJECT.NOTIFICATIONS.PUSH.DELETE_DEVICE(

src/routes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const CONFIG = {
5757
GET_DEVICE: (id) => `/v2/notifications/push/devices/${id}`,
5858
GET_DEVICES: '/v2/notifications/push/devices',
5959
UPDATE_DEVICE: (id) => `/v2/notifications/push/devices/${id}`,
60+
UPDATE_DEVICE_USER: (id) => `/v2/notifications/push/devices/${id}/user`,
6061
DELETE_DEVICE: (id) => `/v2/notifications/push/devices/${id}`,
6162
GET_ALL: '/v2/notifications/push',
6263
GET: (id) => `/v2/notifications/push/${id}`,

0 commit comments

Comments
 (0)