@pilot-status/sdk 0.17.0 → 0.19.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/CHANGELOG.md +80 -0
- package/README.md +121 -3
- package/dist/client.d.ts +38 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +24 -0
- package/dist/client.js.map +1 -1
- package/dist/http.d.ts +6 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +3 -0
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/resources/billing.d.ts +58 -8
- package/dist/resources/billing.d.ts.map +1 -1
- package/dist/resources/billing.js +96 -7
- package/dist/resources/billing.js.map +1 -1
- package/dist/resources/messages.d.ts.map +1 -1
- package/dist/resources/messages.js +8 -1
- package/dist/resources/messages.js.map +1 -1
- package/dist/resources/phone-lines.d.ts +55 -1
- package/dist/resources/phone-lines.d.ts.map +1 -1
- package/dist/resources/phone-lines.js +94 -0
- package/dist/resources/phone-lines.js.map +1 -1
- package/dist/resources/workspace-webhooks.d.ts +46 -0
- package/dist/resources/workspace-webhooks.d.ts.map +1 -0
- package/dist/resources/workspace-webhooks.js +83 -0
- package/dist/resources/workspace-webhooks.js.map +1 -0
- package/dist/resources/workspace.d.ts +3 -0
- package/dist/resources/workspace.d.ts.map +1 -1
- package/dist/resources/workspace.js +4 -0
- package/dist/resources/workspace.js.map +1 -1
- package/dist/resources/workspaces.d.ts +47 -0
- package/dist/resources/workspaces.d.ts.map +1 -0
- package/dist/resources/workspaces.js +75 -0
- package/dist/resources/workspaces.js.map +1 -0
- package/dist/types.d.ts +401 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/webhooks/types.d.ts +20 -0
- package/dist/webhooks/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,68 @@
|
|
|
1
1
|
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type { CheckoutInput, CheckoutResult } from "../types.js";
|
|
3
|
-
/**
|
|
2
|
+
import type { CardSetupIntent, CardSetupIntentSync, CheckoutInput, CheckoutResult, CreatePaymentIntentInput, CreatePaymentIntentOptions, CreatePaymentIntentResult, PaymentIntentSync, WalletTopupResponse } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Billing (`/v1/billing/*`). Requires a tenant-scoped credential (with an account key,
|
|
5
|
+
* `workspaceId`). Card payments through Stripe Elements answer 503
|
|
6
|
+
* `PAYMENTS_NOT_CONFIGURED` while the platform has no Stripe publishable key.
|
|
7
|
+
*/
|
|
4
8
|
export declare class BillingResource {
|
|
5
9
|
#private;
|
|
6
10
|
constructor(http: HttpClient);
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
9
|
-
* (`POST /v1/billing/checkout`).
|
|
12
|
+
* `POST /v1/billing/checkout`.
|
|
10
13
|
*
|
|
11
|
-
* **Nothing is charged here.**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* **Nothing is charged here.** `purpose: "add_card"` returns the `url` of a hosted
|
|
15
|
+
* page that saves a card. `purpose: "wallet_topup"` (requires `amount`, in the
|
|
16
|
+
* account currency) creates a PENDING order (`orderId`, poll it with
|
|
17
|
+
* {@link getTopup}) and returns either a hosted page `url` (`method: "card"`, the
|
|
18
|
+
* default) or, with `method: "pix"` (BRL workspaces only, 400 `PIX_NOT_ELIGIBLE`
|
|
19
|
+
* otherwise), the Pix to show the payer in `pix.copyPaste` / `pix.qrCode`.
|
|
20
|
+
* `method` is sent only when given; `successUrl`/`cancelUrl` with a Pix, or
|
|
21
|
+
* `method` on `add_card`, is 400 `FIELD_NOT_APPLICABLE`.
|
|
15
22
|
*/
|
|
16
23
|
createCheckout(input: CheckoutInput): Promise<CheckoutResult>;
|
|
24
|
+
/**
|
|
25
|
+
* `GET /v1/billing/topups/{id}` — the status of a wallet top-up order (`pending`,
|
|
26
|
+
* `paid`, `expired`, `failed`). Read-only: polling it calls no payment provider.
|
|
27
|
+
* Another workspace's id is 404 `TOPUP_NOT_FOUND`, like an unknown one.
|
|
28
|
+
*/
|
|
29
|
+
getTopup(id: string): Promise<WalletTopupResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* `POST /v1/billing/card/setup-intent` — a Stripe SetupIntent to save a card with
|
|
32
|
+
* the Payment Element on YOUR page (`stripe.confirmSetup(...)`); the card goes
|
|
33
|
+
* browser → Stripe. OWNER only (`billing:payment_method:manage`). Sends no body.
|
|
34
|
+
* ⛔ `clientSecret` lets its holder confirm the intent: never log it.
|
|
35
|
+
*/
|
|
36
|
+
createCardSetupIntent(): Promise<CardSetupIntent>;
|
|
37
|
+
/**
|
|
38
|
+
* `POST /v1/billing/card/setup-intent/{id}/sync` — call right after
|
|
39
|
+
* `confirmSetup` resolves: the server reads the SetupIntent from Stripe and, if it
|
|
40
|
+
* `succeeded`, makes the card the workspace's saved card now (`saved: true`).
|
|
41
|
+
* Idempotent. Not succeeded yet → `saved: false` and Stripe's `status`. A
|
|
42
|
+
* malformed id is 400 `INVALID_SETUP_INTENT_ID`; unknown or another workspace's,
|
|
43
|
+
* 404 `SETUP_INTENT_NOT_FOUND`.
|
|
44
|
+
*/
|
|
45
|
+
syncCardSetupIntent(setupIntentId: string): Promise<CardSetupIntentSync>;
|
|
46
|
+
/**
|
|
47
|
+
* `POST /v1/billing/payment-intents` — a transparent wallet top-up: a PENDING
|
|
48
|
+
* order and a card PaymentIntent for `stripe.confirmPayment(...)` on YOUR page.
|
|
49
|
+
* Nothing is charged here. OWNER only (`billing:wallet:topup`).
|
|
50
|
+
*
|
|
51
|
+
* `options.idempotencyKey` (optional) goes out as the `Idempotency-Key` header:
|
|
52
|
+
* reuse it on retry and the server returns the SAME order and PaymentIntent
|
|
53
|
+
* (`replayed: true`) instead of creating another; the same key with a different
|
|
54
|
+
* body is 409 `IDEMPOTENCY_KEY_REUSED`, while the first call runs 409
|
|
55
|
+
* `IDEMPOTENCY_KEY_IN_USE`. This POST is never retried automatically by the SDK.
|
|
56
|
+
* Resolves to `{ paymentIntent, replayed }`, `paymentIntent` being the body untouched.
|
|
57
|
+
*/
|
|
58
|
+
createPaymentIntent(input: CreatePaymentIntentInput, options?: CreatePaymentIntentOptions): Promise<CreatePaymentIntentResult>;
|
|
59
|
+
/**
|
|
60
|
+
* `POST /v1/billing/payment-intents/{id}/sync` — call right after
|
|
61
|
+
* `confirmPayment` resolves: the server reads the PaymentIntent from Stripe and, if
|
|
62
|
+
* it `succeeded`, credits the wallet exactly once (`credited: true` on that call
|
|
63
|
+
* only). It never charges. A malformed id is 400 `INVALID_PAYMENT_INTENT_ID`;
|
|
64
|
+
* unknown or another workspace's, 404 `PAYMENT_INTENT_NOT_FOUND`.
|
|
65
|
+
*/
|
|
66
|
+
syncPaymentIntent(paymentIntentId: string): Promise<PaymentIntentSync>;
|
|
17
67
|
}
|
|
18
68
|
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,EAEjB,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,qBAAa,eAAe;;gBAGZ,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;OAWG;IACG,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAcnE;;;;OAIG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOxD;;;;;OAKG;IACG,qBAAqB,IAAI,OAAO,CAAC,eAAe,CAAC;IAOvD;;;;;;;OAOG;IACG,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO9E;;;;;;;;;;;OAWG;IACG,mBAAmB,CACrB,KAAK,EAAE,wBAAwB,EAC/B,OAAO,CAAC,EAAE,0BAA0B,GACrC,OAAO,CAAC,yBAAyB,CAAC;IAsBrC;;;;;;OAMG;IACG,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAM/E"}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { compact } from "../internal.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Billing (`/v1/billing/*`). Requires a tenant-scoped credential (with an account key,
|
|
4
|
+
* `workspaceId`). Card payments through Stripe Elements answer 503
|
|
5
|
+
* `PAYMENTS_NOT_CONFIGURED` while the platform has no Stripe publishable key.
|
|
6
|
+
*/
|
|
3
7
|
export class BillingResource {
|
|
4
8
|
#http;
|
|
5
9
|
constructor(http) {
|
|
6
10
|
this.#http = http;
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
10
|
-
* (`POST /v1/billing/checkout`).
|
|
13
|
+
* `POST /v1/billing/checkout`.
|
|
11
14
|
*
|
|
12
|
-
* **Nothing is charged here.**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
* **Nothing is charged here.** `purpose: "add_card"` returns the `url` of a hosted
|
|
16
|
+
* page that saves a card. `purpose: "wallet_topup"` (requires `amount`, in the
|
|
17
|
+
* account currency) creates a PENDING order (`orderId`, poll it with
|
|
18
|
+
* {@link getTopup}) and returns either a hosted page `url` (`method: "card"`, the
|
|
19
|
+
* default) or, with `method: "pix"` (BRL workspaces only, 400 `PIX_NOT_ELIGIBLE`
|
|
20
|
+
* otherwise), the Pix to show the payer in `pix.copyPaste` / `pix.qrCode`.
|
|
21
|
+
* `method` is sent only when given; `successUrl`/`cancelUrl` with a Pix, or
|
|
22
|
+
* `method` on `add_card`, is 400 `FIELD_NOT_APPLICABLE`.
|
|
16
23
|
*/
|
|
17
24
|
async createCheckout(input) {
|
|
18
25
|
return this.#http.requestJson({
|
|
@@ -21,10 +28,92 @@ export class BillingResource {
|
|
|
21
28
|
body: compact({
|
|
22
29
|
purpose: input.purpose,
|
|
23
30
|
amount: input.amount,
|
|
31
|
+
method: input.method,
|
|
24
32
|
successUrl: input.successUrl,
|
|
25
33
|
cancelUrl: input.cancelUrl,
|
|
26
34
|
}),
|
|
27
35
|
});
|
|
28
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* `GET /v1/billing/topups/{id}` — the status of a wallet top-up order (`pending`,
|
|
39
|
+
* `paid`, `expired`, `failed`). Read-only: polling it calls no payment provider.
|
|
40
|
+
* Another workspace's id is 404 `TOPUP_NOT_FOUND`, like an unknown one.
|
|
41
|
+
*/
|
|
42
|
+
async getTopup(id) {
|
|
43
|
+
return this.#http.requestJson({
|
|
44
|
+
method: "GET",
|
|
45
|
+
path: `/v1/billing/topups/${encodeURIComponent(id)}`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `POST /v1/billing/card/setup-intent` — a Stripe SetupIntent to save a card with
|
|
50
|
+
* the Payment Element on YOUR page (`stripe.confirmSetup(...)`); the card goes
|
|
51
|
+
* browser → Stripe. OWNER only (`billing:payment_method:manage`). Sends no body.
|
|
52
|
+
* ⛔ `clientSecret` lets its holder confirm the intent: never log it.
|
|
53
|
+
*/
|
|
54
|
+
async createCardSetupIntent() {
|
|
55
|
+
return this.#http.requestJson({
|
|
56
|
+
method: "POST",
|
|
57
|
+
path: "/v1/billing/card/setup-intent",
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* `POST /v1/billing/card/setup-intent/{id}/sync` — call right after
|
|
62
|
+
* `confirmSetup` resolves: the server reads the SetupIntent from Stripe and, if it
|
|
63
|
+
* `succeeded`, makes the card the workspace's saved card now (`saved: true`).
|
|
64
|
+
* Idempotent. Not succeeded yet → `saved: false` and Stripe's `status`. A
|
|
65
|
+
* malformed id is 400 `INVALID_SETUP_INTENT_ID`; unknown or another workspace's,
|
|
66
|
+
* 404 `SETUP_INTENT_NOT_FOUND`.
|
|
67
|
+
*/
|
|
68
|
+
async syncCardSetupIntent(setupIntentId) {
|
|
69
|
+
return this.#http.requestJson({
|
|
70
|
+
method: "POST",
|
|
71
|
+
path: `/v1/billing/card/setup-intent/${encodeURIComponent(setupIntentId)}/sync`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* `POST /v1/billing/payment-intents` — a transparent wallet top-up: a PENDING
|
|
76
|
+
* order and a card PaymentIntent for `stripe.confirmPayment(...)` on YOUR page.
|
|
77
|
+
* Nothing is charged here. OWNER only (`billing:wallet:topup`).
|
|
78
|
+
*
|
|
79
|
+
* `options.idempotencyKey` (optional) goes out as the `Idempotency-Key` header:
|
|
80
|
+
* reuse it on retry and the server returns the SAME order and PaymentIntent
|
|
81
|
+
* (`replayed: true`) instead of creating another; the same key with a different
|
|
82
|
+
* body is 409 `IDEMPOTENCY_KEY_REUSED`, while the first call runs 409
|
|
83
|
+
* `IDEMPOTENCY_KEY_IN_USE`. This POST is never retried automatically by the SDK.
|
|
84
|
+
* Resolves to `{ paymentIntent, replayed }`, `paymentIntent` being the body untouched.
|
|
85
|
+
*/
|
|
86
|
+
async createPaymentIntent(input, options) {
|
|
87
|
+
const idempotencyKey = options?.idempotencyKey;
|
|
88
|
+
if (idempotencyKey !== undefined &&
|
|
89
|
+
(typeof idempotencyKey !== "string" || idempotencyKey.length === 0)) {
|
|
90
|
+
throw new TypeError("idempotencyKey must be a non-empty string when provided");
|
|
91
|
+
}
|
|
92
|
+
const res = await this.#http.requestJsonWithHeaders({
|
|
93
|
+
method: "POST",
|
|
94
|
+
path: "/v1/billing/payment-intents",
|
|
95
|
+
...(idempotencyKey !== undefined
|
|
96
|
+
? { headers: { "Idempotency-Key": idempotencyKey } }
|
|
97
|
+
: {}),
|
|
98
|
+
body: compact({ purpose: input.purpose, amount: input.amount, saveCard: input.saveCard }),
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
paymentIntent: res.body,
|
|
102
|
+
replayed: res.headers.get("idempotent-replayed") === "true",
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* `POST /v1/billing/payment-intents/{id}/sync` — call right after
|
|
107
|
+
* `confirmPayment` resolves: the server reads the PaymentIntent from Stripe and, if
|
|
108
|
+
* it `succeeded`, credits the wallet exactly once (`credited: true` on that call
|
|
109
|
+
* only). It never charges. A malformed id is 400 `INVALID_PAYMENT_INTENT_ID`;
|
|
110
|
+
* unknown or another workspace's, 404 `PAYMENT_INTENT_NOT_FOUND`.
|
|
111
|
+
*/
|
|
112
|
+
async syncPaymentIntent(paymentIntentId) {
|
|
113
|
+
return this.#http.requestJson({
|
|
114
|
+
method: "POST",
|
|
115
|
+
path: `/v1/billing/payment-intents/${encodeURIComponent(paymentIntentId)}/sync`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
29
118
|
}
|
|
30
119
|
//# sourceMappingURL=billing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAczC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IACf,KAAK,CAAa;IA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AAO,CAAC,iBAAiB,CAAC;IAkBlE,+EAA+E;IACzE,KAAK,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAavE;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQ1E;;;;;;;;OAQG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAQnD;;;;;;;;;OASG;IACG,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;CAOxD"}
|
|
@@ -53,9 +53,16 @@ export class MessagesResource {
|
|
|
53
53
|
...(input.marketingOptions
|
|
54
54
|
? { marketingOptions: input.marketingOptions }
|
|
55
55
|
: {}),
|
|
56
|
+
// A file name only makes sense on a document, so it flips the default media
|
|
57
|
+
// kind: defaulting to "image" here would make the API reject the send.
|
|
56
58
|
...(input.media
|
|
57
|
-
? {
|
|
59
|
+
? {
|
|
60
|
+
media: input.media,
|
|
61
|
+
mediaType: input.mediaType ?? (input.mediaFilename ? "document" : "image"),
|
|
62
|
+
}
|
|
58
63
|
: {}),
|
|
64
|
+
// Also valid WITHOUT `media`: a template with a DOCUMENT header names its file.
|
|
65
|
+
...(input.mediaFilename ? { mediaFilename: input.mediaFilename } : {}),
|
|
59
66
|
...(input.buttons?.length ? { buttons: input.buttons.map(withButtonText) } : {}),
|
|
60
67
|
// ⛔ Estes tres NAO estavam aqui, e a API aceita-os desde sempre: um `list` ou um
|
|
61
68
|
// `carousel` passados a este metodo eram descartados EM SILENCIO, e a mensagem saia
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAqBzC,MAAM,OAAO,gBAAgB;IAClB,KAAK,CAAa;IAE3B,YA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AAC,KAAK,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type { ActivationAudio, StartVerificationOptions, StartVerificationParams, StartVerificationResult, VerificationContactChannelPath, VerificationState } from "../types.js";
|
|
2
|
+
import type { ActivationAudio, CreatePhoneLineWebhookInput, CreatePhoneLineWebhookResponse, ListPhoneLineWebhookDeliveriesParams, PhoneLineWebhookDeleteResult, PhoneLineWebhookDeliveryList, PhoneLineWebhookDeliveryResponse, PhoneLineWebhookList, PhoneLineWebhookResponse, StartVerificationOptions, StartVerificationParams, StartVerificationResult, UpdatePhoneLineWebhookInput, VerificationContactChannelPath, VerificationState } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* `filename` out of a `Content-Disposition` header — quoted (what the server sends,
|
|
5
5
|
* `attachment; filename="activation-<id>.mp3"`) or a bare token. `null` when the
|
|
@@ -56,10 +56,64 @@ export declare class PhoneLineVerificationResource {
|
|
|
56
56
|
*/
|
|
57
57
|
submitDocument(document: string): Promise<VerificationState>;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Phone-line webhooks (`/v1/phone-lines/webhooks*`) — a registry of their OWN, separate
|
|
61
|
+
* from `client.webhooks`: these receive only `phone_line.*` events, and a number webhook
|
|
62
|
+
* (even one on `"*"`) never receives those.
|
|
63
|
+
*
|
|
64
|
+
* Requires a TENANT-scoped key (a number-scoped key is refused) with the
|
|
65
|
+
* `phone_lines:webhooks` permission (ADMIN and up). Another workspace's webhook is 404
|
|
66
|
+
* `WEBHOOK_NOT_FOUND` (a `NotFoundError`), the same as one that does not exist.
|
|
67
|
+
*
|
|
68
|
+
* Every method resolves to the response body untouched (wire-shaped). Deliveries are
|
|
69
|
+
* signed like the number webhooks (`x-pilot-status-signature`, HMAC-SHA256 hex over the
|
|
70
|
+
* raw body) with the webhook's `plwh_` secret: verify them with `verifyWebhookSignature`.
|
|
71
|
+
*/
|
|
72
|
+
export declare class PhoneLineWebhooksResource {
|
|
73
|
+
#private;
|
|
74
|
+
constructor(http: HttpClient);
|
|
75
|
+
/** `GET /v1/phone-lines/webhooks` — the workspace's webhooks (oldest first) and the event catalogue. Never the secret. */
|
|
76
|
+
list(): Promise<PhoneLineWebhookList>;
|
|
77
|
+
/** `GET /v1/phone-lines/webhooks/{id}` — never the secret. */
|
|
78
|
+
get(id: string): Promise<PhoneLineWebhookResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* `POST /v1/phone-lines/webhooks` → HTTP 201 `{ webhook }` WITH `secret` (`plwh_…`),
|
|
81
|
+
* the only time it is ever returned: store it right away.
|
|
82
|
+
*
|
|
83
|
+
* ⚠️ Not idempotent: two calls create two webhooks with two secrets, and the SDK never
|
|
84
|
+
* retries this POST on its own. `url` must be https and public (400
|
|
85
|
+
* `WEBHOOK_URL_REFUSED` otherwise); `events` is a non-empty list of phone-line events
|
|
86
|
+
* or `["*"]`.
|
|
87
|
+
*/
|
|
88
|
+
create(input: CreatePhoneLineWebhookInput): Promise<CreatePhoneLineWebhookResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* `PATCH /v1/phone-lines/webhooks/{id}` — an omitted field is left as it is; `events`
|
|
91
|
+
* REPLACES the whole list; `active: false` pauses. Only a URL that changes is checked
|
|
92
|
+
* again, so a webhook can always be paused. The secret never changes.
|
|
93
|
+
*/
|
|
94
|
+
update(id: string, input: UpdatePhoneLineWebhookInput): Promise<PhoneLineWebhookResponse>;
|
|
95
|
+
/** `DELETE /v1/phone-lines/webhooks/{id}` — irreversible, deletes the delivery history too. To pause, `update(id, { active: false })`. */
|
|
96
|
+
delete(id: string): Promise<PhoneLineWebhookDeleteResult>;
|
|
97
|
+
/**
|
|
98
|
+
* `GET /v1/phone-lines/webhooks/{id}/deliveries` — the latest deliveries, newest first,
|
|
99
|
+
* with their outcome and never their payload (`getDelivery()` has it). `limit`: an
|
|
100
|
+
* integer from 1 to 200, default 50; anything else is 400 `INVALID_LIMIT`.
|
|
101
|
+
*/
|
|
102
|
+
listDeliveries(id: string, params?: ListPhoneLineWebhookDeliveriesParams): Promise<PhoneLineWebhookDeliveryList>;
|
|
103
|
+
/**
|
|
104
|
+
* `GET /v1/phone-lines/webhooks/{id}/deliveries/{deliveryId}` — one delivery in full,
|
|
105
|
+
* with `payload`: the exact JSON string that was POSTed and signed. ⛔ A
|
|
106
|
+
* `phone_line.code_received` payload carries the activation code — a credential.
|
|
107
|
+
* Unknown, another webhook's or another workspace's delivery: 404
|
|
108
|
+
* `WEBHOOK_DELIVERY_NOT_FOUND`.
|
|
109
|
+
*/
|
|
110
|
+
getDelivery(id: string, deliveryId: string): Promise<PhoneLineWebhookDeliveryResponse>;
|
|
111
|
+
}
|
|
59
112
|
/** Phone lines (`/v1/phone-lines/*`). Tenant-scoped keys only. */
|
|
60
113
|
export declare class PhoneLinesResource {
|
|
61
114
|
#private;
|
|
62
115
|
readonly verification: PhoneLineVerificationResource;
|
|
116
|
+
readonly webhooks: PhoneLineWebhooksResource;
|
|
63
117
|
constructor(http: HttpClient);
|
|
64
118
|
/**
|
|
65
119
|
* `GET /v1/phone-lines/activations/{activationId}/audio` — the recording of one
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-lines.d.ts","sourceRoot":"","sources":["../../src/resources/phone-lines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"phone-lines.d.ts","sourceRoot":"","sources":["../../src/resources/phone-lines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,eAAe,EACf,2BAA2B,EAC3B,8BAA8B,EAC9B,oCAAoC,EACpC,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,2B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;IACG,cAAc,CAChB,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,oCAAoC,GAC9C,OAAO,CAAC,4BAA4B,CAAC;IAQxC;;;;;;OAMG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gCAAgC,CAAC;CAM/F;AAED,kEAAkE;AAClE,qBAAa,kBAAkB;;IAE3B,QAAQ,CAAC,YAAY,EAAE,6BAA6B,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;gBAEjC,IAAI,EAAE,UAAU;IAM5B;;;;;;;;;OASG;IACG,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAgB3E;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrE"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { compact } from "../internal.js";
|
|
1
2
|
const VERIFICATION_PATH = "/v1/phone-lines/verification";
|
|
3
|
+
const WEBHOOKS_PATH = "/v1/phone-lines/webhooks";
|
|
2
4
|
/**
|
|
3
5
|
* `filename` out of a `Content-Disposition` header — quoted (what the server sends,
|
|
4
6
|
* `attachment; filename="activation-<id>.mp3"`) or a bare token. `null` when the
|
|
@@ -95,13 +97,105 @@ export class PhoneLineVerificationResource {
|
|
|
95
97
|
});
|
|
96
98
|
}
|
|
97
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Phone-line webhooks (`/v1/phone-lines/webhooks*`) — a registry of their OWN, separate
|
|
102
|
+
* from `client.webhooks`: these receive only `phone_line.*` events, and a number webhook
|
|
103
|
+
* (even one on `"*"`) never receives those.
|
|
104
|
+
*
|
|
105
|
+
* Requires a TENANT-scoped key (a number-scoped key is refused) with the
|
|
106
|
+
* `phone_lines:webhooks` permission (ADMIN and up). Another workspace's webhook is 404
|
|
107
|
+
* `WEBHOOK_NOT_FOUND` (a `NotFoundError`), the same as one that does not exist.
|
|
108
|
+
*
|
|
109
|
+
* Every method resolves to the response body untouched (wire-shaped). Deliveries are
|
|
110
|
+
* signed like the number webhooks (`x-pilot-status-signature`, HMAC-SHA256 hex over the
|
|
111
|
+
* raw body) with the webhook's `plwh_` secret: verify them with `verifyWebhookSignature`.
|
|
112
|
+
*/
|
|
113
|
+
export class PhoneLineWebhooksResource {
|
|
114
|
+
#http;
|
|
115
|
+
constructor(http) {
|
|
116
|
+
this.#http = http;
|
|
117
|
+
}
|
|
118
|
+
/** `GET /v1/phone-lines/webhooks` — the workspace's webhooks (oldest first) and the event catalogue. Never the secret. */
|
|
119
|
+
async list() {
|
|
120
|
+
return this.#http.requestJson({ method: "GET", path: WEBHOOKS_PATH });
|
|
121
|
+
}
|
|
122
|
+
/** `GET /v1/phone-lines/webhooks/{id}` — never the secret. */
|
|
123
|
+
async get(id) {
|
|
124
|
+
return this.#http.requestJson({
|
|
125
|
+
method: "GET",
|
|
126
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* `POST /v1/phone-lines/webhooks` → HTTP 201 `{ webhook }` WITH `secret` (`plwh_…`),
|
|
131
|
+
* the only time it is ever returned: store it right away.
|
|
132
|
+
*
|
|
133
|
+
* ⚠️ Not idempotent: two calls create two webhooks with two secrets, and the SDK never
|
|
134
|
+
* retries this POST on its own. `url` must be https and public (400
|
|
135
|
+
* `WEBHOOK_URL_REFUSED` otherwise); `events` is a non-empty list of phone-line events
|
|
136
|
+
* or `["*"]`.
|
|
137
|
+
*/
|
|
138
|
+
async create(input) {
|
|
139
|
+
return this.#http.requestJson({
|
|
140
|
+
method: "POST",
|
|
141
|
+
path: WEBHOOKS_PATH,
|
|
142
|
+
body: compact({ name: input.name, url: input.url, events: input.events }),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* `PATCH /v1/phone-lines/webhooks/{id}` — an omitted field is left as it is; `events`
|
|
147
|
+
* REPLACES the whole list; `active: false` pauses. Only a URL that changes is checked
|
|
148
|
+
* again, so a webhook can always be paused. The secret never changes.
|
|
149
|
+
*/
|
|
150
|
+
async update(id, input) {
|
|
151
|
+
return this.#http.requestJson({
|
|
152
|
+
method: "PATCH",
|
|
153
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
154
|
+
body: compact({ name: input.name, url: input.url, events: input.events, active: input.active }),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/** `DELETE /v1/phone-lines/webhooks/{id}` — irreversible, deletes the delivery history too. To pause, `update(id, { active: false })`. */
|
|
158
|
+
async delete(id) {
|
|
159
|
+
return this.#http.requestJson({
|
|
160
|
+
method: "DELETE",
|
|
161
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* `GET /v1/phone-lines/webhooks/{id}/deliveries` — the latest deliveries, newest first,
|
|
166
|
+
* with their outcome and never their payload (`getDelivery()` has it). `limit`: an
|
|
167
|
+
* integer from 1 to 200, default 50; anything else is 400 `INVALID_LIMIT`.
|
|
168
|
+
*/
|
|
169
|
+
async listDeliveries(id, params) {
|
|
170
|
+
return this.#http.requestJson({
|
|
171
|
+
method: "GET",
|
|
172
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}/deliveries`,
|
|
173
|
+
query: compact({ limit: params?.limit }),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* `GET /v1/phone-lines/webhooks/{id}/deliveries/{deliveryId}` — one delivery in full,
|
|
178
|
+
* with `payload`: the exact JSON string that was POSTed and signed. ⛔ A
|
|
179
|
+
* `phone_line.code_received` payload carries the activation code — a credential.
|
|
180
|
+
* Unknown, another webhook's or another workspace's delivery: 404
|
|
181
|
+
* `WEBHOOK_DELIVERY_NOT_FOUND`.
|
|
182
|
+
*/
|
|
183
|
+
async getDelivery(id, deliveryId) {
|
|
184
|
+
return this.#http.requestJson({
|
|
185
|
+
method: "GET",
|
|
186
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}/deliveries/${encodeURIComponent(deliveryId)}`,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
98
190
|
/** Phone lines (`/v1/phone-lines/*`). Tenant-scoped keys only. */
|
|
99
191
|
export class PhoneLinesResource {
|
|
100
192
|
#http;
|
|
101
193
|
verification;
|
|
194
|
+
webhooks;
|
|
102
195
|
constructor(http) {
|
|
103
196
|
this.#http = http;
|
|
104
197
|
this.verification = new PhoneLineVerificationResource(http);
|
|
198
|
+
this.webhooks = new PhoneLineWebhooksResource(http);
|
|
105
199
|
}
|
|
106
200
|
/**
|
|
107
201
|
* `GET /v1/phone-lines/activations/{activationId}/audio` — the recording of one
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-lines.js","sourceRoot":"","sources":["../../src/resources/phone-lines.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"phone-lines.js","sourceRoot":"","sources":["../../src/resources/phone-lines.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAmBzC,MAAM,iBAAiB,GAAG,8BAA8B,CAAC;AACzD,MAAM,aAAa,GAAG,0BAA0B,CAAC;AAEjD;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAAC,MAAqB;IACjE,MAAM,KAAK,GAAG,yCAAyC,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,6BAA6B;IAC7B,KAAK,CAAa;IAE3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ceWebhookDeliveriesParams, UpdateWorkspaceWebhookInput, WorkspaceWebhookDeleteResult, WorkspaceWebhookDeliveryList, WorkspaceWebhookDeliveryResponse, WorkspaceWebhookList, WorkspaceWebhookResponse } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Workspace webhooks (`/v1/workspace/webhooks*`) — events of the WORKSPACE, not of a
|
|
5
|
+
* number: every phone-line event plus `wallet.topup_paid`.
|
|
6
|
+
*
|
|
7
|
+
* It is the SAME registry as `client.phoneLines.webhooks` (same rows, `plwh_` secret,
|
|
8
|
+
* signature and deliveries), seen with the wider event set: this surface lists every
|
|
9
|
+
* webhook of the workspace and accepts `wallet.*` events. ⚠️ `"*"` means every
|
|
10
|
+
* PHONE-LINE event only — `wallet.topup_paid` is opt-in: name it
|
|
11
|
+
* (`["*", "wallet.topup_paid"]`).
|
|
12
|
+
*
|
|
13
|
+
* Requires a TENANT-scoped key with `phone_lines:webhooks` (ADMIN and up). Another
|
|
14
|
+
* workspace's webhook is 404 `WEBHOOK_NOT_FOUND`. Every method resolves to the
|
|
15
|
+
* response body untouched. Verify deliveries with `verifyWebhookSignature` and the
|
|
16
|
+
* webhook's `plwh_` secret.
|
|
17
|
+
*/
|
|
18
|
+
export declare class WorkspaceWebhooksResource {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(http: HttpClient);
|
|
21
|
+
/** `GET /v1/workspace/webhooks` — every webhook of the workspace (oldest first) and the event catalogue. Never the secret. */
|
|
22
|
+
list(): Promise<WorkspaceWebhookList>;
|
|
23
|
+
/** `GET /v1/workspace/webhooks/{id}` — never the secret. */
|
|
24
|
+
get(id: string): Promise<WorkspaceWebhookResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* `POST /v1/workspace/webhooks` → HTTP 201 `{ webhook }` WITH `secret` (`plwh_…`),
|
|
27
|
+
* the only time it is ever returned: store it right away.
|
|
28
|
+
*
|
|
29
|
+
* ⚠️ Not idempotent, and never retried by the SDK. `events`: a non-empty list of
|
|
30
|
+
* workspace events and/or `"*"` (phone-line events only).
|
|
31
|
+
*/
|
|
32
|
+
create(input: CreateWorkspaceWebhookInput): Promise<CreateWorkspaceWebhookResponse>;
|
|
33
|
+
/** `PATCH /v1/workspace/webhooks/{id}` — omitted fields stay; `events` REPLACES the list; `active: false` pauses. */
|
|
34
|
+
update(id: string, input: UpdateWorkspaceWebhookInput): Promise<WorkspaceWebhookResponse>;
|
|
35
|
+
/** `DELETE /v1/workspace/webhooks/{id}` — irreversible, deletes the delivery history too. */
|
|
36
|
+
delete(id: string): Promise<WorkspaceWebhookDeleteResult>;
|
|
37
|
+
/** `GET /v1/workspace/webhooks/{id}/deliveries` — newest first, never the payload. `limit` 1–200 (default 50). */
|
|
38
|
+
listDeliveries(id: string, params?: ListWorkspaceWebhookDeliveriesParams): Promise<WorkspaceWebhookDeliveryList>;
|
|
39
|
+
/**
|
|
40
|
+
* `GET /v1/workspace/webhooks/{id}/deliveries/{deliveryId}` — one delivery in full,
|
|
41
|
+
* `payload` being the exact signed JSON string. ⛔ A `phone_line.code_received`
|
|
42
|
+
* payload carries the activation code. 404 `WEBHOOK_DELIVERY_NOT_FOUND` otherwise.
|
|
43
|
+
*/
|
|
44
|
+
getDelivery(id: string, deliveryId: string): Promise<WorkspaceWebhookDeliveryResponse>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=workspace-webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/workspace-webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACR,2BAA2B,EAC3B,8BAA8B,EAC9B,oCAAoC,EACpC,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,oBAAoB,EACpB,wBAAwB,EAC3B,MAAM,aAAa,CAAC;AAIrB;;;;;;;;;;;;;;GAcG;AACH,qBAAa,yBAAyB;;gBAGtB,IAAI,EAAE,UAAU;IAI5B,8HAA8H;IACxH,IAAI,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI3C,4DAA4D;IACtD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAOxD;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,8BAA8B,CAAC;IAQzF,qHAAqH;IAC/G,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAQ/F,6FAA6F;IACvF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAO/D,kHAAkH;IAC5G,cAAc,CAChB,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,oCAAoC,GAC9C,OAAO,CAAC,4BAA4B,CAAC;IAQxC;;;;OAIG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gCAAgC,CAAC;CAM/F"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { compact } from "../internal.js";
|
|
2
|
+
const WEBHOOKS_PATH = "/v1/workspace/webhooks";
|
|
3
|
+
/**
|
|
4
|
+
* Workspace webhooks (`/v1/workspace/webhooks*`) — events of the WORKSPACE, not of a
|
|
5
|
+
* number: every phone-line event plus `wallet.topup_paid`.
|
|
6
|
+
*
|
|
7
|
+
* It is the SAME registry as `client.phoneLines.webhooks` (same rows, `plwh_` secret,
|
|
8
|
+
* signature and deliveries), seen with the wider event set: this surface lists every
|
|
9
|
+
* webhook of the workspace and accepts `wallet.*` events. ⚠️ `"*"` means every
|
|
10
|
+
* PHONE-LINE event only — `wallet.topup_paid` is opt-in: name it
|
|
11
|
+
* (`["*", "wallet.topup_paid"]`).
|
|
12
|
+
*
|
|
13
|
+
* Requires a TENANT-scoped key with `phone_lines:webhooks` (ADMIN and up). Another
|
|
14
|
+
* workspace's webhook is 404 `WEBHOOK_NOT_FOUND`. Every method resolves to the
|
|
15
|
+
* response body untouched. Verify deliveries with `verifyWebhookSignature` and the
|
|
16
|
+
* webhook's `plwh_` secret.
|
|
17
|
+
*/
|
|
18
|
+
export class WorkspaceWebhooksResource {
|
|
19
|
+
#http;
|
|
20
|
+
constructor(http) {
|
|
21
|
+
this.#http = http;
|
|
22
|
+
}
|
|
23
|
+
/** `GET /v1/workspace/webhooks` — every webhook of the workspace (oldest first) and the event catalogue. Never the secret. */
|
|
24
|
+
async list() {
|
|
25
|
+
return this.#http.requestJson({ method: "GET", path: WEBHOOKS_PATH });
|
|
26
|
+
}
|
|
27
|
+
/** `GET /v1/workspace/webhooks/{id}` — never the secret. */
|
|
28
|
+
async get(id) {
|
|
29
|
+
return this.#http.requestJson({
|
|
30
|
+
method: "GET",
|
|
31
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `POST /v1/workspace/webhooks` → HTTP 201 `{ webhook }` WITH `secret` (`plwh_…`),
|
|
36
|
+
* the only time it is ever returned: store it right away.
|
|
37
|
+
*
|
|
38
|
+
* ⚠️ Not idempotent, and never retried by the SDK. `events`: a non-empty list of
|
|
39
|
+
* workspace events and/or `"*"` (phone-line events only).
|
|
40
|
+
*/
|
|
41
|
+
async create(input) {
|
|
42
|
+
return this.#http.requestJson({
|
|
43
|
+
method: "POST",
|
|
44
|
+
path: WEBHOOKS_PATH,
|
|
45
|
+
body: compact({ name: input.name, url: input.url, events: input.events }),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** `PATCH /v1/workspace/webhooks/{id}` — omitted fields stay; `events` REPLACES the list; `active: false` pauses. */
|
|
49
|
+
async update(id, input) {
|
|
50
|
+
return this.#http.requestJson({
|
|
51
|
+
method: "PATCH",
|
|
52
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
53
|
+
body: compact({ name: input.name, url: input.url, events: input.events, active: input.active }),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** `DELETE /v1/workspace/webhooks/{id}` — irreversible, deletes the delivery history too. */
|
|
57
|
+
async delete(id) {
|
|
58
|
+
return this.#http.requestJson({
|
|
59
|
+
method: "DELETE",
|
|
60
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** `GET /v1/workspace/webhooks/{id}/deliveries` — newest first, never the payload. `limit` 1–200 (default 50). */
|
|
64
|
+
async listDeliveries(id, params) {
|
|
65
|
+
return this.#http.requestJson({
|
|
66
|
+
method: "GET",
|
|
67
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}/deliveries`,
|
|
68
|
+
query: compact({ limit: params?.limit }),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `GET /v1/workspace/webhooks/{id}/deliveries/{deliveryId}` — one delivery in full,
|
|
73
|
+
* `payload` being the exact signed JSON string. ⛔ A `phone_line.code_received`
|
|
74
|
+
* payload carries the activation code. 404 `WEBHOOK_DELIVERY_NOT_FOUND` otherwise.
|
|
75
|
+
*/
|
|
76
|
+
async getDelivery(id, deliveryId) {
|
|
77
|
+
return this.#http.requestJson({
|
|
78
|
+
method: "GET",
|
|
79
|
+
path: `${WEBHOOKS_PATH}/${encodeURIComponent(id)}/deliveries/${encodeURIComponent(deliveryId)}`,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=workspace-webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-webhooks.js","sourceRoot":"","sources":["../../src/resources/workspace-webhooks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAazC,MA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