ab-ecosystem-cpass 0.1.0 → 1.0.0
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.
- package/README.md +127 -25
- package/dist/client.d.ts +56 -1
- package/dist/client.js +76 -30
- package/dist/client.js.map +1 -1
- package/dist/http.d.ts +8 -0
- package/dist/http.js +10 -3
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/resources/audience/contact-notes.d.ts +51 -0
- package/dist/resources/audience/contact-notes.js +70 -0
- package/dist/resources/audience/contact-notes.js.map +1 -0
- package/dist/resources/audience/contact-tags.d.ts +43 -0
- package/dist/resources/audience/contact-tags.js +60 -0
- package/dist/resources/audience/contact-tags.js.map +1 -0
- package/dist/resources/audience/contacts.d.ts +76 -0
- package/dist/resources/audience/contacts.js +103 -0
- package/dist/resources/audience/contacts.js.map +1 -0
- package/dist/resources/audience/crm-triggers.d.ts +67 -0
- package/dist/resources/audience/crm-triggers.js +86 -0
- package/dist/resources/audience/crm-triggers.js.map +1 -0
- package/dist/resources/audience/custom-fields.d.ts +54 -0
- package/dist/resources/audience/custom-fields.js +71 -0
- package/dist/resources/audience/custom-fields.js.map +1 -0
- package/dist/resources/audience/export-history.d.ts +52 -0
- package/dist/resources/audience/export-history.js +67 -0
- package/dist/resources/audience/export-history.js.map +1 -0
- package/dist/resources/audience/import-history.d.ts +51 -0
- package/dist/resources/audience/import-history.js +66 -0
- package/dist/resources/audience/import-history.js.map +1 -0
- package/dist/resources/audience/segments.d.ts +49 -0
- package/dist/resources/audience/segments.js +66 -0
- package/dist/resources/audience/segments.js.map +1 -0
- package/dist/resources/audience/webhooks.d.ts +68 -0
- package/dist/resources/audience/webhooks.js +83 -0
- package/dist/resources/audience/webhooks.js.map +1 -0
- package/dist/resources/channels/activity.d.ts +25 -0
- package/dist/resources/channels/activity.js +34 -0
- package/dist/resources/channels/activity.js.map +1 -0
- package/dist/resources/channels/billing.d.ts +46 -0
- package/dist/resources/channels/billing.js +59 -0
- package/dist/resources/channels/billing.js.map +1 -0
- package/dist/resources/channels/channels.d.ts +115 -0
- package/dist/resources/channels/channels.js +129 -0
- package/dist/resources/channels/channels.js.map +1 -0
- package/dist/resources/channels/templates.d.ts +90 -0
- package/dist/resources/channels/templates.js +109 -0
- package/dist/resources/channels/templates.js.map +1 -0
- package/dist/resources/channels/wallet.d.ts +25 -0
- package/dist/resources/channels/wallet.js +34 -0
- package/dist/resources/channels/wallet.js.map +1 -0
- package/dist/resources/channels/webhooks.d.ts +60 -0
- package/dist/resources/channels/webhooks.js +79 -0
- package/dist/resources/channels/webhooks.js.map +1 -0
- package/dist/resources/paths.d.ts +12 -0
- package/dist/resources/paths.js +17 -0
- package/dist/resources/paths.js.map +1 -0
- package/dist/types/audience.d.ts +512 -0
- package/dist/types/audience.js +3 -0
- package/dist/types/audience.js.map +1 -0
- package/dist/types/channels.d.ts +383 -0
- package/dist/types/channels.js +22 -0
- package/dist/types/channels.js.map +1 -0
- package/dist/types/common.d.ts +55 -0
- package/dist/types/common.js +8 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/contact-filter.d.ts +55 -0
- package/dist/types/contact-filter.js +11 -0
- package/dist/types/contact-filter.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/docs/audience/contact-notes.md +129 -0
- package/docs/audience/contact-tags.md +109 -0
- package/docs/audience/contacts.md +227 -0
- package/docs/audience/crm-triggers.md +240 -0
- package/docs/audience/custom-fields.md +174 -0
- package/docs/audience/exports.md +163 -0
- package/docs/audience/imports.md +161 -0
- package/docs/audience/segments.md +120 -0
- package/docs/audience/webhooks.md +167 -0
- package/docs/channels/activity.md +68 -0
- package/docs/channels/billing.md +112 -0
- package/docs/channels/channel-props.md +290 -0
- package/docs/channels/channels.md +199 -0
- package/docs/channels/templates.md +224 -0
- package/docs/channels/wallet.md +67 -0
- package/docs/channels/webhooks.md +152 -0
- package/docs/contact-filter.md +157 -0
- package/package.json +7 -3
- package/dist/resources/channels.d.ts +0 -10
- package/dist/resources/channels.js +0 -19
- package/dist/resources/channels.js.map +0 -1
- package/dist/types.d.ts +0 -70
- package/dist/types.js +0 -7
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Billing = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const base = (channelId) => `${paths_1.CHANNELS}/${(0, paths_1.seg)(channelId)}/conversations`;
|
|
6
|
+
/**
|
|
7
|
+
* Conversation billing: what each conversation on a channel cost.
|
|
8
|
+
*
|
|
9
|
+
* The endpoint answers in two shapes off one route. Without `stat` it pages
|
|
10
|
+
* through individual charges; with `stat` it returns aggregates instead, which
|
|
11
|
+
* is why `list` and `stats` are separate methods here.
|
|
12
|
+
*
|
|
13
|
+
* Pass `'all'` as the channel id to read across every channel the caller owns.
|
|
14
|
+
* `summary` then totals by currency; on a single channel it totals by message
|
|
15
|
+
* category.
|
|
16
|
+
*/
|
|
17
|
+
class Billing {
|
|
18
|
+
http;
|
|
19
|
+
constructor(http) {
|
|
20
|
+
this.http = http;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/channels/:channelId/conversations` -- offset paginated, one row
|
|
24
|
+
* per billed conversation.
|
|
25
|
+
*
|
|
26
|
+
* `search` matches the recipient identifier and the provider detail in
|
|
27
|
+
* `meta`: recipient, category, country and message id. `range` restricts to
|
|
28
|
+
* a window in unix seconds, where `0` on either end means no bound.
|
|
29
|
+
* `template`, `country` and `campaign` take arrays and are serialised to
|
|
30
|
+
* JSON by the SDK.
|
|
31
|
+
*
|
|
32
|
+
* `channelId` may be `'all'`.
|
|
33
|
+
*
|
|
34
|
+
* Scope: `channels:read`.
|
|
35
|
+
*/
|
|
36
|
+
list(channelId, query = {}) {
|
|
37
|
+
return this.http.request('GET', base(channelId), { query });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `GET /v1/channels/:channelId/conversations?stat=...` -- the same filters,
|
|
41
|
+
* aggregated instead of paged. Returns `{ data, stat }`, where each row is
|
|
42
|
+
* `{ group, totalRecords, totalDeductionAmount }`.
|
|
43
|
+
*
|
|
44
|
+
* `group` is what the totals are cut by: currency for `summary` across all
|
|
45
|
+
* channels, message category for `summary` on one channel, and the calendar
|
|
46
|
+
* date for `day_wise`.
|
|
47
|
+
*
|
|
48
|
+
* Pagination does not apply -- every group is returned.
|
|
49
|
+
*
|
|
50
|
+
* Scope: `channels:read`.
|
|
51
|
+
*/
|
|
52
|
+
stats(channelId, stat = 'summary', query = {}) {
|
|
53
|
+
return this.http.request('GET', base(channelId), {
|
|
54
|
+
query: { ...query, stat },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.Billing = Billing;
|
|
59
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/resources/channels/billing.ts"],"names":[],"mappings":";;;AAOA,oCAAyC;AAEzC,MAAM,IAAI,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,SAAS,CAAC,gBAAgB,CAAC;AAElF;;;;;;;;;;GAUG;AACH,MAAa,OAAO;IACW;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,SAAiB,EAAE,QAAqD,EAAE;QAC7E,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAwB,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CACH,SAAiB,EACjB,OAAkD,SAAS,EAC3D,QAAqD,EAAE;QAEvD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAe,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE;YAC7D,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE;SAC1B,CAAC,CAAC;IACL,CAAC;CACF;AA3CD,0BA2CC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Channel, ChannelActionResult, ChannelGetProp, ChannelPropResponse, ChannelResponse, ChannelSetProp, ListChannelsQuery, Paginated, UpdateChannelDetailsInput } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
/** Options for a property write; `raw` switches the body to file bytes. */
|
|
4
|
+
export interface SetPropOptions {
|
|
5
|
+
/** JSON body. Ignored when `raw` is given. */
|
|
6
|
+
body?: Record<string, unknown>;
|
|
7
|
+
/** Query string parameters for the property. */
|
|
8
|
+
query?: Record<string, unknown>;
|
|
9
|
+
/** File bytes, for `profile_pic`, `resumable_upload` and `upload_media`. */
|
|
10
|
+
raw?: BodyInit;
|
|
11
|
+
/** Media type of `raw`, e.g. `image/jpeg`. Required whenever `raw` is set. */
|
|
12
|
+
contentType?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Channels: the connections an account sends and receives on -- a WhatsApp
|
|
16
|
+
* number, an RCS agent, a webchat widget.
|
|
17
|
+
*
|
|
18
|
+
* A channel is provisioned by onboarding, not by this API: there is no create
|
|
19
|
+
* and no delete. `disable` retires one for good, keeping the row its billing,
|
|
20
|
+
* wallet and activity history hang off.
|
|
21
|
+
*
|
|
22
|
+
* Anything that lives with the provider rather than on the channel document --
|
|
23
|
+
* the business profile, the QR code, media uploads, number registration --
|
|
24
|
+
* moves through `getProp` and `setProp`.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Channels {
|
|
27
|
+
private readonly http;
|
|
28
|
+
constructor(http: HttpClient);
|
|
29
|
+
/**
|
|
30
|
+
* `GET /v1/channels` -- offset paginated, newest first. `search` matches the
|
|
31
|
+
* channel name and its identity (number, handle, address). `type`, `active`
|
|
32
|
+
* and `status` are quick filters.
|
|
33
|
+
*
|
|
34
|
+
* Credentials and the private auth block are stripped from every row.
|
|
35
|
+
*
|
|
36
|
+
* Scope: `channels:read`.
|
|
37
|
+
*/
|
|
38
|
+
list(query?: Partial<ListChannelsQuery>): Promise<Paginated<Channel>>;
|
|
39
|
+
/**
|
|
40
|
+
* `GET /v1/channels/:id` -- wrapped as `{ data }`, and **`{ data: {} }`
|
|
41
|
+
* rather than a 404** when nothing matches. Check for `id` on the payload
|
|
42
|
+
* before using it.
|
|
43
|
+
*
|
|
44
|
+
* Scope: `channels:read`.
|
|
45
|
+
*/
|
|
46
|
+
get(id: string): Promise<ChannelResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* `PUT /v1/channels/:id` -- renames or recolours a channel, and moves its
|
|
49
|
+
* billing currency. Returns `{ data }` with the updated channel.
|
|
50
|
+
*
|
|
51
|
+
* At least one of `name`, `color` or `currency` is required. Currency is the
|
|
52
|
+
* one field with consequences: it only moves on a WhatsApp channel whose
|
|
53
|
+
* wallet is empty, because a balance carried across a switch would be worth a
|
|
54
|
+
* different amount on the other side. Otherwise 409 `wallet_not_empty`.
|
|
55
|
+
* Asking for the currency the channel already bills in changes nothing.
|
|
56
|
+
*
|
|
57
|
+
* Scope: `channels:write`.
|
|
58
|
+
*/
|
|
59
|
+
updateDetails(id: string, input: UpdateChannelDetailsInput): Promise<ChannelResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* `POST /v1/channels/:id/disable` -- retires a channel for good. It stops
|
|
62
|
+
* delivering, drops out of every listing, and cannot be brought back.
|
|
63
|
+
*
|
|
64
|
+
* A negative wallet balance blocks it with 409 `negative_wallet_balance`:
|
|
65
|
+
* that is money owed that nothing would collect afterwards. A webchat
|
|
66
|
+
* channel has its widget subscription removed first.
|
|
67
|
+
*
|
|
68
|
+
* Scope: `channels:write`.
|
|
69
|
+
*/
|
|
70
|
+
disable(id: string): Promise<ChannelActionResult>;
|
|
71
|
+
/**
|
|
72
|
+
* `DELETE /v1/channels/:id/token` -- issues a new inbound API token and
|
|
73
|
+
* discards the old one, which stops working immediately.
|
|
74
|
+
*
|
|
75
|
+
* The new value is not in the response; read it back with
|
|
76
|
+
* `getProp(id, 'token')`.
|
|
77
|
+
*
|
|
78
|
+
* Scope: `channels:write`.
|
|
79
|
+
*/
|
|
80
|
+
rotateToken(id: string): Promise<ChannelActionResult>;
|
|
81
|
+
/**
|
|
82
|
+
* `GET /v1/channels/:id/:prop` -- reads one provider-side property. Answers
|
|
83
|
+
* `{ data, prop, channel }`, where `data` follows the property and is
|
|
84
|
+
* therefore untyped; pass a type argument when you know the shape.
|
|
85
|
+
*
|
|
86
|
+
* WhatsApp supports every property. RCS reads only `fetch_channel_queue`,
|
|
87
|
+
* `recharge_url` and `token`; anything else is 400
|
|
88
|
+
* `unsupported_channel_prop`, with the supported list in `details`.
|
|
89
|
+
*
|
|
90
|
+
* Scope: `channels:read`.
|
|
91
|
+
*/
|
|
92
|
+
getProp<T = unknown>(id: string, prop: ChannelGetProp, query?: Record<string, unknown>): Promise<ChannelPropResponse<T>>;
|
|
93
|
+
/**
|
|
94
|
+
* `POST /v1/channels/:id/:prop` -- writes one provider-side property, or runs
|
|
95
|
+
* the action it names. Answers the same `{ data, prop, channel }` envelope.
|
|
96
|
+
*
|
|
97
|
+
* `profile_pic`, `resumable_upload` and `upload_media` take the file bytes as
|
|
98
|
+
* the request body: pass them as `raw` with a `contentType`. Every other
|
|
99
|
+
* property takes JSON in `body`.
|
|
100
|
+
*
|
|
101
|
+
* ```ts
|
|
102
|
+
* await crm.channels.setProp(id, 'business_profile', {
|
|
103
|
+
* body: { about: 'We reply in minutes' },
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* await crm.channels.setProp(id, 'profile_pic', {
|
|
107
|
+
* raw: fileBytes,
|
|
108
|
+
* contentType: 'image/jpeg',
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* Scope: `channels:write`.
|
|
113
|
+
*/
|
|
114
|
+
setProp<T = unknown>(id: string, prop: ChannelSetProp, options?: SetPropOptions): Promise<ChannelPropResponse<T>>;
|
|
115
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Channels = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
/**
|
|
6
|
+
* Channels: the connections an account sends and receives on -- a WhatsApp
|
|
7
|
+
* number, an RCS agent, a webchat widget.
|
|
8
|
+
*
|
|
9
|
+
* A channel is provisioned by onboarding, not by this API: there is no create
|
|
10
|
+
* and no delete. `disable` retires one for good, keeping the row its billing,
|
|
11
|
+
* wallet and activity history hang off.
|
|
12
|
+
*
|
|
13
|
+
* Anything that lives with the provider rather than on the channel document --
|
|
14
|
+
* the business profile, the QR code, media uploads, number registration --
|
|
15
|
+
* moves through `getProp` and `setProp`.
|
|
16
|
+
*/
|
|
17
|
+
class Channels {
|
|
18
|
+
http;
|
|
19
|
+
constructor(http) {
|
|
20
|
+
this.http = http;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/channels` -- offset paginated, newest first. `search` matches the
|
|
24
|
+
* channel name and its identity (number, handle, address). `type`, `active`
|
|
25
|
+
* and `status` are quick filters.
|
|
26
|
+
*
|
|
27
|
+
* Credentials and the private auth block are stripped from every row.
|
|
28
|
+
*
|
|
29
|
+
* Scope: `channels:read`.
|
|
30
|
+
*/
|
|
31
|
+
list(query = {}) {
|
|
32
|
+
return this.http.request('GET', paths_1.CHANNELS, { query });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `GET /v1/channels/:id` -- wrapped as `{ data }`, and **`{ data: {} }`
|
|
36
|
+
* rather than a 404** when nothing matches. Check for `id` on the payload
|
|
37
|
+
* before using it.
|
|
38
|
+
*
|
|
39
|
+
* Scope: `channels:read`.
|
|
40
|
+
*/
|
|
41
|
+
get(id) {
|
|
42
|
+
return this.http.request('GET', `${paths_1.CHANNELS}/${(0, paths_1.seg)(id)}`);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* `PUT /v1/channels/:id` -- renames or recolours a channel, and moves its
|
|
46
|
+
* billing currency. Returns `{ data }` with the updated channel.
|
|
47
|
+
*
|
|
48
|
+
* At least one of `name`, `color` or `currency` is required. Currency is the
|
|
49
|
+
* one field with consequences: it only moves on a WhatsApp channel whose
|
|
50
|
+
* wallet is empty, because a balance carried across a switch would be worth a
|
|
51
|
+
* different amount on the other side. Otherwise 409 `wallet_not_empty`.
|
|
52
|
+
* Asking for the currency the channel already bills in changes nothing.
|
|
53
|
+
*
|
|
54
|
+
* Scope: `channels:write`.
|
|
55
|
+
*/
|
|
56
|
+
updateDetails(id, input) {
|
|
57
|
+
return this.http.request('PUT', `${paths_1.CHANNELS}/${(0, paths_1.seg)(id)}`, { body: input });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* `POST /v1/channels/:id/disable` -- retires a channel for good. It stops
|
|
61
|
+
* delivering, drops out of every listing, and cannot be brought back.
|
|
62
|
+
*
|
|
63
|
+
* A negative wallet balance blocks it with 409 `negative_wallet_balance`:
|
|
64
|
+
* that is money owed that nothing would collect afterwards. A webchat
|
|
65
|
+
* channel has its widget subscription removed first.
|
|
66
|
+
*
|
|
67
|
+
* Scope: `channels:write`.
|
|
68
|
+
*/
|
|
69
|
+
disable(id) {
|
|
70
|
+
return this.http.request('POST', `${paths_1.CHANNELS}/${(0, paths_1.seg)(id)}/disable`);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* `DELETE /v1/channels/:id/token` -- issues a new inbound API token and
|
|
74
|
+
* discards the old one, which stops working immediately.
|
|
75
|
+
*
|
|
76
|
+
* The new value is not in the response; read it back with
|
|
77
|
+
* `getProp(id, 'token')`.
|
|
78
|
+
*
|
|
79
|
+
* Scope: `channels:write`.
|
|
80
|
+
*/
|
|
81
|
+
rotateToken(id) {
|
|
82
|
+
return this.http.request('DELETE', `${paths_1.CHANNELS}/${(0, paths_1.seg)(id)}/token`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* `GET /v1/channels/:id/:prop` -- reads one provider-side property. Answers
|
|
86
|
+
* `{ data, prop, channel }`, where `data` follows the property and is
|
|
87
|
+
* therefore untyped; pass a type argument when you know the shape.
|
|
88
|
+
*
|
|
89
|
+
* WhatsApp supports every property. RCS reads only `fetch_channel_queue`,
|
|
90
|
+
* `recharge_url` and `token`; anything else is 400
|
|
91
|
+
* `unsupported_channel_prop`, with the supported list in `details`.
|
|
92
|
+
*
|
|
93
|
+
* Scope: `channels:read`.
|
|
94
|
+
*/
|
|
95
|
+
getProp(id, prop, query = {}) {
|
|
96
|
+
return this.http.request('GET', `${paths_1.CHANNELS}/${(0, paths_1.seg)(id)}/${(0, paths_1.seg)(prop)}`, { query });
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* `POST /v1/channels/:id/:prop` -- writes one provider-side property, or runs
|
|
100
|
+
* the action it names. Answers the same `{ data, prop, channel }` envelope.
|
|
101
|
+
*
|
|
102
|
+
* `profile_pic`, `resumable_upload` and `upload_media` take the file bytes as
|
|
103
|
+
* the request body: pass them as `raw` with a `contentType`. Every other
|
|
104
|
+
* property takes JSON in `body`.
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* await crm.channels.setProp(id, 'business_profile', {
|
|
108
|
+
* body: { about: 'We reply in minutes' },
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* await crm.channels.setProp(id, 'profile_pic', {
|
|
112
|
+
* raw: fileBytes,
|
|
113
|
+
* contentType: 'image/jpeg',
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* Scope: `channels:write`.
|
|
118
|
+
*/
|
|
119
|
+
setProp(id, prop, options = {}) {
|
|
120
|
+
return this.http.request('POST', `${paths_1.CHANNELS}/${(0, paths_1.seg)(id)}/${(0, paths_1.seg)(prop)}`, {
|
|
121
|
+
body: options.raw ? undefined : (options.body ?? {}),
|
|
122
|
+
query: options.query,
|
|
123
|
+
raw: options.raw,
|
|
124
|
+
contentType: options.contentType,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.Channels = Channels;
|
|
129
|
+
//# sourceMappingURL=channels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.js","sourceRoot":"","sources":["../../../src/resources/channels/channels.ts"],"names":[],"mappings":";;;AAYA,oCAAyC;AAczC;;;;;;;;;;;GAWG;AACH,MAAa,QAAQ;IACU;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;OAQG;IACH,IAAI,CAAC,QAAoC,EAAE;QACzC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAqB,KAAK,EAAE,gBAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAkB,KAAK,EAAE,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAU,EAAE,KAAgC;QACxD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAkB,KAAK,EAAE,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9F,CAAC;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsB,MAAM,EAAE,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,UAAU,CAAC,CAAC;IAC1F,CAAC;IAED;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAU;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsB,QAAQ,EAAE,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC1F,CAAC;IAED;;;;;;;;;;OAUG;IACH,OAAO,CAAc,EAAU,EAAE,IAAoB,EAAE,QAAiC,EAAE;QACxF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACtB,KAAK,EACL,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,IAAI,IAAA,WAAG,EAAC,IAAI,CAAC,EAAE,EACrC,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAc,EAAU,EAAE,IAAoB,EAAE,UAA0B,EAAE;QACjF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACtB,MAAM,EACN,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,IAAI,IAAA,WAAG,EAAC,IAAI,CAAC,EAAE,EACrC;YACE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;YACpD,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CACF,CAAC;IACJ,CAAC;CACF;AA1HD,4BA0HC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { CreateTemplateInput, ListTemplatesQuery, Paginated, Template, TemplateSyncResult, UpdateTemplateInput } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
/**
|
|
4
|
+
* WhatsApp message templates, per channel.
|
|
5
|
+
*
|
|
6
|
+
* A template is local until it is submitted to Meta: create it as a `draft`,
|
|
7
|
+
* or pass `applyForApproval: true` to send it straight on, at which point it
|
|
8
|
+
* becomes `pending` and Meta decides. `sync` pulls Meta's current view back
|
|
9
|
+
* over ours, which is how approvals and rejections arrive without waiting on a
|
|
10
|
+
* webhook.
|
|
11
|
+
*
|
|
12
|
+
* Every method takes the channel id first; a template id belonging to another
|
|
13
|
+
* channel is a 404 rather than a match.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Templates {
|
|
16
|
+
private readonly http;
|
|
17
|
+
constructor(http: HttpClient);
|
|
18
|
+
/**
|
|
19
|
+
* `GET /v1/channels/:channelId/templates` -- offset paginated. `search`
|
|
20
|
+
* matches the template name and sub-category; `status`, `category`,
|
|
21
|
+
* `parameterFormat` and `language` are quick filters.
|
|
22
|
+
*
|
|
23
|
+
* Scope: `channels:read`.
|
|
24
|
+
*/
|
|
25
|
+
list(channelId: string, query?: Partial<ListTemplatesQuery>): Promise<Paginated<Template>>;
|
|
26
|
+
/**
|
|
27
|
+
* `GET /v1/channels/:channelId/templates/:id`.
|
|
28
|
+
*
|
|
29
|
+
* Scope: `channels:read`.
|
|
30
|
+
*/
|
|
31
|
+
get(channelId: string, id: string): Promise<Template>;
|
|
32
|
+
/**
|
|
33
|
+
* `POST /v1/channels/:channelId/templates` -- 201 with the created template.
|
|
34
|
+
*
|
|
35
|
+
* `name` must be lowercase letters, digits and underscores -- Meta's own
|
|
36
|
+
* rule. A template is identified within a channel by name plus language, so
|
|
37
|
+
* the same name in two languages is two templates, and re-using a pair that
|
|
38
|
+
* already exists is 409 `conflict`.
|
|
39
|
+
*
|
|
40
|
+
* With `applyForApproval: false` (the default) nothing leaves the platform
|
|
41
|
+
* and the row is a `draft`. With `true`, the template goes to Meta first and
|
|
42
|
+
* the row is only written if Meta accepts it, at `status: 'pending'`; a
|
|
43
|
+
* rejection surfaces as 400 with Meta's reason and leaves nothing behind.
|
|
44
|
+
*
|
|
45
|
+
* Scope: `channels:write`.
|
|
46
|
+
*/
|
|
47
|
+
create(channelId: string, input: CreateTemplateInput): Promise<Template>;
|
|
48
|
+
/**
|
|
49
|
+
* `PATCH /v1/channels/:channelId/templates/:id` -- a partial update; at least
|
|
50
|
+
* one field is required.
|
|
51
|
+
*
|
|
52
|
+
* What may change depends on where the template is. A `draft` is fully
|
|
53
|
+
* editable. Once it is with Meta its identity is fixed, and `name`,
|
|
54
|
+
* `language`, `category`, `subCategory`, `parameterFormat`, `source` and
|
|
55
|
+
* `adDetails` are ignored -- only `components`, `payload` and `extra` still
|
|
56
|
+
* move.
|
|
57
|
+
*
|
|
58
|
+
* Nothing is sent to Meta unless you ask for it: pass `applyForApproval:
|
|
59
|
+
* true`, or a `status` other than `'draft'`. A draft is then submitted, and
|
|
60
|
+
* a template already at Meta is updated in place; either way the row comes
|
|
61
|
+
* back `pending`. A non-draft with no Meta id is 409
|
|
62
|
+
* `template_not_submitted`.
|
|
63
|
+
*
|
|
64
|
+
* Scope: `channels:write`.
|
|
65
|
+
*/
|
|
66
|
+
update(channelId: string, id: string, input: UpdateTemplateInput): Promise<Template>;
|
|
67
|
+
/**
|
|
68
|
+
* `DELETE /v1/channels/:channelId/templates/:id` -- 204, no body.
|
|
69
|
+
*
|
|
70
|
+
* A `draft` only exists here and is simply removed. Anything submitted is
|
|
71
|
+
* deleted at Meta first, so no row is kept for a template the WABA no longer
|
|
72
|
+
* has; if Meta refuses, the call fails with 400 `template_deletion_failed`
|
|
73
|
+
* and the row stays.
|
|
74
|
+
*
|
|
75
|
+
* Scope: `channels:write`.
|
|
76
|
+
*/
|
|
77
|
+
delete(channelId: string, id: string): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* `POST /v1/channels/:channelId/templates/sync` -- pulls the channel's
|
|
80
|
+
* templates from Meta and writes their current state over ours. Returns
|
|
81
|
+
* counts: `{ fetched, created, updated, skipped }`.
|
|
82
|
+
*
|
|
83
|
+
* `skipped` is templates Meta returned that are not storable here, such as
|
|
84
|
+
* one in a category this platform does not model. Note the path: `sync` is a
|
|
85
|
+
* sibling of `:id`, not a child of it.
|
|
86
|
+
*
|
|
87
|
+
* Scope: `channels:write`.
|
|
88
|
+
*/
|
|
89
|
+
sync(channelId: string): Promise<TemplateSyncResult>;
|
|
90
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Templates = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const base = (channelId) => `${paths_1.CHANNELS}/${(0, paths_1.seg)(channelId)}/templates`;
|
|
6
|
+
/**
|
|
7
|
+
* WhatsApp message templates, per channel.
|
|
8
|
+
*
|
|
9
|
+
* A template is local until it is submitted to Meta: create it as a `draft`,
|
|
10
|
+
* or pass `applyForApproval: true` to send it straight on, at which point it
|
|
11
|
+
* becomes `pending` and Meta decides. `sync` pulls Meta's current view back
|
|
12
|
+
* over ours, which is how approvals and rejections arrive without waiting on a
|
|
13
|
+
* webhook.
|
|
14
|
+
*
|
|
15
|
+
* Every method takes the channel id first; a template id belonging to another
|
|
16
|
+
* channel is a 404 rather than a match.
|
|
17
|
+
*/
|
|
18
|
+
class Templates {
|
|
19
|
+
http;
|
|
20
|
+
constructor(http) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `GET /v1/channels/:channelId/templates` -- offset paginated. `search`
|
|
25
|
+
* matches the template name and sub-category; `status`, `category`,
|
|
26
|
+
* `parameterFormat` and `language` are quick filters.
|
|
27
|
+
*
|
|
28
|
+
* Scope: `channels:read`.
|
|
29
|
+
*/
|
|
30
|
+
list(channelId, query = {}) {
|
|
31
|
+
return this.http.request('GET', base(channelId), { query });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `GET /v1/channels/:channelId/templates/:id`.
|
|
35
|
+
*
|
|
36
|
+
* Scope: `channels:read`.
|
|
37
|
+
*/
|
|
38
|
+
get(channelId, id) {
|
|
39
|
+
return this.http.request('GET', `${base(channelId)}/${(0, paths_1.seg)(id)}`);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `POST /v1/channels/:channelId/templates` -- 201 with the created template.
|
|
43
|
+
*
|
|
44
|
+
* `name` must be lowercase letters, digits and underscores -- Meta's own
|
|
45
|
+
* rule. A template is identified within a channel by name plus language, so
|
|
46
|
+
* the same name in two languages is two templates, and re-using a pair that
|
|
47
|
+
* already exists is 409 `conflict`.
|
|
48
|
+
*
|
|
49
|
+
* With `applyForApproval: false` (the default) nothing leaves the platform
|
|
50
|
+
* and the row is a `draft`. With `true`, the template goes to Meta first and
|
|
51
|
+
* the row is only written if Meta accepts it, at `status: 'pending'`; a
|
|
52
|
+
* rejection surfaces as 400 with Meta's reason and leaves nothing behind.
|
|
53
|
+
*
|
|
54
|
+
* Scope: `channels:write`.
|
|
55
|
+
*/
|
|
56
|
+
create(channelId, input) {
|
|
57
|
+
return this.http.request('POST', base(channelId), { body: input });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* `PATCH /v1/channels/:channelId/templates/:id` -- a partial update; at least
|
|
61
|
+
* one field is required.
|
|
62
|
+
*
|
|
63
|
+
* What may change depends on where the template is. A `draft` is fully
|
|
64
|
+
* editable. Once it is with Meta its identity is fixed, and `name`,
|
|
65
|
+
* `language`, `category`, `subCategory`, `parameterFormat`, `source` and
|
|
66
|
+
* `adDetails` are ignored -- only `components`, `payload` and `extra` still
|
|
67
|
+
* move.
|
|
68
|
+
*
|
|
69
|
+
* Nothing is sent to Meta unless you ask for it: pass `applyForApproval:
|
|
70
|
+
* true`, or a `status` other than `'draft'`. A draft is then submitted, and
|
|
71
|
+
* a template already at Meta is updated in place; either way the row comes
|
|
72
|
+
* back `pending`. A non-draft with no Meta id is 409
|
|
73
|
+
* `template_not_submitted`.
|
|
74
|
+
*
|
|
75
|
+
* Scope: `channels:write`.
|
|
76
|
+
*/
|
|
77
|
+
update(channelId, id, input) {
|
|
78
|
+
return this.http.request('PATCH', `${base(channelId)}/${(0, paths_1.seg)(id)}`, { body: input });
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* `DELETE /v1/channels/:channelId/templates/:id` -- 204, no body.
|
|
82
|
+
*
|
|
83
|
+
* A `draft` only exists here and is simply removed. Anything submitted is
|
|
84
|
+
* deleted at Meta first, so no row is kept for a template the WABA no longer
|
|
85
|
+
* has; if Meta refuses, the call fails with 400 `template_deletion_failed`
|
|
86
|
+
* and the row stays.
|
|
87
|
+
*
|
|
88
|
+
* Scope: `channels:write`.
|
|
89
|
+
*/
|
|
90
|
+
delete(channelId, id) {
|
|
91
|
+
return this.http.request('DELETE', `${base(channelId)}/${(0, paths_1.seg)(id)}`);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* `POST /v1/channels/:channelId/templates/sync` -- pulls the channel's
|
|
95
|
+
* templates from Meta and writes their current state over ours. Returns
|
|
96
|
+
* counts: `{ fetched, created, updated, skipped }`.
|
|
97
|
+
*
|
|
98
|
+
* `skipped` is templates Meta returned that are not storable here, such as
|
|
99
|
+
* one in a category this platform does not model. Note the path: `sync` is a
|
|
100
|
+
* sibling of `:id`, not a child of it.
|
|
101
|
+
*
|
|
102
|
+
* Scope: `channels:write`.
|
|
103
|
+
*/
|
|
104
|
+
sync(channelId) {
|
|
105
|
+
return this.http.request('POST', `${base(channelId)}/sync`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.Templates = Templates;
|
|
109
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/resources/channels/templates.ts"],"names":[],"mappings":";;;AASA,oCAAyC;AAEzC,MAAM,IAAI,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,SAAS,CAAC,YAAY,CAAC;AAE9E;;;;;;;;;;;GAWG;AACH,MAAa,SAAS;IACS;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;OAMG;IACH,IAAI,CAAC,SAAiB,EAAE,QAAqC,EAAE;QAC7D,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsB,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACnF,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,SAAiB,EAAE,EAAU;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAW,KAAK,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,SAAiB,EAAE,KAA0B;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAW,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,SAAiB,EAAE,EAAU,EAAE,KAA0B;QAC9D,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAW,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAChG,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,SAAiB,EAAE,EAAU;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CAAC,SAAiB;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAqB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAClF,CAAC;CACF;AA5FD,8BA4FC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ListWalletLogsQuery, Paginated, WalletLog } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
/**
|
|
4
|
+
* Channel wallet ledger: every credit and debit against a channel's balance,
|
|
5
|
+
* with the balance before and after each movement.
|
|
6
|
+
*
|
|
7
|
+
* Read-only. Money moves through top-ups and through conversation billing, not
|
|
8
|
+
* through this API. Amounts here are the raw stored values -- ten-thousandths
|
|
9
|
+
* of a currency unit -- unlike `channel.wallet.balance`, which is already
|
|
10
|
+
* divided down for display.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Wallet {
|
|
13
|
+
private readonly http;
|
|
14
|
+
constructor(http: HttpClient);
|
|
15
|
+
/**
|
|
16
|
+
* `GET /v1/channels/:channelId/wallet` -- offset paginated, newest first.
|
|
17
|
+
*
|
|
18
|
+
* `search` matches the note, the category and the status. `type` narrows to
|
|
19
|
+
* credits or debits; `range` restricts to a window in unix seconds, where
|
|
20
|
+
* `0` on either end means no bound.
|
|
21
|
+
*
|
|
22
|
+
* Scope: `channels:read`.
|
|
23
|
+
*/
|
|
24
|
+
list(channelId: string, query?: Partial<ListWalletLogsQuery>): Promise<Paginated<WalletLog>>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Wallet = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const base = (channelId) => `${paths_1.CHANNELS}/${(0, paths_1.seg)(channelId)}/wallet`;
|
|
6
|
+
/**
|
|
7
|
+
* Channel wallet ledger: every credit and debit against a channel's balance,
|
|
8
|
+
* with the balance before and after each movement.
|
|
9
|
+
*
|
|
10
|
+
* Read-only. Money moves through top-ups and through conversation billing, not
|
|
11
|
+
* through this API. Amounts here are the raw stored values -- ten-thousandths
|
|
12
|
+
* of a currency unit -- unlike `channel.wallet.balance`, which is already
|
|
13
|
+
* divided down for display.
|
|
14
|
+
*/
|
|
15
|
+
class Wallet {
|
|
16
|
+
http;
|
|
17
|
+
constructor(http) {
|
|
18
|
+
this.http = http;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* `GET /v1/channels/:channelId/wallet` -- offset paginated, newest first.
|
|
22
|
+
*
|
|
23
|
+
* `search` matches the note, the category and the status. `type` narrows to
|
|
24
|
+
* credits or debits; `range` restricts to a window in unix seconds, where
|
|
25
|
+
* `0` on either end means no bound.
|
|
26
|
+
*
|
|
27
|
+
* Scope: `channels:read`.
|
|
28
|
+
*/
|
|
29
|
+
list(channelId, query = {}) {
|
|
30
|
+
return this.http.request('GET', base(channelId), { query });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Wallet = Wallet;
|
|
34
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/resources/channels/wallet.ts"],"names":[],"mappings":";;;AAEA,oCAAyC;AAEzC,MAAM,IAAI,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,GAAG,gBAAQ,IAAI,IAAA,WAAG,EAAC,SAAS,CAAC,SAAS,CAAC;AAE3E;;;;;;;;GAQG;AACH,MAAa,MAAM;IACY;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;OAQG;IACH,IAAI,CAAC,SAAiB,EAAE,QAAsC,EAAE;QAC9D,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAuB,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACpF,CAAC;CACF;AAfD,wBAeC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ChannelWebhook, CreateChannelWebhookInput, ListChannelWebhooksQuery, Paginated, UpdateChannelWebhookInput } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
/**
|
|
4
|
+
* Channel webhooks: where a channel's message traffic is delivered.
|
|
5
|
+
*
|
|
6
|
+
* These carry conversation events -- `incoming`, `sent`, `delivered`, `read`,
|
|
7
|
+
* `failed` -- plus the account-level notices Meta sends about templates, the
|
|
8
|
+
* phone number and the WABA. Distinct from `crm.webhooks`, which carries
|
|
9
|
+
* contact changes from the audience module.
|
|
10
|
+
*
|
|
11
|
+
* Each webhook subscribes to a set of events; several webhooks may watch the
|
|
12
|
+
* same channel, and each gets its own copy.
|
|
13
|
+
*
|
|
14
|
+
* `meta` on a stored webhook is an audit trail -- who created or last changed
|
|
15
|
+
* it and from where -- filled in by the service from the caller's identity and
|
|
16
|
+
* IP. It is never accepted on a write.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ChannelWebhooks {
|
|
19
|
+
private readonly http;
|
|
20
|
+
constructor(http: HttpClient);
|
|
21
|
+
/**
|
|
22
|
+
* `GET /v1/channels/:channelId/webhooks` -- offset paginated. `search`
|
|
23
|
+
* matches the title and the URL; `active` and `event` are quick filters,
|
|
24
|
+
* where `event` finds the webhooks subscribed to that one event.
|
|
25
|
+
*
|
|
26
|
+
* Scope: `channels:read`.
|
|
27
|
+
*/
|
|
28
|
+
list(channelId: string, query?: Partial<ListChannelWebhooksQuery>): Promise<Paginated<ChannelWebhook>>;
|
|
29
|
+
/**
|
|
30
|
+
* `GET /v1/channels/:channelId/webhooks/:id`.
|
|
31
|
+
*
|
|
32
|
+
* Scope: `channels:read`.
|
|
33
|
+
*/
|
|
34
|
+
get(channelId: string, id: string): Promise<ChannelWebhook>;
|
|
35
|
+
/**
|
|
36
|
+
* `POST /v1/channels/:channelId/webhooks` -- 201 with the created webhook.
|
|
37
|
+
*
|
|
38
|
+
* Only `url` and `events` are required; the title defaults to
|
|
39
|
+
* `'CRM Channel Webhook'` and the webhook starts active. Webhooks created
|
|
40
|
+
* through the API are recorded with `meta.source: 'API'`.
|
|
41
|
+
*
|
|
42
|
+
* Scope: `channels:write`.
|
|
43
|
+
*/
|
|
44
|
+
create(channelId: string, input: CreateChannelWebhookInput): Promise<ChannelWebhook>;
|
|
45
|
+
/**
|
|
46
|
+
* `PATCH /v1/channels/:channelId/webhooks/:id` -- a partial update; at least
|
|
47
|
+
* one field is required. `events` replaces the subscription list rather than
|
|
48
|
+
* adding to it. Pause delivery with `{ active: false }`.
|
|
49
|
+
*
|
|
50
|
+
* Scope: `channels:write`.
|
|
51
|
+
*/
|
|
52
|
+
update(channelId: string, id: string, input: UpdateChannelWebhookInput): Promise<ChannelWebhook>;
|
|
53
|
+
/**
|
|
54
|
+
* `DELETE /v1/channels/:channelId/webhooks/:id` -- 204. Delivery stops
|
|
55
|
+
* immediately.
|
|
56
|
+
*
|
|
57
|
+
* Scope: `channels:write`.
|
|
58
|
+
*/
|
|
59
|
+
delete(channelId: string, id: string): Promise<void>;
|
|
60
|
+
}
|