1 | import { __decorate } from "tslib";
|
2 | import { _SPCollection, spInvokableFactory, _SPInstance, } from "../spqueryable.js";
|
3 | import { body } from "@pnp/queryable";
|
4 | import { defaultPath } from "../decorators.js";
|
5 | import { spPost, spPatch, spDelete } from "../operations.js";
|
6 | let _Subscriptions = class _Subscriptions extends _SPCollection {
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 | getById(subscriptionId) {
|
13 | return Subscription(this).concat(`('${subscriptionId}')`);
|
14 | }
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | async add(notificationUrl, expirationDate, clientState) {
|
23 | const postBody = {
|
24 | "expirationDateTime": expirationDate,
|
25 | "notificationUrl": notificationUrl,
|
26 | "resource": this.toUrl(),
|
27 | };
|
28 | if (clientState) {
|
29 | postBody.clientState = clientState;
|
30 | }
|
31 | const data = await spPost(this, body(postBody));
|
32 | return { data, subscription: this.getById(data.id) };
|
33 | }
|
34 | };
|
35 | _Subscriptions = __decorate([
|
36 | defaultPath("subscriptions")
|
37 | ], _Subscriptions);
|
38 | export { _Subscriptions };
|
39 | export const Subscriptions = spInvokableFactory(_Subscriptions);
|
40 | export class _Subscription extends _SPInstance {
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | async update(expirationDate, notificationUrl, clientState) {
|
49 | const postBody = {};
|
50 | if (expirationDate) {
|
51 | postBody.expirationDateTime = expirationDate;
|
52 | }
|
53 | if (notificationUrl) {
|
54 | postBody.notificationUrl = notificationUrl;
|
55 | }
|
56 | if (clientState) {
|
57 | postBody.clientState = clientState;
|
58 | }
|
59 | const data = await spPatch(this, body(postBody));
|
60 | return { data, subscription: this };
|
61 | }
|
62 | |
63 |
|
64 |
|
65 |
|
66 | delete() {
|
67 | return spDelete(this);
|
68 | }
|
69 | }
|
70 | export const Subscription = spInvokableFactory(_Subscription);
|
71 |
|
\ | No newline at end of file |