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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContactNotes = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const base = (contactId) => `${paths_1.AUDIENCE}/contacts/${(0, paths_1.seg)(contactId)}/notes`;
|
|
6
|
+
/**
|
|
7
|
+
* Internal notes on a contact: free text, attachments, and team members
|
|
8
|
+
* mentioned in them. Notes are never shown to the contact.
|
|
9
|
+
*
|
|
10
|
+
* Every method takes the contact id first -- notes are addressed under their
|
|
11
|
+
* contact, and a note id from another contact is a 404 rather than a match.
|
|
12
|
+
*
|
|
13
|
+
* NOTE: these routes are currently commented out in the audience service's
|
|
14
|
+
* `routes.ts`, so they answer 404 until that line is restored. The contract and
|
|
15
|
+
* the service behind them are complete.
|
|
16
|
+
*/
|
|
17
|
+
class ContactNotes {
|
|
18
|
+
http;
|
|
19
|
+
constructor(http) {
|
|
20
|
+
this.http = http;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/audience/contacts/:contactId/notes` -- cursor paginated, newest
|
|
24
|
+
* first. Notes are appended, so an offset would shift under a caller
|
|
25
|
+
* mid-walk; page with `cursor` from the previous response's `nextCursor`.
|
|
26
|
+
*
|
|
27
|
+
* Scope: `contacts:read`.
|
|
28
|
+
*/
|
|
29
|
+
list(contactId, query = {}) {
|
|
30
|
+
return this.http.request('GET', base(contactId), { query });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* `GET /v1/audience/contacts/:contactId/notes/:noteId`.
|
|
34
|
+
*
|
|
35
|
+
* Scope: `contacts:read`.
|
|
36
|
+
*/
|
|
37
|
+
get(contactId, noteId) {
|
|
38
|
+
return this.http.request('GET', `${base(contactId)}/${(0, paths_1.seg)(noteId)}`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* `POST /v1/audience/contacts/:contactId/notes` -- 201 with the created note.
|
|
42
|
+
*
|
|
43
|
+
* Scope: `contacts:write`.
|
|
44
|
+
*/
|
|
45
|
+
create(contactId, input) {
|
|
46
|
+
return this.http.request('POST', base(contactId), { body: input });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `PATCH /v1/audience/contacts/:contactId/notes/:noteId` -- a partial update.
|
|
50
|
+
* `attachments` and `mentions` replace their stored value rather than
|
|
51
|
+
* appending to it.
|
|
52
|
+
*
|
|
53
|
+
* Scope: `contacts:write`.
|
|
54
|
+
*/
|
|
55
|
+
update(contactId, noteId, input) {
|
|
56
|
+
return this.http.request('PATCH', `${base(contactId)}/${(0, paths_1.seg)(noteId)}`, {
|
|
57
|
+
body: input,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* `DELETE /v1/audience/contacts/:contactId/notes/:noteId` -- 204, no body.
|
|
62
|
+
*
|
|
63
|
+
* Scope: `contacts:write`.
|
|
64
|
+
*/
|
|
65
|
+
delete(contactId, noteId) {
|
|
66
|
+
return this.http.request('DELETE', `${base(contactId)}/${(0, paths_1.seg)(noteId)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ContactNotes = ContactNotes;
|
|
70
|
+
//# sourceMappingURL=contact-notes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-notes.js","sourceRoot":"","sources":["../../../src/resources/audience/contact-notes.ts"],"names":[],"mappings":";;;AAQA,oCAAyC;AAEzC,MAAM,IAAI,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,GAAG,gBAAQ,aAAa,IAAA,WAAG,EAAC,SAAS,CAAC,QAAQ,CAAC;AAEnF;;;;;;;;;;GAUG;AACH,MAAa,YAAY;IACM;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;OAMG;IACH,IAAI,CAAC,SAAiB,EAAE,QAAwC,EAAE;QAChE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACjF,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,SAAiB,EAAE,MAAc;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc,KAAK,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAA,WAAG,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAiB,EAAE,KAA6B;QACrD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,SAAiB,EAAE,MAAc,EAAE,KAA6B;QACrE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAA,WAAG,EAAC,MAAM,CAAC,EAAE,EAAE;YAClF,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAiB,EAAE,MAAc;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAA,WAAG,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC;CACF;AArDD,oCAqDC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ContactTag, CreateContactTagInput, ListContactTagsQuery, Paginated, UpdateContactTagInput } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
/**
|
|
4
|
+
* Contact tags: the labels a contact can carry. A tag is its own resource --
|
|
5
|
+
* `contacts.update` takes tag ids, and a contact reads back with the full tag
|
|
6
|
+
* documents resolved into `contact.tags`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ContactTags {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: HttpClient);
|
|
11
|
+
/**
|
|
12
|
+
* `GET /v1/audience/contact-tags` -- offset paginated. `search` matches the
|
|
13
|
+
* tag name.
|
|
14
|
+
*
|
|
15
|
+
* Scope: `contact_tags:read`.
|
|
16
|
+
*/
|
|
17
|
+
list(query?: Partial<ListContactTagsQuery>): Promise<Paginated<ContactTag>>;
|
|
18
|
+
/**
|
|
19
|
+
* `GET /v1/audience/contact-tags/:id`. 404 `not_found` if the tag is not the
|
|
20
|
+
* caller's.
|
|
21
|
+
*
|
|
22
|
+
* Scope: `contact_tags:read`.
|
|
23
|
+
*/
|
|
24
|
+
get(id: string): Promise<ContactTag>;
|
|
25
|
+
/**
|
|
26
|
+
* `POST /v1/audience/contact-tags` -- 201 with the created tag.
|
|
27
|
+
*
|
|
28
|
+
* Scope: `contact_tags:write`.
|
|
29
|
+
*/
|
|
30
|
+
create(input: CreateContactTagInput): Promise<ContactTag>;
|
|
31
|
+
/**
|
|
32
|
+
* `PATCH /v1/audience/contact-tags/:id` -- a partial update.
|
|
33
|
+
*
|
|
34
|
+
* Scope: `contact_tags:write`.
|
|
35
|
+
*/
|
|
36
|
+
update(id: string, input: UpdateContactTagInput): Promise<ContactTag>;
|
|
37
|
+
/**
|
|
38
|
+
* `DELETE /v1/audience/contact-tags/:id` -- 204, no body.
|
|
39
|
+
*
|
|
40
|
+
* Scope: `contact_tags:write`.
|
|
41
|
+
*/
|
|
42
|
+
delete(id: string): Promise<void>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContactTags = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const BASE = `${paths_1.AUDIENCE}/contact-tags`;
|
|
6
|
+
/**
|
|
7
|
+
* Contact tags: the labels a contact can carry. A tag is its own resource --
|
|
8
|
+
* `contacts.update` takes tag ids, and a contact reads back with the full tag
|
|
9
|
+
* documents resolved into `contact.tags`.
|
|
10
|
+
*/
|
|
11
|
+
class ContactTags {
|
|
12
|
+
http;
|
|
13
|
+
constructor(http) {
|
|
14
|
+
this.http = http;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `GET /v1/audience/contact-tags` -- offset paginated. `search` matches the
|
|
18
|
+
* tag name.
|
|
19
|
+
*
|
|
20
|
+
* Scope: `contact_tags:read`.
|
|
21
|
+
*/
|
|
22
|
+
list(query = {}) {
|
|
23
|
+
return this.http.request('GET', BASE, { query });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `GET /v1/audience/contact-tags/:id`. 404 `not_found` if the tag is not the
|
|
27
|
+
* caller's.
|
|
28
|
+
*
|
|
29
|
+
* Scope: `contact_tags:read`.
|
|
30
|
+
*/
|
|
31
|
+
get(id) {
|
|
32
|
+
return this.http.request('GET', `${BASE}/${(0, paths_1.seg)(id)}`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `POST /v1/audience/contact-tags` -- 201 with the created tag.
|
|
36
|
+
*
|
|
37
|
+
* Scope: `contact_tags:write`.
|
|
38
|
+
*/
|
|
39
|
+
create(input) {
|
|
40
|
+
return this.http.request('POST', BASE, { body: input });
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `PATCH /v1/audience/contact-tags/:id` -- a partial update.
|
|
44
|
+
*
|
|
45
|
+
* Scope: `contact_tags:write`.
|
|
46
|
+
*/
|
|
47
|
+
update(id, input) {
|
|
48
|
+
return this.http.request('PATCH', `${BASE}/${(0, paths_1.seg)(id)}`, { body: input });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `DELETE /v1/audience/contact-tags/:id` -- 204, no body.
|
|
52
|
+
*
|
|
53
|
+
* Scope: `contact_tags:write`.
|
|
54
|
+
*/
|
|
55
|
+
delete(id) {
|
|
56
|
+
return this.http.request('DELETE', `${BASE}/${(0, paths_1.seg)(id)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.ContactTags = ContactTags;
|
|
60
|
+
//# sourceMappingURL=contact-tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-tags.js","sourceRoot":"","sources":["../../../src/resources/audience/contact-tags.ts"],"names":[],"mappings":";;;AAQA,oCAAyC;AAEzC,MAAM,IAAI,GAAG,GAAG,gBAAQ,eAAe,CAAC;AAExC;;;;GAIG;AACH,MAAa,WAAW;IACO;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;OAKG;IACH,IAAI,CAAC,QAAuC,EAAE;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAwB,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa,KAAK,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAA4B;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,EAAU,EAAE,KAA4B;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa,OAAO,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;CACF;AAjDD,kCAiDC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Contact, ContactDeleteResult, CreateContactInput, ListContactsQuery, Paginated, UpdateContactInput } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
/**
|
|
4
|
+
* Contacts: the people an account talks to, and the resource everything else in
|
|
5
|
+
* the audience module hangs off.
|
|
6
|
+
*
|
|
7
|
+
* Scoping: contacts belong to an account, and a request carries two identities
|
|
8
|
+
* -- the caller and the account they act for. Reads match either; writes land
|
|
9
|
+
* on the caller's own.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Contacts {
|
|
12
|
+
private readonly http;
|
|
13
|
+
constructor(http: HttpClient);
|
|
14
|
+
/**
|
|
15
|
+
* `GET /v1/audience/contacts` -- offset paginated.
|
|
16
|
+
*
|
|
17
|
+
* `search` matches the first and last name plus the name and identifier of
|
|
18
|
+
* every channel identity. `segment` replays a saved filter; `filter` carries
|
|
19
|
+
* ad-hoc conditions, serialised to JSON on the query string by the SDK.
|
|
20
|
+
* Sending both narrows the segment rather than replacing it, and `tag`,
|
|
21
|
+
* `agent` and `status` narrow whatever those produce.
|
|
22
|
+
*
|
|
23
|
+
* Defaults to `status: 'live'`, so the trash needs an explicit
|
|
24
|
+
* `status: 'trashed'`.
|
|
25
|
+
*
|
|
26
|
+
* Scope: `contacts:read`.
|
|
27
|
+
*/
|
|
28
|
+
list(query?: Partial<ListContactsQuery>): Promise<Paginated<Contact>>;
|
|
29
|
+
/**
|
|
30
|
+
* `GET /v1/audience/contacts/:id` -- one contact with its tags resolved.
|
|
31
|
+
* 404 `not_found` if no contact with that id belongs to the caller.
|
|
32
|
+
*
|
|
33
|
+
* Scope: `contacts:read`.
|
|
34
|
+
*/
|
|
35
|
+
get(id: string): Promise<Contact>;
|
|
36
|
+
/**
|
|
37
|
+
* `POST /v1/audience/contacts` -- 201 with the created contact.
|
|
38
|
+
*
|
|
39
|
+
* Every field is optional: an empty body creates a blank contact. Channel
|
|
40
|
+
* identities are not settable here; they are written when a conversation
|
|
41
|
+
* starts on a channel.
|
|
42
|
+
*
|
|
43
|
+
* Scope: `contacts:write`.
|
|
44
|
+
*/
|
|
45
|
+
create(input?: CreateContactInput): Promise<Contact>;
|
|
46
|
+
/**
|
|
47
|
+
* `PATCH /v1/audience/contacts/:id` -- a partial update; anything left out is
|
|
48
|
+
* untouched. `tags` and `custom_field_hash` replace their stored value rather
|
|
49
|
+
* than merging into it.
|
|
50
|
+
*
|
|
51
|
+
* Scope: `contacts:write`.
|
|
52
|
+
*/
|
|
53
|
+
update(id: string, input: UpdateContactInput): Promise<Contact>;
|
|
54
|
+
/**
|
|
55
|
+
* `DELETE /v1/audience/contacts/:id` -- two-stage, and 200 rather than 204
|
|
56
|
+
* both times: the body is what says which stage ran.
|
|
57
|
+
*
|
|
58
|
+
* The first call moves the contact to the trash (`status: 'trashed'`); a
|
|
59
|
+
* second call on an already-trashed contact destroys it along with its notes
|
|
60
|
+
* and channel identities (`status: 'deleted'`).
|
|
61
|
+
*
|
|
62
|
+
* Scope: `contacts:write`.
|
|
63
|
+
*/
|
|
64
|
+
delete(id: string): Promise<ContactDeleteResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Walks every page of `list`, yielding one contact at a time. Takes the same
|
|
67
|
+
* query as `list`; `page` is managed here and is ignored if passed.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* for await (const contact of crm.contacts.iterate({ tag: tagId })) {
|
|
71
|
+
* console.log(contact.id);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
iterate(query?: Partial<ListContactsQuery>): AsyncGenerator<Contact>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Contacts = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const BASE = `${paths_1.AUDIENCE}/contacts`;
|
|
6
|
+
/**
|
|
7
|
+
* Contacts: the people an account talks to, and the resource everything else in
|
|
8
|
+
* the audience module hangs off.
|
|
9
|
+
*
|
|
10
|
+
* Scoping: contacts belong to an account, and a request carries two identities
|
|
11
|
+
* -- the caller and the account they act for. Reads match either; writes land
|
|
12
|
+
* on the caller's own.
|
|
13
|
+
*/
|
|
14
|
+
class Contacts {
|
|
15
|
+
http;
|
|
16
|
+
constructor(http) {
|
|
17
|
+
this.http = http;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `GET /v1/audience/contacts` -- offset paginated.
|
|
21
|
+
*
|
|
22
|
+
* `search` matches the first and last name plus the name and identifier of
|
|
23
|
+
* every channel identity. `segment` replays a saved filter; `filter` carries
|
|
24
|
+
* ad-hoc conditions, serialised to JSON on the query string by the SDK.
|
|
25
|
+
* Sending both narrows the segment rather than replacing it, and `tag`,
|
|
26
|
+
* `agent` and `status` narrow whatever those produce.
|
|
27
|
+
*
|
|
28
|
+
* Defaults to `status: 'live'`, so the trash needs an explicit
|
|
29
|
+
* `status: 'trashed'`.
|
|
30
|
+
*
|
|
31
|
+
* Scope: `contacts:read`.
|
|
32
|
+
*/
|
|
33
|
+
list(query = {}) {
|
|
34
|
+
return this.http.request('GET', BASE, { query });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `GET /v1/audience/contacts/:id` -- one contact with its tags resolved.
|
|
38
|
+
* 404 `not_found` if no contact with that id belongs to the caller.
|
|
39
|
+
*
|
|
40
|
+
* Scope: `contacts:read`.
|
|
41
|
+
*/
|
|
42
|
+
get(id) {
|
|
43
|
+
return this.http.request('GET', `${BASE}/${(0, paths_1.seg)(id)}`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `POST /v1/audience/contacts` -- 201 with the created contact.
|
|
47
|
+
*
|
|
48
|
+
* Every field is optional: an empty body creates a blank contact. Channel
|
|
49
|
+
* identities are not settable here; they are written when a conversation
|
|
50
|
+
* starts on a channel.
|
|
51
|
+
*
|
|
52
|
+
* Scope: `contacts:write`.
|
|
53
|
+
*/
|
|
54
|
+
create(input = {}) {
|
|
55
|
+
return this.http.request('POST', BASE, { body: input });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* `PATCH /v1/audience/contacts/:id` -- a partial update; anything left out is
|
|
59
|
+
* untouched. `tags` and `custom_field_hash` replace their stored value rather
|
|
60
|
+
* than merging into it.
|
|
61
|
+
*
|
|
62
|
+
* Scope: `contacts:write`.
|
|
63
|
+
*/
|
|
64
|
+
update(id, input) {
|
|
65
|
+
return this.http.request('PATCH', `${BASE}/${(0, paths_1.seg)(id)}`, { body: input });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `DELETE /v1/audience/contacts/:id` -- two-stage, and 200 rather than 204
|
|
69
|
+
* both times: the body is what says which stage ran.
|
|
70
|
+
*
|
|
71
|
+
* The first call moves the contact to the trash (`status: 'trashed'`); a
|
|
72
|
+
* second call on an already-trashed contact destroys it along with its notes
|
|
73
|
+
* and channel identities (`status: 'deleted'`).
|
|
74
|
+
*
|
|
75
|
+
* Scope: `contacts:write`.
|
|
76
|
+
*/
|
|
77
|
+
delete(id) {
|
|
78
|
+
return this.http.request('DELETE', `${BASE}/${(0, paths_1.seg)(id)}`);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Walks every page of `list`, yielding one contact at a time. Takes the same
|
|
82
|
+
* query as `list`; `page` is managed here and is ignored if passed.
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* for await (const contact of crm.contacts.iterate({ tag: tagId })) {
|
|
86
|
+
* console.log(contact.id);
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
async *iterate(query = {}) {
|
|
91
|
+
let page = 1;
|
|
92
|
+
for (;;) {
|
|
93
|
+
const result = await this.list({ ...query, page });
|
|
94
|
+
for (const contact of result.data)
|
|
95
|
+
yield contact;
|
|
96
|
+
if (page >= result.pagination.pages || result.data.length === 0)
|
|
97
|
+
return;
|
|
98
|
+
page += 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.Contacts = Contacts;
|
|
103
|
+
//# sourceMappingURL=contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../../src/resources/audience/contacts.ts"],"names":[],"mappings":";;;AASA,oCAAyC;AAEzC,MAAM,IAAI,GAAG,GAAG,gBAAQ,WAAW,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAa,QAAQ;IACU;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,QAAoC,EAAE;QACzC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAqB,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAU,KAAK,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,QAA4B,EAAE;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAU,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,EAAU,EAAE,KAAyB;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAU,OAAO,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACpF,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsB,QAAQ,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,CAAC,OAAO,CAAC,QAAoC,EAAE;QACnD,IAAI,IAAI,GAAG,CAAC,CAAC;QAEb,SAAS,CAAC;YACR,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACnD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI;gBAAE,MAAM,OAAO,CAAC;YACjD,IAAI,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;YACxE,IAAI,IAAI,CAAC,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAzFD,4BAyFC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { CreateCrmTriggerInput, CrmTrigger, CrmTriggerLog, ListCrmTriggerLogsQuery, ListCrmTriggersQuery, Paginated, UpdateCrmTriggerInput } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
/**
|
|
4
|
+
* CRM triggers: fire a webhook when a contact changes.
|
|
5
|
+
*
|
|
6
|
+
* A trigger is three questions. `trigger` is which contact event to watch;
|
|
7
|
+
* `when` narrows it to the fields that moved; `filters` requires the contact
|
|
8
|
+
* itself to match a set of conditions -- the same DSL segments speak, flat
|
|
9
|
+
* rather than wrapped. All three have to pass before `action` runs.
|
|
10
|
+
*
|
|
11
|
+
* `type: 'time'` triggers are stored and served but not dispatched: nothing
|
|
12
|
+
* schedules them yet.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CrmTriggers {
|
|
15
|
+
private readonly http;
|
|
16
|
+
constructor(http: HttpClient);
|
|
17
|
+
/**
|
|
18
|
+
* `GET /v1/audience/crm-triggers` -- offset paginated. `search` matches the
|
|
19
|
+
* trigger name.
|
|
20
|
+
*
|
|
21
|
+
* Scope: `crm_triggers:read`.
|
|
22
|
+
*/
|
|
23
|
+
list(query?: Partial<ListCrmTriggersQuery>): Promise<Paginated<CrmTrigger>>;
|
|
24
|
+
/**
|
|
25
|
+
* `GET /v1/audience/crm-triggers/:id`.
|
|
26
|
+
*
|
|
27
|
+
* Scope: `crm_triggers:read`.
|
|
28
|
+
*/
|
|
29
|
+
get(id: string): Promise<CrmTrigger>;
|
|
30
|
+
/**
|
|
31
|
+
* `POST /v1/audience/crm-triggers` -- 201 with the created trigger.
|
|
32
|
+
*
|
|
33
|
+
* Only `name` and `action` are required; the rest default to an active
|
|
34
|
+
* `event` trigger on `edited` with no field narrowing and no filters, which
|
|
35
|
+
* fires on every change to every contact.
|
|
36
|
+
*
|
|
37
|
+
* Scope: `crm_triggers:write`.
|
|
38
|
+
*/
|
|
39
|
+
create(input: CreateCrmTriggerInput): Promise<CrmTrigger>;
|
|
40
|
+
/**
|
|
41
|
+
* `PATCH /v1/audience/crm-triggers/:id` -- a partial update. `when`,
|
|
42
|
+
* `filters` and `action` replace their stored value rather than merging.
|
|
43
|
+
* Pause a trigger with `{ active: false }` instead of deleting it; the
|
|
44
|
+
* delivery history stays readable either way.
|
|
45
|
+
*
|
|
46
|
+
* Scope: `crm_triggers:write`.
|
|
47
|
+
*/
|
|
48
|
+
update(id: string, input: UpdateCrmTriggerInput): Promise<CrmTrigger>;
|
|
49
|
+
/**
|
|
50
|
+
* `DELETE /v1/audience/crm-triggers/:id` -- 204, no body.
|
|
51
|
+
*
|
|
52
|
+
* Scope: `crm_triggers:write`.
|
|
53
|
+
*/
|
|
54
|
+
delete(id: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* `GET /v1/audience/crm-triggers/logs` -- delivery history across every
|
|
57
|
+
* trigger, or one trigger's with `{ trigger: id }`. Offset paginated,
|
|
58
|
+
* newest first.
|
|
59
|
+
*
|
|
60
|
+
* Logs are written by the dispatcher, never by a caller, and the collection
|
|
61
|
+
* expires them after 30 days -- there is no way to write or delete one.
|
|
62
|
+
* Note the path: `logs` is a sibling of `:id`, not a child of it.
|
|
63
|
+
*
|
|
64
|
+
* Scope: `crm_triggers:read`.
|
|
65
|
+
*/
|
|
66
|
+
logs(query?: Partial<ListCrmTriggerLogsQuery>): Promise<Paginated<CrmTriggerLog>>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrmTriggers = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const BASE = `${paths_1.AUDIENCE}/crm-triggers`;
|
|
6
|
+
/**
|
|
7
|
+
* CRM triggers: fire a webhook when a contact changes.
|
|
8
|
+
*
|
|
9
|
+
* A trigger is three questions. `trigger` is which contact event to watch;
|
|
10
|
+
* `when` narrows it to the fields that moved; `filters` requires the contact
|
|
11
|
+
* itself to match a set of conditions -- the same DSL segments speak, flat
|
|
12
|
+
* rather than wrapped. All three have to pass before `action` runs.
|
|
13
|
+
*
|
|
14
|
+
* `type: 'time'` triggers are stored and served but not dispatched: nothing
|
|
15
|
+
* schedules them yet.
|
|
16
|
+
*/
|
|
17
|
+
class CrmTriggers {
|
|
18
|
+
http;
|
|
19
|
+
constructor(http) {
|
|
20
|
+
this.http = http;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/audience/crm-triggers` -- offset paginated. `search` matches the
|
|
24
|
+
* trigger name.
|
|
25
|
+
*
|
|
26
|
+
* Scope: `crm_triggers:read`.
|
|
27
|
+
*/
|
|
28
|
+
list(query = {}) {
|
|
29
|
+
return this.http.request('GET', BASE, { query });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `GET /v1/audience/crm-triggers/:id`.
|
|
33
|
+
*
|
|
34
|
+
* Scope: `crm_triggers:read`.
|
|
35
|
+
*/
|
|
36
|
+
get(id) {
|
|
37
|
+
return this.http.request('GET', `${BASE}/${(0, paths_1.seg)(id)}`);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `POST /v1/audience/crm-triggers` -- 201 with the created trigger.
|
|
41
|
+
*
|
|
42
|
+
* Only `name` and `action` are required; the rest default to an active
|
|
43
|
+
* `event` trigger on `edited` with no field narrowing and no filters, which
|
|
44
|
+
* fires on every change to every contact.
|
|
45
|
+
*
|
|
46
|
+
* Scope: `crm_triggers:write`.
|
|
47
|
+
*/
|
|
48
|
+
create(input) {
|
|
49
|
+
return this.http.request('POST', BASE, { body: input });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `PATCH /v1/audience/crm-triggers/:id` -- a partial update. `when`,
|
|
53
|
+
* `filters` and `action` replace their stored value rather than merging.
|
|
54
|
+
* Pause a trigger with `{ active: false }` instead of deleting it; the
|
|
55
|
+
* delivery history stays readable either way.
|
|
56
|
+
*
|
|
57
|
+
* Scope: `crm_triggers:write`.
|
|
58
|
+
*/
|
|
59
|
+
update(id, input) {
|
|
60
|
+
return this.http.request('PATCH', `${BASE}/${(0, paths_1.seg)(id)}`, { body: input });
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `DELETE /v1/audience/crm-triggers/:id` -- 204, no body.
|
|
64
|
+
*
|
|
65
|
+
* Scope: `crm_triggers:write`.
|
|
66
|
+
*/
|
|
67
|
+
delete(id) {
|
|
68
|
+
return this.http.request('DELETE', `${BASE}/${(0, paths_1.seg)(id)}`);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* `GET /v1/audience/crm-triggers/logs` -- delivery history across every
|
|
72
|
+
* trigger, or one trigger's with `{ trigger: id }`. Offset paginated,
|
|
73
|
+
* newest first.
|
|
74
|
+
*
|
|
75
|
+
* Logs are written by the dispatcher, never by a caller, and the collection
|
|
76
|
+
* expires them after 30 days -- there is no way to write or delete one.
|
|
77
|
+
* Note the path: `logs` is a sibling of `:id`, not a child of it.
|
|
78
|
+
*
|
|
79
|
+
* Scope: `crm_triggers:read`.
|
|
80
|
+
*/
|
|
81
|
+
logs(query = {}) {
|
|
82
|
+
return this.http.request('GET', `${BASE}/logs`, { query });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.CrmTriggers = CrmTriggers;
|
|
86
|
+
//# sourceMappingURL=crm-triggers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crm-triggers.js","sourceRoot":"","sources":["../../../src/resources/audience/crm-triggers.ts"],"names":[],"mappings":";;;AAUA,oCAAyC;AAEzC,MAAM,IAAI,GAAG,GAAG,gBAAQ,eAAe,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAa,WAAW;IACO;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;OAKG;IACH,IAAI,CAAC,QAAuC,EAAE;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAwB,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa,KAAK,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,KAA4B;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,KAA4B;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa,OAAO,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CAAC,QAA0C,EAAE;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA2B,KAAK,EAAE,GAAG,IAAI,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,CAAC;CACF;AAtED,kCAsEC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CreateCustomFieldInput, CustomField, ListCustomFieldsQuery, Paginated, UpdateCustomFieldInput } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
/**
|
|
4
|
+
* Custom fields: the per-account schema for contacts. A field's `slug` is the
|
|
5
|
+
* key its values are stored under in `contact.custom_field_hash`, and the
|
|
6
|
+
* `field_id` the contact filter addresses it by.
|
|
7
|
+
*
|
|
8
|
+
* Every route below takes either the field's id or its slug, so a caller that
|
|
9
|
+
* knows the schema never has to look an id up first.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CustomFields {
|
|
12
|
+
private readonly http;
|
|
13
|
+
constructor(http: HttpClient);
|
|
14
|
+
/**
|
|
15
|
+
* `GET /v1/audience/custom-fields` -- offset paginated. `search` matches the
|
|
16
|
+
* slug, the label and the caption. `type` filters by who owns the field
|
|
17
|
+
* (`system` for platform-provisioned, `user` for the account's own).
|
|
18
|
+
*
|
|
19
|
+
* Scope: `custom_fields:read`.
|
|
20
|
+
*/
|
|
21
|
+
list(query?: Partial<ListCustomFieldsQuery>): Promise<Paginated<CustomField>>;
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/audience/custom-fields/:ref` -- `ref` is the field's id or its
|
|
24
|
+
* slug. A value that reads as an id is looked up as one; anything else is
|
|
25
|
+
* read as a slug.
|
|
26
|
+
*
|
|
27
|
+
* Scope: `custom_fields:read`.
|
|
28
|
+
*/
|
|
29
|
+
get(ref: string): Promise<CustomField>;
|
|
30
|
+
/**
|
|
31
|
+
* `POST /v1/audience/custom-fields` -- 201 with the created field.
|
|
32
|
+
*
|
|
33
|
+
* The slug must be snake_case and unclaimed: a name that would shadow a
|
|
34
|
+
* contact document path (`name`, `tags`, `status`), a channel key
|
|
35
|
+
* (`whatsapp`, `email`) or a built-in filter field is rejected with 422.
|
|
36
|
+
* A slug already in use on the account is a 409 `conflict`.
|
|
37
|
+
*
|
|
38
|
+
* Scope: `custom_fields:write`.
|
|
39
|
+
*/
|
|
40
|
+
create(input: CreateCustomFieldInput): Promise<CustomField>;
|
|
41
|
+
/**
|
|
42
|
+
* `PATCH /v1/audience/custom-fields/:ref` -- a partial update. The slug is
|
|
43
|
+
* not updatable: values already stored under it would be orphaned.
|
|
44
|
+
*
|
|
45
|
+
* Scope: `custom_fields:write`.
|
|
46
|
+
*/
|
|
47
|
+
update(ref: string, input: UpdateCustomFieldInput): Promise<CustomField>;
|
|
48
|
+
/**
|
|
49
|
+
* `DELETE /v1/audience/custom-fields/:ref` -- 204, no body.
|
|
50
|
+
*
|
|
51
|
+
* Scope: `custom_fields:write`.
|
|
52
|
+
*/
|
|
53
|
+
delete(ref: string): Promise<void>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomFields = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const BASE = `${paths_1.AUDIENCE}/custom-fields`;
|
|
6
|
+
/**
|
|
7
|
+
* Custom fields: the per-account schema for contacts. A field's `slug` is the
|
|
8
|
+
* key its values are stored under in `contact.custom_field_hash`, and the
|
|
9
|
+
* `field_id` the contact filter addresses it by.
|
|
10
|
+
*
|
|
11
|
+
* Every route below takes either the field's id or its slug, so a caller that
|
|
12
|
+
* knows the schema never has to look an id up first.
|
|
13
|
+
*/
|
|
14
|
+
class CustomFields {
|
|
15
|
+
http;
|
|
16
|
+
constructor(http) {
|
|
17
|
+
this.http = http;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `GET /v1/audience/custom-fields` -- offset paginated. `search` matches the
|
|
21
|
+
* slug, the label and the caption. `type` filters by who owns the field
|
|
22
|
+
* (`system` for platform-provisioned, `user` for the account's own).
|
|
23
|
+
*
|
|
24
|
+
* Scope: `custom_fields:read`.
|
|
25
|
+
*/
|
|
26
|
+
list(query = {}) {
|
|
27
|
+
return this.http.request('GET', BASE, { query });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `GET /v1/audience/custom-fields/:ref` -- `ref` is the field's id or its
|
|
31
|
+
* slug. A value that reads as an id is looked up as one; anything else is
|
|
32
|
+
* read as a slug.
|
|
33
|
+
*
|
|
34
|
+
* Scope: `custom_fields:read`.
|
|
35
|
+
*/
|
|
36
|
+
get(ref) {
|
|
37
|
+
return this.http.request('GET', `${BASE}/${(0, paths_1.seg)(ref)}`);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `POST /v1/audience/custom-fields` -- 201 with the created field.
|
|
41
|
+
*
|
|
42
|
+
* The slug must be snake_case and unclaimed: a name that would shadow a
|
|
43
|
+
* contact document path (`name`, `tags`, `status`), a channel key
|
|
44
|
+
* (`whatsapp`, `email`) or a built-in filter field is rejected with 422.
|
|
45
|
+
* A slug already in use on the account is a 409 `conflict`.
|
|
46
|
+
*
|
|
47
|
+
* Scope: `custom_fields:write`.
|
|
48
|
+
*/
|
|
49
|
+
create(input) {
|
|
50
|
+
return this.http.request('POST', BASE, { body: input });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `PATCH /v1/audience/custom-fields/:ref` -- a partial update. The slug is
|
|
54
|
+
* not updatable: values already stored under it would be orphaned.
|
|
55
|
+
*
|
|
56
|
+
* Scope: `custom_fields:write`.
|
|
57
|
+
*/
|
|
58
|
+
update(ref, input) {
|
|
59
|
+
return this.http.request('PATCH', `${BASE}/${(0, paths_1.seg)(ref)}`, { body: input });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `DELETE /v1/audience/custom-fields/:ref` -- 204, no body.
|
|
63
|
+
*
|
|
64
|
+
* Scope: `custom_fields:write`.
|
|
65
|
+
*/
|
|
66
|
+
delete(ref) {
|
|
67
|
+
return this.http.request('DELETE', `${BASE}/${(0, paths_1.seg)(ref)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.CustomFields = CustomFields;
|
|
71
|
+
//# sourceMappingURL=custom-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-fields.js","sourceRoot":"","sources":["../../../src/resources/audience/custom-fields.ts"],"names":[],"mappings":";;;AAQA,oCAAyC;AAEzC,MAAM,IAAI,GAAG,GAAG,gBAAQ,gBAAgB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAa,YAAY;IACM;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;OAMG;IACH,IAAI,CAAC,QAAwC,EAAE;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAyB,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc,KAAK,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,KAA6B;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAW,EAAE,KAA6B;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc,OAAO,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,GAAG,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACzF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAzDD,oCAyDC"}
|