attlaz-client 1.13.46 → 1.13.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,4 +14,5 @@ export declare class UserEndpoint extends Endpoint {
|
|
|
14
14
|
create(user: User, password: string, invitationCode?: string | null): Promise<User>;
|
|
15
15
|
requestResetPassword(email: string): Promise<boolean>;
|
|
16
16
|
resetPassword(code: string, password: string): Promise<boolean>;
|
|
17
|
+
createWebPush(subscription: any, session: string): Promise<boolean>;
|
|
17
18
|
}
|
|
@@ -111,4 +111,23 @@ export class UserEndpoint extends Endpoint {
|
|
|
111
111
|
throw e;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
async createWebPush(subscription, session) {
|
|
115
|
+
try {
|
|
116
|
+
const url = '/webpush';
|
|
117
|
+
const parser = (raw) => ({ created: raw.requested });
|
|
118
|
+
const result = await this.requestObject(url, { subscription, session }, parser, 'POST', true);
|
|
119
|
+
const re = result.getData();
|
|
120
|
+
if (re === null) {
|
|
121
|
+
console.log('created web push wrong data', { result, parsed: re });
|
|
122
|
+
throw new Error('Unable to request web push: wrong response from API');
|
|
123
|
+
}
|
|
124
|
+
return re.created;
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
if (this.httpClient.isDebugEnabled()) {
|
|
128
|
+
console.error('Failed to create web push: ', e);
|
|
129
|
+
}
|
|
130
|
+
throw e;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
114
133
|
}
|