@isnap/sdk 2.3.0 → 2.3.1-next.43435188216.1
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/CHANGELOG.md +65 -40
- package/README.md +360 -167
- package/dist/client.d.ts +35 -49
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +44 -58
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +6 -6
- package/dist/config.js +6 -6
- package/dist/generated/openapi.d.ts +403 -14
- package/dist/internal/sleep.d.ts +2 -2
- package/dist/internal/sleep.js +5 -5
- package/dist/internal/sleep.js.map +1 -1
- package/dist/resources/apps.d.ts +11 -18
- package/dist/resources/apps.d.ts.map +1 -1
- package/dist/resources/apps.js +11 -18
- package/dist/resources/apps.js.map +1 -1
- package/dist/resources/area-codes.d.ts +5 -6
- package/dist/resources/area-codes.d.ts.map +1 -1
- package/dist/resources/area-codes.js +5 -6
- package/dist/resources/area-codes.js.map +1 -1
- package/dist/resources/attachments.d.ts +51 -17
- package/dist/resources/attachments.d.ts.map +1 -1
- package/dist/resources/attachments.js +42 -22
- package/dist/resources/attachments.js.map +1 -1
- package/dist/resources/byod.d.ts +14 -4
- package/dist/resources/byod.d.ts.map +1 -1
- package/dist/resources/byod.js +14 -4
- package/dist/resources/byod.js.map +1 -1
- package/dist/resources/chats.d.ts +30 -22
- package/dist/resources/chats.d.ts.map +1 -1
- package/dist/resources/chats.js +29 -21
- package/dist/resources/chats.js.map +1 -1
- package/dist/resources/lines.d.ts +240 -266
- package/dist/resources/lines.d.ts.map +1 -1
- package/dist/resources/lines.js +240 -266
- package/dist/resources/lines.js.map +1 -1
- package/dist/resources/lookup.d.ts +10 -13
- package/dist/resources/lookup.d.ts.map +1 -1
- package/dist/resources/lookup.js +10 -13
- package/dist/resources/lookup.js.map +1 -1
- package/dist/resources/macos-sessions.d.ts +42 -36
- package/dist/resources/macos-sessions.d.ts.map +1 -1
- package/dist/resources/macos-sessions.js +24 -22
- package/dist/resources/macos-sessions.js.map +1 -1
- package/dist/resources/messages.d.ts +35 -25
- package/dist/resources/messages.d.ts.map +1 -1
- package/dist/resources/messages.js +30 -19
- package/dist/resources/messages.js.map +1 -1
- package/dist/resources/preorders.d.ts +42 -47
- package/dist/resources/preorders.d.ts.map +1 -1
- package/dist/resources/preorders.js +42 -47
- package/dist/resources/preorders.js.map +1 -1
- package/dist/resources/trial.d.ts +30 -21
- package/dist/resources/trial.d.ts.map +1 -1
- package/dist/resources/trial.js +30 -21
- package/dist/resources/trial.js.map +1 -1
- package/dist/resources/webhooks.d.ts +39 -22
- package/dist/resources/webhooks.d.ts.map +1 -1
- package/dist/resources/webhooks.js +39 -22
- package/dist/resources/webhooks.js.map +1 -1
- package/dist/retry.d.ts +9 -10
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +11 -12
- package/dist/retry.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +13 -37
- package/dist/version.js.map +1 -1
- package/dist/webhooks/parse.d.ts +10 -9
- package/dist/webhooks/parse.d.ts.map +1 -1
- package/dist/webhooks/parse.js +14 -13
- package/dist/webhooks/parse.js.map +1 -1
- package/dist/webhooks/types.d.ts +74 -110
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/webhooks/types.js.map +1 -1
- package/dist/webhooks/verify.d.ts +27 -29
- package/dist/webhooks/verify.d.ts.map +1 -1
- package/dist/webhooks/verify.js +29 -35
- package/dist/webhooks/verify.js.map +1 -1
- package/examples/handle-webhook.ts +146 -0
- package/examples/paginate-messages.ts +54 -0
- package/examples/send-message.ts +37 -0
- package/examples/upload-attachment.ts +91 -0
- package/package.json +4 -8
package/dist/resources/apps.d.ts
CHANGED
|
@@ -5,26 +5,19 @@ export type AppManifest = components['schemas']['AppManifestResponse'];
|
|
|
5
5
|
export type AppDownloadEntry = components['schemas']['AppDownloadEntry'];
|
|
6
6
|
export declare class AppsResource extends BaseResource {
|
|
7
7
|
/**
|
|
8
|
-
* `GET /v1/apps
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `byod.pair`, requires no pairing in flight — use it for setup guides,
|
|
12
|
-
* "add a device" flows, reinstalls, and update prompts (compare `version`
|
|
13
|
-
* against the version the device reports).
|
|
8
|
+
* `GET /v1/apps`: where to download the bridge app. One entry for `macos`,
|
|
9
|
+
* with `url`, `version`, `version_status` and `available`. The operation
|
|
10
|
+
* needs no credential.
|
|
14
11
|
*
|
|
15
|
-
*
|
|
16
|
-
* `
|
|
12
|
+
* `url` is a stable link that redirects to the current installer. It is the
|
|
13
|
+
* link `byod.pair` returns in `download_urls`. When `available` is `false`,
|
|
14
|
+
* no installer is offered for that platform and `url` returns `404`: do not
|
|
15
|
+
* show the link.
|
|
17
16
|
*
|
|
18
|
-
* `version` is
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* and do not treat `null` as an error. It is deliberately NOT the
|
|
23
|
-
* `bridge_version` string `byod.pair` returns — that field is a separate,
|
|
24
|
-
* device-facing value (WHA-2538).
|
|
25
|
-
*
|
|
26
|
-
* A platform with `available: false` still appears in the response; hide the
|
|
27
|
-
* affordance rather than offering a link that 404s on click.
|
|
17
|
+
* `version` is a string exactly when `version_status` is `published`, and
|
|
18
|
+
* `null` otherwise. Show that no version is published: do not substitute a
|
|
19
|
+
* number, and do not treat `null` as an error. It is not the
|
|
20
|
+
* `bridge_version` that `byod.pair` returns.
|
|
28
21
|
*/
|
|
29
22
|
manifest(opts?: RequestOptions): Promise<AppManifest>;
|
|
30
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../src/resources/apps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,CAAA;AACtE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAA;AAExE,qBAAa,YAAa,SAAQ,YAAY;IAC5C
|
|
1
|
+
{"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../src/resources/apps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,CAAA;AACtE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAA;AAExE,qBAAa,YAAa,SAAQ,YAAY;IAC5C;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;CAGtD"}
|
package/dist/resources/apps.js
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
import { BaseResource } from './base.js';
|
|
2
2
|
export class AppsResource extends BaseResource {
|
|
3
3
|
/**
|
|
4
|
-
* `GET /v1/apps
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `byod.pair`, requires no pairing in flight — use it for setup guides,
|
|
8
|
-
* "add a device" flows, reinstalls, and update prompts (compare `version`
|
|
9
|
-
* against the version the device reports).
|
|
4
|
+
* `GET /v1/apps`: where to download the bridge app. One entry for `macos`,
|
|
5
|
+
* with `url`, `version`, `version_status` and `available`. The operation
|
|
6
|
+
* needs no credential.
|
|
10
7
|
*
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
8
|
+
* `url` is a stable link that redirects to the current installer. It is the
|
|
9
|
+
* link `byod.pair` returns in `download_urls`. When `available` is `false`,
|
|
10
|
+
* no installer is offered for that platform and `url` returns `404`: do not
|
|
11
|
+
* show the link.
|
|
13
12
|
*
|
|
14
|
-
* `version` is
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* and do not treat `null` as an error. It is deliberately NOT the
|
|
19
|
-
* `bridge_version` string `byod.pair` returns — that field is a separate,
|
|
20
|
-
* device-facing value (WHA-2538).
|
|
21
|
-
*
|
|
22
|
-
* A platform with `available: false` still appears in the response; hide the
|
|
23
|
-
* affordance rather than offering a link that 404s on click.
|
|
13
|
+
* `version` is a string exactly when `version_status` is `published`, and
|
|
14
|
+
* `null` otherwise. Show that no version is published: do not substitute a
|
|
15
|
+
* number, and do not treat `null` as an error. It is not the
|
|
16
|
+
* `bridge_version` that `byod.pair` returns.
|
|
24
17
|
*/
|
|
25
18
|
manifest(opts) {
|
|
26
19
|
return this.client.request('GET', '/v1/apps', undefined, opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps.js","sourceRoot":"","sources":["../../src/resources/apps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,MAAM,OAAO,YAAa,SAAQ,YAAY;IAC5C
|
|
1
|
+
{"version":3,"file":"apps.js","sourceRoot":"","sources":["../../src/resources/apps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,MAAM,OAAO,YAAa,SAAQ,YAAY;IAC5C;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,IAAqB;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAc,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;IAC7E,CAAC;CACF"}
|
|
@@ -7,12 +7,11 @@ export type Country = components['schemas']['Country'];
|
|
|
7
7
|
export type ListAreaCodesQuery = NonNullable<paths['/v1/area-codes']['get']['parameters']['query']>;
|
|
8
8
|
export declare class AreaCodesResource extends BaseResource {
|
|
9
9
|
/**
|
|
10
|
-
* `GET /v1/area-codes
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* alpha-2, case-insensitive) to
|
|
14
|
-
*
|
|
15
|
-
* country dropdown in the same round-trip.
|
|
10
|
+
* `GET /v1/area-codes`: the area codes that can be requested as
|
|
11
|
+
* `preferred_area_codes` on a pre-order, and the countries they belong to.
|
|
12
|
+
* It does not list the lines in stock. The operation needs no credential.
|
|
13
|
+
* Pass `{ country }` (ISO 3166-1 alpha-2, case-insensitive) to keep the area
|
|
14
|
+
* codes of one country; `countries` is never filtered.
|
|
16
15
|
*/
|
|
17
16
|
list(query?: ListAreaCodesQuery, opts?: RequestOptions): Promise<AreaCodes>;
|
|
18
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"area-codes.d.ts","sourceRoot":"","sources":["../../src/resources/area-codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAA;AAC1D,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAA;AACxD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAA;AACtD,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAC1C,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CACtD,CAAA;AAED,qBAAa,iBAAkB,SAAQ,YAAY;IACjD
|
|
1
|
+
{"version":3,"file":"area-codes.d.ts","sourceRoot":"","sources":["../../src/resources/area-codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAA;AAC1D,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAA;AACxD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAA;AACtD,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAC1C,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CACtD,CAAA;AAED,qBAAa,iBAAkB,SAAQ,YAAY;IACjD;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,GAAE,kBAAuB,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC;CAMhF"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { BaseResource } from './base.js';
|
|
2
2
|
export class AreaCodesResource extends BaseResource {
|
|
3
3
|
/**
|
|
4
|
-
* `GET /v1/area-codes
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* alpha-2, case-insensitive) to
|
|
8
|
-
*
|
|
9
|
-
* country dropdown in the same round-trip.
|
|
4
|
+
* `GET /v1/area-codes`: the area codes that can be requested as
|
|
5
|
+
* `preferred_area_codes` on a pre-order, and the countries they belong to.
|
|
6
|
+
* It does not list the lines in stock. The operation needs no credential.
|
|
7
|
+
* Pass `{ country }` (ISO 3166-1 alpha-2, case-insensitive) to keep the area
|
|
8
|
+
* codes of one country; `countries` is never filtered.
|
|
10
9
|
*/
|
|
11
10
|
list(query = {}, opts) {
|
|
12
11
|
return this.client.request('GET', '/v1/area-codes', undefined, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"area-codes.js","sourceRoot":"","sources":["../../src/resources/area-codes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AASxC,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IACjD
|
|
1
|
+
{"version":3,"file":"area-codes.js","sourceRoot":"","sources":["../../src/resources/area-codes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AASxC,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IACjD;;;;;;OAMG;IACH,IAAI,CAAC,QAA4B,EAAE,EAAE,IAAqB;QACxD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAY,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE;YACxE,GAAG,IAAI;YACP,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE;SACpC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -10,35 +10,69 @@ export interface UploadMetadata {
|
|
|
10
10
|
contentType: string;
|
|
11
11
|
}
|
|
12
12
|
export interface UploadOptions extends RequestOptions {
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Wait between two reads of the attachment, in milliseconds. Default 500.
|
|
15
|
+
* Each read is one request and counts toward the request-rate limit. To wait
|
|
16
|
+
* longer for an attachment, raise this value to between 2,000 and 5,000.
|
|
17
|
+
*/
|
|
14
18
|
pollIntervalMs?: number;
|
|
15
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Number of reads of the attachment before `upload()` gives up. Default 60:
|
|
21
|
+
* with the default interval, 30 seconds plus request time. iSnap confirms a
|
|
22
|
+
* finished upload on a 30-second cycle and converts an audio file before it
|
|
23
|
+
* is `ready`, so the default can run out on an upload that succeeds. To wait
|
|
24
|
+
* longer, raise `pollIntervalMs`, not this value alone: at the default
|
|
25
|
+
* interval the reads reach up to 120 per minute, above the request-rate
|
|
26
|
+
* limit of 100.
|
|
27
|
+
*/
|
|
16
28
|
maxPolls?: number;
|
|
17
29
|
}
|
|
18
30
|
export declare class AttachmentsResource extends BaseResource {
|
|
19
31
|
/**
|
|
20
|
-
* `POST /v1/attachments
|
|
21
|
-
*
|
|
22
|
-
*
|
|
32
|
+
* `POST /v1/attachments`: register an attachment and get the URL to upload
|
|
33
|
+
* its bytes to (`upload_url`, with `required_headers`). It is the first step
|
|
34
|
+
* of an upload; `upload()` runs the whole upload in one call.
|
|
23
35
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* method here unless the backend ships one.
|
|
36
|
+
* The API has no operation that deletes an attachment. An attachment expires
|
|
37
|
+
* 72 hours after this call.
|
|
27
38
|
*/
|
|
28
39
|
create(body: CreateAttachmentBody, opts?: RequestOptions): Promise<CreateAttachmentResponse>;
|
|
29
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* `GET /v1/attachments/{id}`: one attachment, with its `status`.
|
|
42
|
+
* `download_url` is set only when `status` is `ready`.
|
|
43
|
+
*/
|
|
30
44
|
get(id: string, opts?: RequestOptions): Promise<Attachment>;
|
|
31
45
|
/**
|
|
32
|
-
*
|
|
33
|
-
* 1. `POST /v1/attachments`
|
|
34
|
-
*
|
|
35
|
-
*
|
|
46
|
+
* Upload a file in one call:
|
|
47
|
+
* 1. `POST /v1/attachments` registers the attachment and returns an upload
|
|
48
|
+
* URL.
|
|
49
|
+
* 2. One `PUT` sends the bytes to that URL. This request is sent once: it is
|
|
50
|
+
* not retried.
|
|
51
|
+
* 3. `GET /v1/attachments/{id}` is read every `pollIntervalMs` until `status`
|
|
52
|
+
* is `ready`, at most `maxPolls` times.
|
|
53
|
+
*
|
|
54
|
+
* Resolves with the attachment once it is `ready`. `file` is a `Blob`, an
|
|
55
|
+
* `ArrayBuffer` or a `Uint8Array` (a Node.js `Buffer` qualifies): the whole
|
|
56
|
+
* file is held in memory. Each call registers a new attachment, unless you
|
|
57
|
+
* pass an `opts.idempotencyKey` that an earlier call used.
|
|
36
58
|
*
|
|
37
59
|
* Throws:
|
|
38
|
-
* - `
|
|
39
|
-
* - `APIError`
|
|
40
|
-
*
|
|
41
|
-
*
|
|
60
|
+
* - `TypeError` when `file` is none of these types.
|
|
61
|
+
* - `APIError` with status 413 and code `attachment_exceeds_storage_limit`
|
|
62
|
+
* when the file is larger than 5 GB (5,368,709,120 bytes), before any
|
|
63
|
+
* request.
|
|
64
|
+
* - `APIConnectionError` when the upload request fails or times out.
|
|
65
|
+
* - `APIError` with code `upload_failed` when the upload request is refused
|
|
66
|
+
* (with the status of that response), or when `status` becomes `failed`
|
|
67
|
+
* (with status 422).
|
|
68
|
+
* - `APIError` with status 504 and code `upload_timeout` when the attachment
|
|
69
|
+
* is not `ready` after `maxPolls` reads. The attachment is not canceled.
|
|
70
|
+
*
|
|
71
|
+
* On `upload_timeout`, and on `upload_failed` after `status` became
|
|
72
|
+
* `failed`, the attachment id is only in the error message. When the upload
|
|
73
|
+
* request is refused, the error carries no id. To keep the id, call
|
|
74
|
+
* `create()`, upload the bytes yourself, and read `get()` until `status` is
|
|
75
|
+
* `ready`.
|
|
42
76
|
*/
|
|
43
77
|
upload(file: UploadInput, metadata: UploadMetadata, opts?: UploadOptions): Promise<Attachment>;
|
|
44
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../../src/resources/attachments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAA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ClB;AAeD,qBAAa,mBAAoB,SAAQ,YAAY;IACnD;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAI5F;;;OAGG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IAS3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,MAAM,CACV,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,cAAc,EACxB,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,UAAU,CAAC;CA8EvB"}
|
|
@@ -17,32 +17,54 @@ function computeSize(file) {
|
|
|
17
17
|
}
|
|
18
18
|
export class AttachmentsResource extends BaseResource {
|
|
19
19
|
/**
|
|
20
|
-
* `POST /v1/attachments
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* `POST /v1/attachments`: register an attachment and get the URL to upload
|
|
21
|
+
* its bytes to (`upload_url`, with `required_headers`). It is the first step
|
|
22
|
+
* of an upload; `upload()` runs the whole upload in one call.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* method here unless the backend ships one.
|
|
24
|
+
* The API has no operation that deletes an attachment. An attachment expires
|
|
25
|
+
* 72 hours after this call.
|
|
27
26
|
*/
|
|
28
27
|
create(body, opts) {
|
|
29
28
|
return this.client.request('POST', '/v1/attachments', body, opts);
|
|
30
29
|
}
|
|
31
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* `GET /v1/attachments/{id}`: one attachment, with its `status`.
|
|
32
|
+
* `download_url` is set only when `status` is `ready`.
|
|
33
|
+
*/
|
|
32
34
|
get(id, opts) {
|
|
33
35
|
return this.client.request('GET', `/v1/attachments/${encodeURIComponent(id)}`, undefined, opts);
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
37
|
-
* 1. `POST /v1/attachments`
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* Upload a file in one call:
|
|
39
|
+
* 1. `POST /v1/attachments` registers the attachment and returns an upload
|
|
40
|
+
* URL.
|
|
41
|
+
* 2. One `PUT` sends the bytes to that URL. This request is sent once: it is
|
|
42
|
+
* not retried.
|
|
43
|
+
* 3. `GET /v1/attachments/{id}` is read every `pollIntervalMs` until `status`
|
|
44
|
+
* is `ready`, at most `maxPolls` times.
|
|
45
|
+
*
|
|
46
|
+
* Resolves with the attachment once it is `ready`. `file` is a `Blob`, an
|
|
47
|
+
* `ArrayBuffer` or a `Uint8Array` (a Node.js `Buffer` qualifies): the whole
|
|
48
|
+
* file is held in memory. Each call registers a new attachment, unless you
|
|
49
|
+
* pass an `opts.idempotencyKey` that an earlier call used.
|
|
40
50
|
*
|
|
41
51
|
* Throws:
|
|
42
|
-
* - `
|
|
43
|
-
* - `APIError`
|
|
44
|
-
*
|
|
45
|
-
*
|
|
52
|
+
* - `TypeError` when `file` is none of these types.
|
|
53
|
+
* - `APIError` with status 413 and code `attachment_exceeds_storage_limit`
|
|
54
|
+
* when the file is larger than 5 GB (5,368,709,120 bytes), before any
|
|
55
|
+
* request.
|
|
56
|
+
* - `APIConnectionError` when the upload request fails or times out.
|
|
57
|
+
* - `APIError` with code `upload_failed` when the upload request is refused
|
|
58
|
+
* (with the status of that response), or when `status` becomes `failed`
|
|
59
|
+
* (with status 422).
|
|
60
|
+
* - `APIError` with status 504 and code `upload_timeout` when the attachment
|
|
61
|
+
* is not `ready` after `maxPolls` reads. The attachment is not canceled.
|
|
62
|
+
*
|
|
63
|
+
* On `upload_timeout`, and on `upload_failed` after `status` became
|
|
64
|
+
* `failed`, the attachment id is only in the error message. When the upload
|
|
65
|
+
* request is refused, the error carries no id. To keep the id, call
|
|
66
|
+
* `create()`, upload the bytes yourself, and read `get()` until `status` is
|
|
67
|
+
* `ready`.
|
|
46
68
|
*/
|
|
47
69
|
async upload(file, metadata, opts = {}) {
|
|
48
70
|
const size = computeSize(file);
|
|
@@ -60,13 +82,11 @@ export class AttachmentsResource extends BaseResource {
|
|
|
60
82
|
content_type: metadata.contentType,
|
|
61
83
|
size_bytes: size
|
|
62
84
|
}, opts);
|
|
63
|
-
// Build
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// server's `required_headers` because R2 ignores non-AWS keys, so a
|
|
69
|
-
// compromised value cannot be used to inject auth into the upload.
|
|
85
|
+
// Build the upload headers with the Headers constructor, which merges
|
|
86
|
+
// names case-insensitively: `required_headers` can carry any casing of
|
|
87
|
+
// `content-type` and `content-length`, and a plain object spread would
|
|
88
|
+
// send the same header twice, which the upload URL can refuse.
|
|
89
|
+
// `required_headers` comes from the API response and is sent as given.
|
|
70
90
|
const putHeaders = new Headers(created.required_headers);
|
|
71
91
|
putHeaders.set('Content-Type', metadata.contentType);
|
|
72
92
|
putHeaders.set('Content-Length', String(size));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../src/resources/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../src/resources/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAgCxC,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AACtC,MAAM,wBAAwB,GAAG,GAAG,CAAA;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J,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,IAAI,wBAAwB,CAAA;QACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,iBAAiB,CAAA;QACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,MAAM,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;YAC1D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;YAC5C,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO;gBAAE,OAAO,GAAG,CAAA;YACtC,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC5B,MAAM,IAAI,QAAQ,CAAC;oBACjB,MAAM,EAAE,GAAG;oBACX,IAAI,EAAE,eAAe;oBACrB,OAAO,EAAE,cAAc,OAAO,CAAC,EAAE,iCAAiC;oBAClE,OAAO,EAAE,EAAE;oBACX,SAAS,EAAE,EAAE;iBACd,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,MAAM,IAAI,QAAQ,CAAC;YACjB,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,cAAc,OAAO,CAAC,EAAE,gCAAgC,QAAQ,GAAG,cAAc,IAAI;YAC9F,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/resources/byod.d.ts
CHANGED
|
@@ -5,10 +5,20 @@ export type ByodPairBody = components['schemas']['ByodPairBody'];
|
|
|
5
5
|
export type ByodPairResponse = components['schemas']['ByodPairResponse'];
|
|
6
6
|
export declare class ByodResource extends BaseResource {
|
|
7
7
|
/**
|
|
8
|
-
* `POST /v1/byod/pair
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* `POST /v1/byod/pair`: issue an activation code for a BYOD pairing.
|
|
9
|
+
* Resolves with `activation_code` (single use, valid 5 minutes),
|
|
10
|
+
* `expires_at`, `download_urls` and `bridge_version`. The body takes an
|
|
11
|
+
* optional `metadata`, copied onto the line the pairing creates.
|
|
12
|
+
*
|
|
13
|
+
* The line appears on your account, already `active`, when the bridge app
|
|
14
|
+
* completes the pairing with the code.
|
|
15
|
+
*
|
|
16
|
+
* An account that is not a wholesale partner needs a free BYOD slot. With no
|
|
17
|
+
* BYOD subscription the call is a `PaymentRequiredError` (402
|
|
18
|
+
* `payment_required`); with every slot used it is a `NotFoundError` (404
|
|
19
|
+
* `no_slot_available`).
|
|
20
|
+
*
|
|
21
|
+
* The API does not deduplicate this call: a retry issues another code.
|
|
12
22
|
*/
|
|
13
23
|
pair(body: ByodPairBody, opts?: RequestOptions): Promise<ByodPairResponse>;
|
|
14
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"byod.d.ts","sourceRoot":"","sources":["../../src/resources/byod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAA;AAChE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAA;AAExE,qBAAa,YAAa,SAAQ,YAAY;IAC5C
|
|
1
|
+
{"version":3,"file":"byod.d.ts","sourceRoot":"","sources":["../../src/resources/byod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAA;AAChE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAA;AAExE,qBAAa,YAAa,SAAQ,YAAY;IAC5C;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG3E"}
|
package/dist/resources/byod.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { BaseResource } from './base.js';
|
|
2
2
|
export class ByodResource extends BaseResource {
|
|
3
3
|
/**
|
|
4
|
-
* `POST /v1/byod/pair
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* `POST /v1/byod/pair`: issue an activation code for a BYOD pairing.
|
|
5
|
+
* Resolves with `activation_code` (single use, valid 5 minutes),
|
|
6
|
+
* `expires_at`, `download_urls` and `bridge_version`. The body takes an
|
|
7
|
+
* optional `metadata`, copied onto the line the pairing creates.
|
|
8
|
+
*
|
|
9
|
+
* The line appears on your account, already `active`, when the bridge app
|
|
10
|
+
* completes the pairing with the code.
|
|
11
|
+
*
|
|
12
|
+
* An account that is not a wholesale partner needs a free BYOD slot. With no
|
|
13
|
+
* BYOD subscription the call is a `PaymentRequiredError` (402
|
|
14
|
+
* `payment_required`); with every slot used it is a `NotFoundError` (404
|
|
15
|
+
* `no_slot_available`).
|
|
16
|
+
*
|
|
17
|
+
* The API does not deduplicate this call: a retry issues another code.
|
|
8
18
|
*/
|
|
9
19
|
pair(body, opts) {
|
|
10
20
|
return this.client.request('POST', '/v1/byod/pair', body, opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"byod.js","sourceRoot":"","sources":["../../src/resources/byod.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,MAAM,OAAO,YAAa,SAAQ,YAAY;IAC5C
|
|
1
|
+
{"version":3,"file":"byod.js","sourceRoot":"","sources":["../../src/resources/byod.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,MAAM,OAAO,YAAa,SAAQ,YAAY;IAC5C;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,IAAkB,EAAE,IAAqB;QAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAmB,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACnF,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { components, paths } from '../generated/openapi.js';
|
|
2
2
|
import type { RequestOptions } from '../types.js';
|
|
3
3
|
import { BaseResource } from './base.js';
|
|
4
|
-
/**
|
|
4
|
+
/** A chat, as `list` and `get` return it. */
|
|
5
5
|
export type Chat = components['schemas']['Chat'];
|
|
6
6
|
export type ChatTypingStart = components['schemas']['ChatTypingStart'];
|
|
7
7
|
export type ChatTypingStop = components['schemas']['ChatTypingStop'];
|
|
@@ -13,38 +13,46 @@ export type MarkReadBody = NonNullable<paths['/v1/chats/{chat_id}/read']['post']
|
|
|
13
13
|
export type ShareContactCardBody = NonNullable<paths['/v1/chats/{chat_id}/share-contact-card']['post']['requestBody']>['content']['application/json'];
|
|
14
14
|
export declare class ChatsResource extends BaseResource {
|
|
15
15
|
/**
|
|
16
|
-
* `GET /v1/chats/{chat_id}
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* out-of-scope ids resolve 404.
|
|
16
|
+
* `GET /v1/chats/{chat_id}`: one chat, by its `chat_` id. An unknown id, a
|
|
17
|
+
* chat of another account and a chat outside the lines of a line-scoped key
|
|
18
|
+
* all return `404`.
|
|
20
19
|
*/
|
|
21
20
|
get(chatId: string, opts?: RequestOptions): Promise<Chat>;
|
|
22
21
|
/**
|
|
23
|
-
* `GET /v1/chats
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* `
|
|
30
|
-
* `
|
|
31
|
-
* contact; `null` on non-shared lines or once the binding is released.
|
|
22
|
+
* `GET /v1/chats`: your chats, most recent activity first, as an
|
|
23
|
+
* `AsyncIterable`. A `for await` loop receives every matching chat; the SDK
|
|
24
|
+
* fetches the next page when the current one is consumed. Filter by
|
|
25
|
+
* `line_id`, bound the last activity time with `since` and `until` (ISO 8601,
|
|
26
|
+
* inclusive), and set the page size with `limit` (1 to 100, default 20).
|
|
27
|
+
*
|
|
28
|
+
* On a shared line, `outbound_number` is the number that serves the contact,
|
|
29
|
+
* or `null` when none is assigned. On every other line it is `null`.
|
|
32
30
|
*/
|
|
33
31
|
list(filters?: Omit<ListChatsQuery, 'cursor'>, opts?: RequestOptions): AsyncIterable<Chat>;
|
|
34
32
|
/**
|
|
35
|
-
* `POST /v1/chats/{chat_id}/typing
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* `
|
|
33
|
+
* `POST /v1/chats/{chat_id}/typing`: ask the line's device to show the typing
|
|
34
|
+
* indicator to the chat's contact. Resolves with `chat_id`, `started_at` and
|
|
35
|
+
* `expires_at`, which is 15 seconds after `started_at`. Call it again to keep
|
|
36
|
+
* the indicator, or call `typingStop` to clear it.
|
|
39
37
|
*/
|
|
40
38
|
typingStart(chatId: string, body: TypingStartBody, opts?: RequestOptions): Promise<ChatTypingStart>;
|
|
41
|
-
/** `DELETE /v1/chats/{chat_id}/typing
|
|
39
|
+
/** `DELETE /v1/chats/{chat_id}/typing`: ask the line's device to clear the typing indicator. */
|
|
42
40
|
typingStop(chatId: string, opts?: RequestOptions): Promise<ChatTypingStop>;
|
|
43
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* `POST /v1/chats/{chat_id}/read`: mark every unread inbound message of the
|
|
43
|
+
* chat as read and ask the line's device to send read receipts. Resolves with
|
|
44
|
+
* `chat_id`, `read_at` and `marked_count`.
|
|
45
|
+
*/
|
|
44
46
|
markRead(chatId: string, body: MarkReadBody, opts?: RequestOptions): Promise<ChatMarkRead>;
|
|
45
47
|
/**
|
|
46
|
-
* `POST /v1/chats/{chat_id}/share-contact-card
|
|
47
|
-
* contact
|
|
48
|
+
* `POST /v1/chats/{chat_id}/share-contact-card`: send a contact card (a
|
|
49
|
+
* vCard file) to the chat's contact, as a message with one attachment.
|
|
50
|
+
*
|
|
51
|
+
* Once a call has queued the card, a repeat with the same idempotency key
|
|
52
|
+
* returns `409 idempotency_conflict` instead of the first result. The
|
|
53
|
+
* automatic retries of the SDK reuse the key: call this method with
|
|
54
|
+
* `{ maxRetries: 0 }`, and after an error read the messages of the chat's
|
|
55
|
+
* line before you send the card again.
|
|
48
56
|
*/
|
|
49
57
|
shareContactCard(chatId: string, body: ShareContactCardBody, opts?: RequestOptions): Promise<ShareContactCardResult>;
|
|
50
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chats.d.ts","sourceRoot":"","sources":["../../src/resources/chats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAGhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,
|
|
1
|
+
{"version":3,"file":"chats.d.ts","sourceRoot":"","sources":["../../src/resources/chats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAGhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,6CAA6C;AAC7C,MAAM,MAAM,IAAI,GAAG,UA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Ac,GAAG,aAAa,CAAC,IAAI,CAAC;IAW9F;;;;;OAKG;IACH,WAAW,CACT,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,eAAe,EACrB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,eAAe,CAAC;IAS3B,gGAAgG;IAChG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAS1E;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAS1F;;;;;;;;;OASG;IACH,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,oBAAoB,EAC1B,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,sBAAsB,CAAC;CAQnC"}
|
package/dist/resources/chats.js
CHANGED
|
@@ -2,24 +2,22 @@ import { paginate } from '../pagination.js';
|
|
|
2
2
|
import { BaseResource } from './base.js';
|
|
3
3
|
export class ChatsResource extends BaseResource {
|
|
4
4
|
/**
|
|
5
|
-
* `GET /v1/chats/{chat_id}
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* out-of-scope ids resolve 404.
|
|
5
|
+
* `GET /v1/chats/{chat_id}`: one chat, by its `chat_` id. An unknown id, a
|
|
6
|
+
* chat of another account and a chat outside the lines of a line-scoped key
|
|
7
|
+
* all return `404`.
|
|
9
8
|
*/
|
|
10
9
|
get(chatId, opts) {
|
|
11
10
|
return this.client.request('GET', `/v1/chats/${encodeURIComponent(chatId)}`, undefined, opts);
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
|
-
* `GET /v1/chats
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* `
|
|
21
|
-
* `
|
|
22
|
-
* contact; `null` on non-shared lines or once the binding is released.
|
|
13
|
+
* `GET /v1/chats`: your chats, most recent activity first, as an
|
|
14
|
+
* `AsyncIterable`. A `for await` loop receives every matching chat; the SDK
|
|
15
|
+
* fetches the next page when the current one is consumed. Filter by
|
|
16
|
+
* `line_id`, bound the last activity time with `since` and `until` (ISO 8601,
|
|
17
|
+
* inclusive), and set the page size with `limit` (1 to 100, default 20).
|
|
18
|
+
*
|
|
19
|
+
* On a shared line, `outbound_number` is the number that serves the contact,
|
|
20
|
+
* or `null` when none is assigned. On every other line it is `null`.
|
|
23
21
|
*/
|
|
24
22
|
list(filters = {}, opts) {
|
|
25
23
|
return paginate((cursor) => this.client.request('GET', '/v1/chats', undefined, {
|
|
@@ -28,25 +26,35 @@ export class ChatsResource extends BaseResource {
|
|
|
28
26
|
}), { signal: opts?.signal });
|
|
29
27
|
}
|
|
30
28
|
/**
|
|
31
|
-
* `POST /v1/chats/{chat_id}/typing
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* `
|
|
29
|
+
* `POST /v1/chats/{chat_id}/typing`: ask the line's device to show the typing
|
|
30
|
+
* indicator to the chat's contact. Resolves with `chat_id`, `started_at` and
|
|
31
|
+
* `expires_at`, which is 15 seconds after `started_at`. Call it again to keep
|
|
32
|
+
* the indicator, or call `typingStop` to clear it.
|
|
35
33
|
*/
|
|
36
34
|
typingStart(chatId, body, opts) {
|
|
37
35
|
return this.client.request('POST', `/v1/chats/${encodeURIComponent(chatId)}/typing`, body, opts);
|
|
38
36
|
}
|
|
39
|
-
/** `DELETE /v1/chats/{chat_id}/typing
|
|
37
|
+
/** `DELETE /v1/chats/{chat_id}/typing`: ask the line's device to clear the typing indicator. */
|
|
40
38
|
typingStop(chatId, opts) {
|
|
41
39
|
return this.client.request('DELETE', `/v1/chats/${encodeURIComponent(chatId)}/typing`, undefined, opts);
|
|
42
40
|
}
|
|
43
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* `POST /v1/chats/{chat_id}/read`: mark every unread inbound message of the
|
|
43
|
+
* chat as read and ask the line's device to send read receipts. Resolves with
|
|
44
|
+
* `chat_id`, `read_at` and `marked_count`.
|
|
45
|
+
*/
|
|
44
46
|
markRead(chatId, body, opts) {
|
|
45
47
|
return this.client.request('POST', `/v1/chats/${encodeURIComponent(chatId)}/read`, body, opts);
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
48
|
-
* `POST /v1/chats/{chat_id}/share-contact-card
|
|
49
|
-
* contact
|
|
50
|
+
* `POST /v1/chats/{chat_id}/share-contact-card`: send a contact card (a
|
|
51
|
+
* vCard file) to the chat's contact, as a message with one attachment.
|
|
52
|
+
*
|
|
53
|
+
* Once a call has queued the card, a repeat with the same idempotency key
|
|
54
|
+
* returns `409 idempotency_conflict` instead of the first result. The
|
|
55
|
+
* automatic retries of the SDK reuse the key: call this method with
|
|
56
|
+
* `{ maxRetries: 0 }`, and after an error read the messages of the chat's
|
|
57
|
+
* line before you send the card again.
|
|
50
58
|
*/
|
|
51
59
|
shareContactCard(chatId, body, opts) {
|
|
52
60
|
return this.client.request('POST', `/v1/chats/${encodeURIComponent(chatId)}/share-contact-card`, body, opts);
|