@botozap/sdk 0.16.1 → 0.18.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 +39 -0
- package/README.md +57 -1
- package/dist/index.cjs +54 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +172 -8
- package/dist/index.d.ts +172 -8
- package/dist/index.js +53 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61,6 +61,9 @@ var PLAN_ERROR_CODES = [
|
|
|
61
61
|
function isPlanError(error) {
|
|
62
62
|
return error instanceof BotoZapError && PLAN_ERROR_CODES.includes(error.code);
|
|
63
63
|
}
|
|
64
|
+
function isBusinessPaymentRequired(error) {
|
|
65
|
+
return error instanceof BotoZapError && error.code === "business_payment_required";
|
|
66
|
+
}
|
|
64
67
|
|
|
65
68
|
// src/resources/ai/upload.ts
|
|
66
69
|
var receipts = /* @__PURE__ */ new WeakMap();
|
|
@@ -5278,7 +5281,8 @@ var Customers = class {
|
|
|
5278
5281
|
* Cria um link de setup sob um cliente (expira em 30 dias). Envie a `url`
|
|
5279
5282
|
* devolvida ao Cliente; veja em {@link CreateSetupLinkParams} como funcionam
|
|
5280
5283
|
* os redirecionamentos. URL de redirecionamento inválida lança
|
|
5281
|
-
* `BotoZapError` com `code: "invalid_redirect_url"` (422)
|
|
5284
|
+
* `BotoZapError` com `code: "invalid_redirect_url"` (422); canal inválido,
|
|
5285
|
+
* `code: "invalid_channel"` (422).
|
|
5282
5286
|
*/
|
|
5283
5287
|
createSetupLink(customerId, params = {}) {
|
|
5284
5288
|
return this.client.requestItem(
|
|
@@ -5933,6 +5937,50 @@ var Usage = class {
|
|
|
5933
5937
|
}
|
|
5934
5938
|
};
|
|
5935
5939
|
|
|
5940
|
+
// src/resources/billing.ts
|
|
5941
|
+
function enc8(id) {
|
|
5942
|
+
return encodeURIComponent(id);
|
|
5943
|
+
}
|
|
5944
|
+
var BillingSlots = class {
|
|
5945
|
+
constructor(client) {
|
|
5946
|
+
this.client = client;
|
|
5947
|
+
}
|
|
5948
|
+
client;
|
|
5949
|
+
/**
|
|
5950
|
+
* Compra um slot vazio: gera cobrança de R$ 47/mês. Scope `billing:write`.
|
|
5951
|
+
* `invoice_url` pode vir `null`; a fatura chega em instantes em
|
|
5952
|
+
* {@link BillingResource.get}. Recusas: 402 `plan_required` (Free ou teste: assine o
|
|
5953
|
+
* plano), 402 `slot_limit` (já há 2 slots com fatura em aberto: pague uma),
|
|
5954
|
+
* 402 `billing_customer_required` (conta sem cadastro de cobrança: fale com o
|
|
5955
|
+
* suporte), 422 `invalid_idempotency_key`.
|
|
5956
|
+
*/
|
|
5957
|
+
create(options = {}) {
|
|
5958
|
+
return this.client.requestItem("POST", "/billing/slots", {
|
|
5959
|
+
idempotencyKey: options.idempotencyKey
|
|
5960
|
+
});
|
|
5961
|
+
}
|
|
5962
|
+
/**
|
|
5963
|
+
* Cancela um slot vazio, sem reembolso. Responde 204, também quando o slot
|
|
5964
|
+
* já estava cancelado. Slot ocupado responde 409 `slot_in_use`: desconecte o
|
|
5965
|
+
* negócio antes. Scope `billing:write`.
|
|
5966
|
+
*/
|
|
5967
|
+
cancel(id) {
|
|
5968
|
+
return this.client.request("DELETE", `/billing/slots/${enc8(id)}`);
|
|
5969
|
+
}
|
|
5970
|
+
};
|
|
5971
|
+
var BillingResource = class {
|
|
5972
|
+
constructor(client) {
|
|
5973
|
+
this.client = client;
|
|
5974
|
+
this.slots = new BillingSlots(client);
|
|
5975
|
+
}
|
|
5976
|
+
client;
|
|
5977
|
+
slots;
|
|
5978
|
+
/** Plano, negócios incluídos e slots ativos. Scope `billing:read`. */
|
|
5979
|
+
get() {
|
|
5980
|
+
return this.client.requestItem("GET", "/billing");
|
|
5981
|
+
}
|
|
5982
|
+
};
|
|
5983
|
+
|
|
5936
5984
|
// src/resources/read-only.ts
|
|
5937
5985
|
var Users = class {
|
|
5938
5986
|
constructor(client) {
|
|
@@ -6026,6 +6074,8 @@ var BotoZap = class {
|
|
|
6026
6074
|
media;
|
|
6027
6075
|
events;
|
|
6028
6076
|
usage;
|
|
6077
|
+
/** Plano da Conta e slots adicionais (só chave de API). */
|
|
6078
|
+
billing;
|
|
6029
6079
|
users;
|
|
6030
6080
|
apiLogs;
|
|
6031
6081
|
webhookDeliveries;
|
|
@@ -6069,6 +6119,7 @@ var BotoZap = class {
|
|
|
6069
6119
|
this.media = new Media(this);
|
|
6070
6120
|
this.events = new Events(this);
|
|
6071
6121
|
this.usage = new Usage(this);
|
|
6122
|
+
this.billing = new BillingResource(this);
|
|
6072
6123
|
this.users = new Users(this);
|
|
6073
6124
|
this.apiLogs = new ApiLogs(this);
|
|
6074
6125
|
this.webhookDeliveries = new WebhookDeliveries(this);
|
|
@@ -6285,6 +6336,7 @@ export {
|
|
|
6285
6336
|
Radar,
|
|
6286
6337
|
SavedReplies,
|
|
6287
6338
|
WEBHOOK_CATEGORIES,
|
|
6339
|
+
isBusinessPaymentRequired,
|
|
6288
6340
|
isPlanError
|
|
6289
6341
|
};
|
|
6290
6342
|
//# sourceMappingURL=index.js.map
|