@pabilo/sdk 0.1.6 → 0.1.7
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 +219 -155
- package/dist/index.cjs +46 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -11
- package/dist/index.d.ts +70 -11
- package/dist/index.js +46 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -169,6 +169,27 @@ var PaymentLinksResource = class {
|
|
|
169
169
|
constructor(http) {
|
|
170
170
|
this.http = http;
|
|
171
171
|
}
|
|
172
|
+
async list(req) {
|
|
173
|
+
const body = {
|
|
174
|
+
page: req?.page ?? 1,
|
|
175
|
+
limit: req?.limit ?? 10
|
|
176
|
+
};
|
|
177
|
+
if (req?.type !== void 0) body["type"] = req.type;
|
|
178
|
+
if (req?.status !== void 0) body["status"] = req.status;
|
|
179
|
+
if (req?.search !== void 0) body["search"] = req.search;
|
|
180
|
+
const res = await this.http.request({
|
|
181
|
+
method: "POST",
|
|
182
|
+
path: "/me/payment-links",
|
|
183
|
+
body
|
|
184
|
+
});
|
|
185
|
+
const raw = Array.isArray(res["payment_links"]) ? res["payment_links"] : [];
|
|
186
|
+
return {
|
|
187
|
+
items: raw.map((item) => normalizePaymentLink(item)),
|
|
188
|
+
total: typeof res["total"] === "number" ? res["total"] : 0,
|
|
189
|
+
page: typeof res["page"] === "number" ? res["page"] : 1,
|
|
190
|
+
limit: typeof res["limit"] === "number" ? res["limit"] : raw.length
|
|
191
|
+
};
|
|
192
|
+
}
|
|
172
193
|
async create(req) {
|
|
173
194
|
const body = {
|
|
174
195
|
amount: req.amount,
|
|
@@ -223,13 +244,17 @@ function normalizePaymentLink(raw) {
|
|
|
223
244
|
url: String(src["url"] ?? ""),
|
|
224
245
|
...typeof src["amount"] === "number" ? { amount: src["amount"] } : {},
|
|
225
246
|
...typeof src["status"] === "string" ? { status: src["status"] } : {},
|
|
247
|
+
...typeof src["status_detail"] === "string" ? { statusDetail: src["status_detail"] } : {},
|
|
226
248
|
...typeof src["type"] === "string" ? { type: src["type"] } : {},
|
|
227
249
|
...userId !== void 0 ? { userId } : {},
|
|
250
|
+
...typeof src["user_bank_id"] === "string" ? { userBankId: src["user_bank_id"] } : {},
|
|
251
|
+
...typeof src["with_subscription_id"] === "string" ? { withSubscriptionId: src["with_subscription_id"] } : {},
|
|
228
252
|
...typeof src["name"] === "string" ? { name: src["name"] } : {},
|
|
229
253
|
...typeof src["description"] === "string" ? { description: src["description"] } : {},
|
|
230
254
|
...typeof src["is_usd"] === "boolean" ? { isUsd: src["is_usd"] } : {},
|
|
231
255
|
...typeof src["redirect_url"] === "string" ? { redirectUrl: src["redirect_url"] } : {},
|
|
232
256
|
...typeof src["webhook_url"] === "string" ? { webhookUrl: src["webhook_url"] } : {},
|
|
257
|
+
...typeof src["webhook_method"] === "string" ? { webhookMethod: src["webhook_method"] } : {},
|
|
233
258
|
...typeof src["notification_by_whastapp"] === "boolean" ? { notificationByWhatsapp: src["notification_by_whastapp"] } : {},
|
|
234
259
|
...typeof src["expiration_time"] === "number" ? { expirationTime: src["expiration_time"] } : {},
|
|
235
260
|
...typeof src["payment_link_origin"] === "string" ? { paymentLinkOrigin: src["payment_link_origin"] } : {},
|
|
@@ -285,17 +310,35 @@ var MeResource = class {
|
|
|
285
310
|
return {
|
|
286
311
|
id: String(u["id"] ?? ""),
|
|
287
312
|
...typeof u["email"] === "string" ? { email: u["email"] } : {},
|
|
288
|
-
...typeof u["
|
|
313
|
+
...typeof u["username"] === "string" ? { username: u["username"] } : {},
|
|
314
|
+
...typeof u["full_name"] === "string" ? { fullName: u["full_name"] } : {},
|
|
315
|
+
...typeof u["company_name"] === "string" ? { companyName: u["company_name"] } : {},
|
|
316
|
+
...typeof u["credits"] === "number" ? { credits: u["credits"] } : {},
|
|
317
|
+
...typeof u["plan_is_active"] === "boolean" ? { planIsActive: u["plan_is_active"] } : {},
|
|
318
|
+
...typeof u["is_demo"] === "boolean" ? { isDemo: u["is_demo"] } : {},
|
|
319
|
+
...typeof u["user_type"] === "string" ? { userType: u["user_type"] } : {}
|
|
289
320
|
};
|
|
290
321
|
}
|
|
291
322
|
async getPlan() {
|
|
292
|
-
const
|
|
323
|
+
const raw = await this.http.request({
|
|
293
324
|
method: "GET",
|
|
294
325
|
path: "/me/plan"
|
|
295
326
|
});
|
|
327
|
+
const res = raw["plan"] ?? raw;
|
|
296
328
|
return {
|
|
297
329
|
name: String(res["name"] ?? ""),
|
|
298
|
-
...typeof res["
|
|
330
|
+
...typeof res["id"] === "string" ? { id: res["id"] } : {},
|
|
331
|
+
...typeof res["description"] === "string" ? { description: res["description"] } : {},
|
|
332
|
+
...typeof res["planType"] === "string" ? { planType: res["planType"] } : {},
|
|
333
|
+
...typeof res["period"] === "string" ? { period: res["period"] } : {},
|
|
334
|
+
...typeof res["price"] === "number" ? { price: res["price"] } : {},
|
|
335
|
+
...typeof res["requestLimit"] === "number" ? { requestLimit: res["requestLimit"] } : {},
|
|
336
|
+
...typeof res["bankAccountLimit"] === "number" ? { bankAccountLimit: res["bankAccountLimit"] } : {},
|
|
337
|
+
...typeof res["initialCredits"] === "number" ? { initialCredits: res["initialCredits"] } : {},
|
|
338
|
+
...typeof res["maxAcumulatedCredits"] === "number" ? { maxAcumulatedCredits: res["maxAcumulatedCredits"] } : {},
|
|
339
|
+
...Array.isArray(res["benefits"]) ? { benefits: res["benefits"] } : {},
|
|
340
|
+
...typeof res["salient"] === "boolean" ? { salient: res["salient"] } : {},
|
|
341
|
+
...typeof res["hidden"] === "boolean" ? { hidden: res["hidden"] } : {}
|
|
299
342
|
};
|
|
300
343
|
}
|
|
301
344
|
};
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/domain/errors.ts","../src/infrastructure/fetch-http-client.ts","../src/infrastructure/pabilo-http-client.ts","../src/resources/bank-accounts.resource.ts","../src/resources/payment-links.resource.ts","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AI,OAAO,GAAA,CAAI,UAAU,CAAA,KAAM,QAAA,GAAW,EAAE,QAAA,EAAU,GAAA,CAAI,UAAU,CAAA,EAAE,GAAI;AAAC,KAC7E;AAAA,EACF;AACF,CAAA;;;ACbO,IAAM,eAAN,MAAmB;AAAA,EAMxB,YAAY,OAAA,EAA8B;AACxC,IAAA,MAAM,IAAA,GAAoB,OAAA,CAAQ,UAAA,IAAc,IAAI,gBAAA,CAAiB;AAAA,MACnE,QAAQ,OAAA,CAAQ,MAAA;AAAA,MAChB,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ,GAAI;AAAC,KACrE,CAAA;AAED,IAAA,IAAA,CAAK,EAAA,GAAK,IAAI,UAAA,CAAW,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,YAAA,GAAe,IAAI,oBAAA,CAAqB,IAAI,CAAA;AACjD,IAAA,IAAA,CAAK,YAAA,GAAe,IAAI,oBAAA,CAAqB,IAAI,CAAA;AACjD,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,gBAAA,CAAiB,IAAI,CAAA;AAAA,EAC3C;AACF","file":"index.cjs","sourcesContent":["export class PabiloError extends Error {\n readonly code: string;\n readonly statusCode: number | undefined;\n readonly raw: unknown;\n\n constructor(opts: {\n message: string;\n code: string;\n statusCode?: number;\n raw?: unknown;\n }) {\n super(opts.message);\n this.name = 'PabiloError';\n this.code = opts.code;\n this.statusCode = opts.statusCode;\n this.raw = opts.raw;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport function parsePabiloError(body: unknown, statusCode: number): PabiloError {\n if (statusCode === 401) {\n return new PabiloError({ message: 'Unauthorized', code: 'UNAUTHORIZED', statusCode, raw: body });\n }\n if (statusCode === 404) {\n return new PabiloError({ message: 'Not found', code: 'NOT_FOUND', statusCode, raw: body });\n }\n\n if (body !== null && typeof body === 'object') {\n const b = body as Record<string, unknown>;\n const code = typeof b['error'] === 'string' ? b['error'] : resolveCodeFromStatus(statusCode);\n const message = typeof b['message'] === 'string' ? b['message'] : code;\n return new PabiloError({ message, code, statusCode, raw: body });\n }\n\n const code = resolveCodeFromStatus(statusCode);\n return new PabiloError({ message: code, code, statusCode, raw: body });\n}\n\nfunction resolveCodeFromStatus(statusCode: number): string {\n if (statusCode >= 500) return 'INTERNAL_SERVER_ERROR';\n if (statusCode === 400) return 'BAD_REQUEST';\n return 'REQUEST_FAILED';\n}\n","import type { IHttpClient, RequestOptions } from '../ports/http.js';\nimport { PabiloError, parsePabiloError } from '../domain/errors.js';\n\ntype FetchFn = typeof globalThis.fetch;\n\nexport class FetchHttpClient implements IHttpClient {\n private readonly fetchFn: FetchFn;\n\n constructor(fetchImpl?: FetchFn) {\n this.fetchFn = fetchImpl ?? globalThis.fetch.bind(globalThis);\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const { method, path, body, headers = {} } = options;\n\n const init: RequestInit = { method, headers: { ...headers } };\n\n if (body !== undefined) {\n (init.headers as Record<string, string>)['content-type'] = 'application/json';\n init.body = JSON.stringify(body);\n }\n\n let response: Response;\n try {\n response = await this.fetchFn(path, init);\n } catch (cause) {\n throw new PabiloError({\n message: cause instanceof Error ? cause.message : 'Network request failed',\n code: 'NETWORK_ERROR',\n raw: cause,\n });\n }\n\n let responseBody: unknown;\n try {\n responseBody = await response.json();\n } catch {\n responseBody = null;\n }\n\n if (!response.ok) {\n throw parsePabiloError(responseBody, response.status);\n }\n\n return responseBody as T;\n }\n}\n","import type { IHttpClient, RequestOptions } from '../ports/http.js';\nimport { FetchHttpClient } from './fetch-http-client.js';\n\nexport interface PabiloHttpClientOptions {\n apiKey: string;\n baseUrl?: string;\n httpClient?: IHttpClient;\n}\n\nconst DEFAULT_BASE_URL = 'https://api.pabilo.app';\n\nexport class PabiloHttpClient implements IHttpClient {\n private readonly inner: IHttpClient;\n private readonly baseUrl: string;\n private readonly apiKey: string;\n\n constructor(options: PabiloHttpClientOptions) {\n this.apiKey = options.apiKey;\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, '');\n this.inner = options.httpClient ?? new FetchHttpClient();\n }\n\n request<T>(options: RequestOptions): Promise<T> {\n const url = `${this.baseUrl}${options.path}`;\n return this.inner.request<T>({\n ...options,\n path: url,\n headers: {\n ...options.headers,\n appKey: this.apiKey,\n },\n });\n }\n}\n","import type { IHttpClient } from '../ports/http.js';\nimport type { IBankAccountsPort } from '../ports/bank-accounts.js';\nimport type { UserBank, BankAccountEntry, CreateUserBankRequest } from '../domain/types.js';\n\nexport class BankAccountsResource implements IBankAccountsPort {\n constructor(private readonly http: IHttpClient) {}\n\n async create(req: CreateUserBankRequest): Promise<UserBank> {\n // API requires user_id in the body — fetch it transparently from /me\n const meRes = await this.http.request<Record<string, unknown>>({ method: 'GET', path: '/me' });\n const userId = String(\n (meRes['user'] as Record<string, unknown> | undefined)?.['id'] ?? meRes['id'] ?? ''\n );\n\n const body = buildCreateBody(req, userId);\n const res = await this.http.request<Record<string, unknown>>({\n method: 'POST',\n path: '/usersbank',\n body,\n });\n\n // Response: { message, userbank: {...} } | { user_bank: {...} } | { data: {...} } | root\n const raw = (res['userbank'] ?? res['user_bank'] ?? res['data'] ?? res) as Record<string, unknown>;\n return normalizeUserBank(raw);\n }\n\n async delete(id: string): Promise<void> {\n await this.http.request({ method: 'DELETE', path: `/usersbank/${id}/to-trash` });\n }\n\n async list(): Promise<UserBank[]> {\n const res = await this.http.request<Record<string, unknown>>({\n method: 'GET',\n path: '/me/usersbank',\n });\n\n const raw =\n Array.isArray(res['user_banks']) ? res['user_banks'] :\n Array.isArray(res['data']) ? res['data'] :\n [];\n\n return (raw as unknown[]).map(normalizeUserBank);\n }\n}\n\nfunction normalizeUserBank(raw: unknown): UserBank {\n const b = raw as Record<string, unknown>;\n const bankAccounts = Array.isArray(b['bank_accounts'])\n ? (b['bank_accounts'] as unknown[]).map(normalizeBankAccount)\n : [];\n\n return {\n id: String(b['id'] ?? ''),\n description: String(b['description'] ?? ''),\n provider: String(b['provider'] ?? ''),\n bank_accounts: bankAccounts,\n ...(typeof b['payment_link'] === 'boolean' ? { payment_link: b['payment_link'] } : {}),\n ...(typeof b['to_trash'] === 'boolean' ? { to_trash: b['to_trash'] } : {}),\n };\n}\n\nfunction normalizeBankAccount(raw: unknown): BankAccountEntry {\n const a = raw as Record<string, unknown>;\n return {\n account_number: String(a['account_number'] ?? ''),\n account_type: String(a['account_type'] ?? a['type'] ?? ''),\n };\n}\n\nfunction buildCreateBody(req: CreateUserBankRequest, userId: string): Record<string, unknown> {\n if (req.bankProvider === 'BANK_TEST') {\n return { bank_provider: req.bankProvider, user_id: userId };\n }\n\n const body: Record<string, unknown> = {\n bank_provider: req.bankProvider,\n description: req.description,\n user_bank_phone: req.userBankPhone,\n user_bank_dni: req.userBankDni,\n user_id: userId,\n metadata: req.metadata ?? [],\n };\n\n switch (req.bankProvider) {\n case 'VE_BAN':\n body['username'] = req.username;\n body['password'] = req.password;\n break;\n case 'VE_BAN_EMP_V2':\n body['username'] = req.accountNumber;\n body['password'] = req.apiKey;\n break;\n }\n\n return body;\n}\n","import type { IHttpClient } from '../ports/http.js';\nimport type { IPaymentLinksPort } from '../ports/payment-links.js';\nimport type {\n PaymentLink,\n CreatePaymentLinkRequest,\n UpdatePaymentLinkRequest,\n} from '../domain/types.js';\n\nexport class PaymentLinksResource implements IPaymentLinksPort {\n constructor(private readonly http: IHttpClient) {}\n\n async create(req: CreatePaymentLinkRequest): Promise<PaymentLink> {\n const body: Record<string, unknown> = {\n amount: req.amount,\n description: req.description,\n user_bank_id: req.userBankId,\n currency: req.currency ?? 'VES',\n };\n if (req.redirectUrl !== undefined) body['redirect_url'] = req.redirectUrl;\n if (req.webhookUrl !== undefined) body['webhook_url'] = req.webhookUrl;\n if (req.notificationByWhatsapp !== undefined) body['notification_by_whastapp'] = req.notificationByWhatsapp;\n if (req.name !== undefined) body['name'] = req.name;\n if (req.isUsd !== undefined) body['is_usd'] = req.isUsd;\n if (req.metadata !== undefined) body['metadata'] = req.metadata;\n\n const res = await this.http.request<Record<string, unknown>>({\n method: 'POST',\n path: '/v1/paymentlink',\n body,\n });\n\n return normalizePaymentLink(res);\n }\n\n async update(id: string, req: UpdatePaymentLinkRequest): Promise<PaymentLink> {\n const body: Record<string, unknown> = {};\n if (req.amount !== undefined) body['amount'] = req.amount;\n if (req.description !== undefined) body['description'] = req.description;\n if (req.redirectUrl !== undefined) body['redirect_url'] = req.redirectUrl;\n if (req.currency !== undefined) body['currency'] = req.currency;\n\n const res = await this.http.request<Record<string, unknown>>({\n method: 'PATCH',\n path: `/paymentlink/${id}/patch`,\n body,\n });\n\n return normalizePaymentLink(res);\n }\n\n async isPaid(id: string): Promise<boolean> {\n const info = await this.getInfo(id);\n return info.status === 'paid';\n }\n\n async getInfo(id: string): Promise<PaymentLink> {\n const res = await this.http.request<Record<string, unknown>>({\n method: 'GET',\n path: `/paymentlink/${id}/info`,\n });\n return normalizePaymentLink(res);\n }\n}\n\nfunction normalizePaymentLink(raw: Record<string, unknown>): PaymentLink {\n // Shapes: { paymentlink: {...} } | { data: { payment_link: {...} } } | { data: {...} } | root\n const dataWrap = raw['data'] as Record<string, unknown> | undefined;\n const src =\n (raw['paymentlink'] as Record<string, unknown> | undefined) ??\n (dataWrap?.['payment_link'] as Record<string, unknown> | undefined) ??\n dataWrap ??\n raw;\n\n const userId = typeof src['user_id'] === 'string' ? src['user_id'] :\n typeof src['userId'] === 'string' ? src['userId'] : undefined;\n\n return {\n id: String(src['id'] ?? ''),\n url: String(src['url'] ?? ''),\n ...(typeof src['amount'] === 'number' ? { amount: src['amount'] } : {}),\n ...(typeof src['status'] === 'string' ? { status: src['status'] } : {}),\n ...(typeof src['type'] === 'string' ? { type: src['type'] } : {}),\n ...(userId !== undefined ? { userId } : {}),\n ...(typeof src['name'] === 'string' ? { name: src['name'] } : {}),\n ...(typeof src['description'] === 'string' ? { description: src['description'] } : {}),\n ...(typeof src['is_usd'] === 'boolean' ? { isUsd: src['is_usd'] } : {}),\n ...(typeof src['redirect_url'] === 'string' ? { redirectUrl: src['redirect_url'] } : {}),\n ...(typeof src['webhook_url'] === 'string' ? { webhookUrl: src['webhook_url'] } : {}),\n ...(typeof src['notification_by_whastapp'] === 'boolean' ? { notificationByWhatsapp: src['notification_by_whastapp'] } : {}),\n ...(typeof src['expiration_time'] === 'number' ? { expirationTime: src['expiration_time'] } : {}),\n ...(typeof src['payment_link_origin'] === 'string' ? { paymentLinkOrigin: src['payment_link_origin'] } : {}),\n ...(typeof src['created_at'] === 'string' ? { createdAt: src['created_at'] } : {}),\n ...(typeof src['updated_at'] === 'string' ? { updatedAt: src['updated_at'] } : {}),\n };\n}\n","import type { IHttpClient } from '../ports/http.js';\nimport type { IPaymentsPort } from '../ports/payments.js';\nimport type { VerifyPaymentRequest, VerifyPaymentResult, PaymentData } from '../domain/types.js';\n\nexport class PaymentsResource implements IPaymentsPort {\n constructor(private readonly http: IHttpClient) {}\n\n async verify(userBankId: string, req: VerifyPaymentRequest): Promise<VerifyPaymentResult> {\n // This endpoint returns HTTP 200 even for domain errors (BANK_NOT_AVAILABLE, PAYMENT_NOT_FOUND).\n // We read the raw response and interpret it ourselves instead of letting the HTTP client throw.\n const res = await this.http.request<Record<string, unknown>>({\n method: 'POST',\n path: `/userbankpayment/${userBankId}/betaserio`,\n body: {\n amount: req.amount,\n bank_reference: req.bankReference,\n movement_type: req.movementType ?? 'GENERIC',\n },\n });\n\n if (res['error'] === 'BANK_NOT_AVAILABLE') {\n return { found: false, reason: 'BANK_NOT_AVAILABLE' };\n }\n\n if (res['error'] === 'PAYMENT_NOT_FOUND') {\n return { found: false, reason: 'PAYMENT_NOT_FOUND' };\n }\n\n const data = res['data'] as Record<string, unknown> | undefined;\n if (data !== undefined) {\n return {\n found: true,\n isNew: data['is_new'] === true,\n data: data as PaymentData,\n };\n }\n\n return { found: false, reason: 'PAYMENT_NOT_FOUND' };\n }\n}\n","import type { IHttpClient } from '../ports/http.js';\nimport type { IMePort } from '../ports/me.js';\nimport type { User, Plan } from '../domain/types.js';\n\nexport class MeResource implements IMePort {\n constructor(private readonly http: IHttpClient) {}\n\n async getMe(): Promise<User> {\n const res = await this.http.request<Record<string, unknown>>({\n method: 'GET',\n path: '/me',\n });\n const u = (res['user'] ?? res) as Record<string, unknown>;\n return {\n id: String(u['id'] ?? ''),\n ...(typeof u['email'] === 'string' ? { email: u['email'] } : {}),\n ...(typeof u['name'] === 'string' ? { name: u['name'] } : {}),\n };\n }\n\n async getPlan(): Promise<Plan> {\n const res = await this.http.request<Record<string, unknown>>({\n method: 'GET',\n path: '/me/plan',\n });\n return {\n name: String(res['name'] ?? ''),\n ...(typeof res['planType'] === 'string' ? { planType: res['planType'] } : {}),\n };\n }\n}\n","import { PabiloHttpClient } from './infrastructure/pabilo-http-client.js';\nimport { BankAccountsResource } from './resources/bank-accounts.resource.js';\nimport { PaymentLinksResource } from './resources/payment-links.resource.js';\nimport { PaymentsResource } from './resources/payments.resource.js';\nimport { MeResource } from './resources/me.resource.js';\nimport type { IHttpClient } from './ports/http.js';\nimport type { IBankAccountsPort } from './ports/bank-accounts.js';\nimport type { IPaymentLinksPort } from './ports/payment-links.js';\nimport type { IPaymentsPort } from './ports/payments.js';\nimport type { IMePort } from './ports/me.js';\n\nexport interface PabiloClientOptions {\n apiKey: string;\n baseUrl?: string;\n httpClient?: IHttpClient;\n}\n\nexport class PabiloClient {\n readonly me: IMePort;\n readonly bankAccounts: IBankAccountsPort;\n readonly paymentLinks: IPaymentLinksPort;\n readonly payments: IPaymentsPort;\n\n constructor(options: PabiloClientOptions) {\n const http: IHttpClient = options.httpClient ?? new PabiloHttpClient({\n apiKey: options.apiKey,\n ...(options.baseUrl !== undefined ? { baseUrl: options.baseUrl } : {}),\n });\n\n this.me = new MeResource(http);\n this.bankAccounts = new BankAccountsResource(http);\n this.paymentLinks = new PaymentLinksResource(http);\n this.payments = new PaymentsResource(http);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/domain/errors.ts","../src/infrastructure/fetch-http-client.ts","../src/infrastructure/pabilo-http-client.ts","../src/resources/bank-accounts.resource.ts","../src/resources/payment-links.resource.ts","../src/resources/payments.resource.ts","../src/resources/me.resource.ts","../src/client.ts"],"names":["code"],"mappings":";;;AAAO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EAKrC,YAAY,IAAA,EAKT;AACD,IAAA,KAAA,CAAM,KAAK,OAAO,CAAA;AAClB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,aAAa,IAAA,CAAK,UAAA;AACvB,IAAA,IAAA,CAAK,MAAM,IAAA,CAAK,GAAA;AAChB,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAEO,SAAS,gBAAA,CAAiB,MAAe,UAAA,EAAiC;AAC/E,EAAA,IAAI,eAAe,GAAA,EAAK;AACtB,IAAA,OAAO,IAAI,WAAA,CAAY,EAAE,OAAA,EAAS,cAAA,EAAgB,MAAM,cAAA,EAAgB,UAAA,EAAY,GAAA,EAAK,IAAA,EAAM,CAAA;AAAA,EACjG;AACA,EAAA,IAAI,eAAe,GAAA,EAAK;AACtB,IAAA,OAAO,IAAI,WAAA,CAAY,EAAE,OAAA,EAAS,WAAA,EAAa,MAAM,WAAA,EAAa,UAAA,EAAY,GAAA,EAAK,IAAA,EAAM,CAAA;AAAA,EAC3F;AAEA,EAAA,IAAI,IAAA,KAAS,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,EAAU;AAC7C,IAAA,MAAM,CAAA,GAAI,IAAA;AACV,IAAA,MAAMA,KAAAA,GAAO,OAAO,CAAA,CAAE,OAAO,CAAA,KAAM,WAAW,CAAA,CAAE,OAAO,CAAA,GAAI,qBAAA,CAAsB,UAAU,CAAA;AAC3F,IAAA,MAAM,O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AY,EAAC;AAAA,MAC9G,GAAI,OAAO,GAAA,CAAI,sBAAsB,CAAA,KAAM,QAAA,GAAc,EAAE,oBAAA,EAAsB,GAAA,CAAI,sBAAsB,CAAA,EAAE,GAAI,EAAC;AAAA,MAClH,GAAI,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,UAAU,CAAC,CAAA,GAAwB,EAAE,QAAA,EAAU,GAAA,CAAI,UAAU,CAAA,KAAuC,EAAC;AAAA,MAC3H,GAAI,OAAO,GAAA,CAAI,SAAS,CAAA,KAAM,SAAA,GAA2B,EAAE,OAAA,EAAS,GAAA,CAAI,SAAS,CAAA,EAAE,GAA0B,EAAC;AAAA,MAC9G,GAAI,OAAO,GAAA,CAAI,QAAQ,CAAA,KAAM,SAAA,GAA4B,EAAE,MAAA,EAAQ,GAAA,CAAI,QAAQ,CAAA,EAAE,GAA4B;AAAC,KAChH;AAAA,EACF;AACF,CAAA;;;AChCO,IAAM,eAAN,MAAmB;AAAA,EAMxB,YAAY,OAAA,EAA8B;AACxC,IAAA,MAAM,IAAA,GAAoB,OAAA,CAAQ,UAAA,IAAc,IAAI,gBAAA,CAAiB;AAAA,MACnE,QAAQ,OAAA,CAAQ,MAAA;AAAA,MAChB,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ,GAAI;AAAC,KACrE,CAAA;AAED,IAAA,IAAA,CAAK,EAAA,GAAK,IAAI,UAAA,CAAW,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,YAAA,GAAe,IAAI,oBAAA,CAAqB,IAAI,CAAA;AACjD,IAAA,IAAA,CAAK,YAAA,GAAe,IAAI,oBAAA,CAAqB,IAAI,CAAA;AACjD,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,gBAAA,CAAiB,IAAI,CAAA;AAAA,EAC3C;AACF","file":"index.cjs","sourcesContent":["export class PabiloError extends Error {\n readonly code: string;\n readonly statusCode: number | undefined;\n readonly raw: unknown;\n\n constructor(opts: {\n message: string;\n code: string;\n statusCode?: number;\n raw?: unknown;\n }) {\n super(opts.message);\n this.name = 'PabiloError';\n this.code = opts.code;\n this.statusCode = opts.statusCode;\n this.raw = opts.raw;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport function parsePabiloError(body: unknown, statusCode: number): PabiloError {\n if (statusCode === 401) {\n return new PabiloError({ message: 'Unauthorized', code: 'UNAUTHORIZED', statusCode, raw: body });\n }\n if (statusCode === 404) {\n return new PabiloError({ message: 'Not found', code: 'NOT_FOUND', statusCode, raw: body });\n }\n\n if (body !== null && typeof body === 'object') {\n const b = body as Record<string, unknown>;\n const code = typeof b['error'] === 'string' ? b['error'] : resolveCodeFromStatus(statusCode);\n const message = typeof b['message'] === 'string' ? b['message'] : code;\n return new PabiloError({ message, code, statusCode, raw: body });\n }\n\n const code = resolveCodeFromStatus(statusCode);\n return new PabiloError({ message: code, code, statusCode, raw: body });\n}\n\nfunction resolveCodeFromStatus(statusCode: number): string {\n if (statusCode >= 500) return 'INTERNAL_SERVER_ERROR';\n if (statusCode === 400) return 'BAD_REQUEST';\n return 'REQUEST_FAILED';\n}\n","import type { IHttpClient, RequestOptions } from '../ports/http.js';\nimport { PabiloError, parsePabiloError } from '../domain/errors.js';\n\ntype FetchFn = typeof globalThis.fetch;\n\nexport class FetchHttpClient implements IHttpClient {\n private readonly fetchFn: FetchFn;\n\n constructor(fetchImpl?: FetchFn) {\n this.fetchFn = fetchImpl ?? globalThis.fetch.bind(globalThis);\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const { method, path, body, headers = {} } = options;\n\n const init: RequestInit = { method, headers: { ...headers } };\n\n if (body !== undefined) {\n (init.headers as Record<string, string>)['content-type'] = 'application/json';\n init.body = JSON.stringify(body);\n }\n\n let response: Response;\n try {\n response = await this.fetchFn(path, init);\n } catch (cause) {\n throw new PabiloError({\n message: cause instanceof Error ? cause.message : 'Network request failed',\n code: 'NETWORK_ERROR',\n raw: cause,\n });\n }\n\n let responseBody: unknown;\n try {\n responseBody = await response.json();\n } catch {\n responseBody = null;\n }\n\n if (!response.ok) {\n throw parsePabiloError(responseBody, response.status);\n }\n\n return responseBody as T;\n }\n}\n","import type { IHttpClient, RequestOptions } from '../ports/http.js';\nimport { FetchHttpClient } from './fetch-http-client.js';\n\nexport interface PabiloHttpClientOptions {\n apiKey: string;\n baseUrl?: string;\n httpClient?: IHttpClient;\n}\n\nconst DEFAULT_BASE_URL = 'https://api.pabilo.app';\n\nexport class PabiloHttpClient implements IHttpClient {\n private readonly inner: IHttpClient;\n private readonly baseUrl: string;\n private readonly apiKey: string;\n\n constructor(options: PabiloHttpClientOptions) {\n this.apiKey = options.apiKey;\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, '');\n this.inner = options.httpClient ?? new FetchHttpClient();\n }\n\n request<T>(options: RequestOptions): Promise<T> {\n const url = `${this.baseUrl}${options.path}`;\n return this.inner.request<T>({\n ...options,\n path: url,\n headers: {\n ...options.headers,\n appKey: this.apiKey,\n },\n });\n }\n}\n","import type { IHttpClient } from '../ports/http.js';\nimport type { IBankAccountsPort } from '../ports/bank-accounts.js';\nimport type { UserBank, BankAccountEntry, CreateUserBankRequest } from '../domain/types.js';\n\nexport class BankAccountsResource implements IBankAccountsPort {\n constructor(private readonly http: IHttpClient) {}\n\n async create(req: CreateUserBankRequest): Promise<UserBank> {\n // API requires user_id in the body — fetch it transparently from /me\n const meRes = await this.http.request<Record<string, unknown>>({ method: 'GET', path: '/me' });\n const userId = String(\n (meRes['user'] as Record<string, unknown> | undefined)?.['id'] ?? meRes['id'] ?? ''\n );\n\n const body = buildCreateBody(req, userId);\n const res = await this.http.request<Record<string, unknown>>({\n method: 'POST',\n path: '/usersbank',\n body,\n });\n\n // Response: { message, userbank: {...} } | { user_bank: {...} } | { data: {...} } | root\n const raw = (res['userbank'] ?? res['user_bank'] ?? res['data'] ?? res) as Record<string, unknown>;\n return normalizeUserBank(raw);\n }\n\n async delete(id: string): Promise<void> {\n await this.http.request({ method: 'DELETE', path: `/usersbank/${id}/to-trash` });\n }\n\n async list(): Promise<UserBank[]> {\n const res = await this.http.request<Record<string, unknown>>({\n method: 'GET',\n path: '/me/usersbank',\n });\n\n const raw =\n Array.isArray(res['user_banks']) ? res['user_banks'] :\n Array.isArray(res['data']) ? res['data'] :\n [];\n\n return (raw as unknown[]).map(normalizeUserBank);\n }\n}\n\nfunction normalizeUserBank(raw: unknown): UserBank {\n const b = raw as Record<string, unknown>;\n const bankAccounts = Array.isArray(b['bank_accounts'])\n ? (b['bank_accounts'] as unknown[]).map(normalizeBankAccount)\n : [];\n\n return {\n id: String(b['id'] ?? ''),\n description: String(b['description'] ?? ''),\n provider: String(b['provider'] ?? ''),\n bank_accounts: bankAccounts,\n ...(typeof b['payment_link'] === 'boolean' ? { payment_link: b['payment_link'] } : {}),\n ...(typeof b['to_trash'] === 'boolean' ? { to_trash: b['to_trash'] } : {}),\n };\n}\n\nfunction normalizeBankAccount(raw: unknown): BankAccountEntry {\n const a = raw as Record<string, unknown>;\n return {\n account_number: String(a['account_number'] ?? ''),\n account_type: String(a['account_type'] ?? a['type'] ?? ''),\n };\n}\n\nfunction buildCreateBody(req: CreateUserBankRequest, userId: string): Record<string, unknown> {\n if (req.bankProvider === 'BANK_TEST') {\n return { bank_provider: req.bankProvider, user_id: userId };\n }\n\n const body: Record<string, unknown> = {\n bank_provider: req.bankProvider,\n description: req.description,\n user_bank_phone: req.userBankPhone,\n user_bank_dni: req.userBankDni,\n user_id: userId,\n metadata: req.metadata ?? [],\n };\n\n switch (req.bankProvider) {\n case 'VE_BAN':\n body['username'] = req.username;\n body['password'] = req.password;\n break;\n case 'VE_BAN_EMP_V2':\n body['username'] = req.accountNumber;\n body['password'] = req.apiKey;\n break;\n }\n\n return body;\n}\n","import type { IHttpClient } from '../ports/http.js';\nimport type { IPaymentLinksPort } from '../ports/payment-links.js';\nimport type {\n PaymentLink,\n CreatePaymentLinkRequest,\n UpdatePaymentLinkRequest,\n ListPaymentLinksRequest,\n PaymentLinksPage,\n} from '../domain/types.js';\n\nexport class PaymentLinksResource implements IPaymentLinksPort {\n constructor(private readonly http: IHttpClient) {}\n\n async list(req?: ListPaymentLinksRequest): Promise<PaymentLinksPage> {\n // The backend uses a custom QUERY method (converted to POST server-side).\n // Parameters are sent as a JSON body, not query string.\n const body: Record<string, unknown> = {\n page: req?.page ?? 1,\n limit: req?.limit ?? 10,\n };\n if (req?.type !== undefined) body['type'] = req.type;\n if (req?.status !== undefined) body['status'] = req.status;\n if (req?.search !== undefined) body['search'] = req.search;\n\n const res = await this.http.request<Record<string, unknown>>({\n method: 'POST',\n path: '/me/payment-links',\n body,\n });\n\n const raw = Array.isArray(res['payment_links']) ? res['payment_links'] : [];\n return {\n items: (raw as unknown[]).map(item => normalizePaymentLink(item as Record<string, unknown>)),\n total: typeof res['total'] === 'number' ? res['total'] : 0,\n page: typeof res['page'] === 'number' ? res['page'] : 1,\n limit: typeof res['limit'] === 'number' ? res['limit'] : raw.length,\n };\n }\n\n async create(req: CreatePaymentLinkRequest): Promise<PaymentLink> {\n const body: Record<string, unknown> = {\n amount: req.amount,\n description: req.description,\n user_bank_id: req.userBankId,\n currency: req.currency ?? 'VES',\n };\n if (req.redirectUrl !== undefined) body['redirect_url'] = req.redirectUrl;\n if (req.webhookUrl !== undefined) body['webhook_url'] = req.webhookUrl;\n if (req.notificationByWhatsapp !== undefined) body['notification_by_whastapp'] = req.notificationByWhatsapp;\n if (req.name !== undefined) body['name'] = req.name;\n if (req.isUsd !== undefined) body['is_usd'] = req.isUsd;\n if (req.metadata !== undefined) body['metadata'] = req.metadata;\n\n const res = await this.http.request<Record<string, unknown>>({\n method: 'POST',\n path: '/v1/paymentlink',\n body,\n });\n\n return normalizePaymentLink(res);\n }\n\n async update(id: string, req: UpdatePaymentLinkRequest): Promise<PaymentLink> {\n const body: Record<string, unknown> = {};\n if (req.amount !== undefined) body['amount'] = req.amount;\n if (req.description !== undefined) body['description'] = req.description;\n if (req.redirectUrl !== undefined) body['redirect_url'] = req.redirectUrl;\n if (req.currency !== undefined) body['currency'] = req.currency;\n\n const res = await this.http.request<Record<string, unknown>>({\n method: 'PATCH',\n path: `/paymentlink/${id}/patch`,\n body,\n });\n\n return normalizePaymentLink(res);\n }\n\n async isPaid(id: string): Promise<boolean> {\n const info = await this.getInfo(id);\n return info.status === 'paid';\n }\n\n async getInfo(id: string): Promise<PaymentLink> {\n const res = await this.http.request<Record<string, unknown>>({\n method: 'GET',\n path: `/paymentlink/${id}/info`,\n });\n return normalizePaymentLink(res);\n }\n}\n\nfunction normalizePaymentLink(raw: Record<string, unknown>): PaymentLink {\n // Shapes: { paymentlink: {...} } | { data: { payment_link: {...} } } | { data: {...} } | root\n const dataWrap = raw['data'] as Record<string, unknown> | undefined;\n const src =\n (raw['paymentlink'] as Record<string, unknown> | undefined) ??\n (dataWrap?.['payment_link'] as Record<string, unknown> | undefined) ??\n dataWrap ??\n raw;\n\n const userId = typeof src['user_id'] === 'string' ? src['user_id'] :\n typeof src['userId'] === 'string' ? src['userId'] : undefined;\n\n return {\n id: String(src['id'] ?? ''),\n url: String(src['url'] ?? ''),\n ...(typeof src['amount'] === 'number' ? { amount: src['amount'] } : {}),\n ...(typeof src['status'] === 'string' ? { status: src['status'] } : {}),\n ...(typeof src['status_detail'] === 'string' ? { statusDetail: src['status_detail'] } : {}),\n ...(typeof src['type'] === 'string' ? { type: src['type'] } : {}),\n ...(userId !== undefined ? { userId } : {}),\n ...(typeof src['user_bank_id'] === 'string' ? { userBankId: src['user_bank_id'] } : {}),\n ...(typeof src['with_subscription_id'] === 'string' ? { withSubscriptionId: src['with_subscription_id'] } : {}),\n ...(typeof src['name'] === 'string' ? { name: src['name'] } : {}),\n ...(typeof src['description'] === 'string' ? { description: src['description'] } : {}),\n ...(typeof src['is_usd'] === 'boolean' ? { isUsd: src['is_usd'] } : {}),\n ...(typeof src['redirect_url'] === 'string' ? { redirectUrl: src['redirect_url'] } : {}),\n ...(typeof src['webhook_url'] === 'string' ? { webhookUrl: src['webhook_url'] } : {}),\n ...(typeof src['webhook_method'] === 'string' ? { webhookMethod: src['webhook_method'] } : {}),\n ...(typeof src['notification_by_whastapp'] === 'boolean' ? { notificationByWhatsapp: src['notification_by_whastapp'] } : {}),\n ...(typeof src['expiration_time'] === 'number' ? { expirationTime: src['expiration_time'] } : {}),\n ...(typeof src['payment_link_origin'] === 'string' ? { paymentLinkOrigin: src['payment_link_origin'] } : {}),\n ...(typeof src['created_at'] === 'string' ? { createdAt: src['created_at'] } : {}),\n ...(typeof src['updated_at'] === 'string' ? { updatedAt: src['updated_at'] } : {}),\n };\n}\n","import type { IHttpClient } from '../ports/http.js';\nimport type { IPaymentsPort } from '../ports/payments.js';\nimport type { VerifyPaymentRequest, VerifyPaymentResult, PaymentData } from '../domain/types.js';\n\nexport class PaymentsResource implements IPaymentsPort {\n constructor(private readonly http: IHttpClient) {}\n\n async verify(userBankId: string, req: VerifyPaymentRequest): Promise<VerifyPaymentResult> {\n // This endpoint returns HTTP 200 even for domain errors (BANK_NOT_AVAILABLE, PAYMENT_NOT_FOUND).\n // We read the raw response and interpret it ourselves instead of letting the HTTP client throw.\n const res = await this.http.request<Record<string, unknown>>({\n method: 'POST',\n path: `/userbankpayment/${userBankId}/betaserio`,\n body: {\n amount: req.amount,\n bank_reference: req.bankReference,\n movement_type: req.movementType ?? 'GENERIC',\n },\n });\n\n if (res['error'] === 'BANK_NOT_AVAILABLE') {\n return { found: false, reason: 'BANK_NOT_AVAILABLE' };\n }\n\n if (res['error'] === 'PAYMENT_NOT_FOUND') {\n return { found: false, reason: 'PAYMENT_NOT_FOUND' };\n }\n\n const data = res['data'] as Record<string, unknown> | undefined;\n if (data !== undefined) {\n return {\n found: true,\n isNew: data['is_new'] === true,\n data: data as PaymentData,\n };\n }\n\n return { found: false, reason: 'PAYMENT_NOT_FOUND' };\n }\n}\n","import type { IHttpClient } from '../ports/http.js';\nimport type { IMePort } from '../ports/me.js';\nimport type { User, Plan } from '../domain/types.js';\n\nexport class MeResource implements IMePort {\n constructor(private readonly http: IHttpClient) {}\n\n async getMe(): Promise<User> {\n const res = await this.http.request<Record<string, unknown>>({\n method: 'GET',\n path: '/me',\n });\n const u = (res['user'] ?? res) as Record<string, unknown>;\n return {\n id: String(u['id'] ?? ''),\n ...(typeof u['email'] === 'string' ? { email: u['email'] } : {}),\n ...(typeof u['username'] === 'string' ? { username: u['username'] } : {}),\n ...(typeof u['full_name'] === 'string' ? { fullName: u['full_name'] } : {}),\n ...(typeof u['company_name'] === 'string' ? { companyName: u['company_name'] } : {}),\n ...(typeof u['credits'] === 'number' ? { credits: u['credits'] } : {}),\n ...(typeof u['plan_is_active'] === 'boolean' ? { planIsActive: u['plan_is_active'] } : {}),\n ...(typeof u['is_demo'] === 'boolean' ? { isDemo: u['is_demo'] } : {}),\n ...(typeof u['user_type'] === 'string' ? { userType: u['user_type'] } : {}),\n };\n }\n\n async getPlan(): Promise<Plan> {\n const raw = await this.http.request<Record<string, unknown>>({\n method: 'GET',\n path: '/me/plan',\n });\n // Response: { message, plan: { ... } }\n const res = (raw['plan'] as Record<string, unknown> | undefined) ?? raw;\n return {\n name: String(res['name'] ?? ''),\n ...(typeof res['id'] === 'string' ? { id: res['id'] } : {}),\n ...(typeof res['description'] === 'string' ? { description: res['description'] } : {}),\n ...(typeof res['planType'] === 'string' ? { planType: res['planType'] } : {}),\n ...(typeof res['period'] === 'string' ? { period: res['period'] } : {}),\n ...(typeof res['price'] === 'number' ? { price: res['price'] } : {}),\n ...(typeof res['requestLimit'] === 'number' ? { requestLimit: res['requestLimit'] } : {}),\n ...(typeof res['bankAccountLimit'] === 'number' ? { bankAccountLimit: res['bankAccountLimit'] } : {}),\n ...(typeof res['initialCredits'] === 'number' ? { initialCredits: res['initialCredits'] } : {}),\n ...(typeof res['maxAcumulatedCredits'] === 'number' ? { maxAcumulatedCredits: res['maxAcumulatedCredits'] } : {}),\n ...(Array.isArray(res['benefits']) ? { benefits: res['benefits'] as NonNullable<Plan['benefits']> } : {}),\n ...(typeof res['salient'] === 'boolean' ? { salient: res['salient'] } : {}),\n ...(typeof res['hidden'] === 'boolean' ? { hidden: res['hidden'] } : {}),\n };\n }\n}\n","import { PabiloHttpClient } from './infrastructure/pabilo-http-client.js';\nimport { BankAccountsResource } from './resources/bank-accounts.resource.js';\nimport { PaymentLinksResource } from './resources/payment-links.resource.js';\nimport { PaymentsResource } from './resources/payments.resource.js';\nimport { MeResource } from './resources/me.resource.js';\nimport type { IHttpClient } from './ports/http.js';\nimport type { IBankAccountsPort } from './ports/bank-accounts.js';\nimport type { IPaymentLinksPort } from './ports/payment-links.js';\nimport type { IPaymentsPort } from './ports/payments.js';\nimport type { IMePort } from './ports/me.js';\n\nexport interface PabiloClientOptions {\n apiKey: string;\n baseUrl?: string;\n httpClient?: IHttpClient;\n}\n\nexport class PabiloClient {\n readonly me: IMePort;\n readonly bankAccounts: IBankAccountsPort;\n readonly paymentLinks: IPaymentLinksPort;\n readonly payments: IPaymentsPort;\n\n constructor(options: PabiloClientOptions) {\n const http: IHttpClient = options.httpClient ?? new PabiloHttpClient({\n apiKey: options.apiKey,\n ...(options.baseUrl !== undefined ? { baseUrl: options.baseUrl } : {}),\n });\n\n this.me = new MeResource(http);\n this.bankAccounts = new BankAccountsResource(http);\n this.paymentLinks = new PaymentLinksResource(http);\n this.payments = new PaymentsResource(http);\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -8,11 +8,17 @@ interface IHttpClient {
|
|
|
8
8
|
request<T>(options: RequestOptions): Promise<T>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
type BankProvider = '
|
|
11
|
+
type BankProvider = 'VE_BAN' | 'VE_BAN_EMP' | 'VE_BAN_EMP_V2' | 'VE_PROV' | 'VE_PROV_EMP' | 'BANK_TEST' | 'MERCANTIL_EMP_TEST_V1' | 'MERCANTIL_EMP_V1' | (string & Record<never, never>);
|
|
12
12
|
type AccountType = 'SAVINGS' | 'CHECKING' | (string & Record<never, never>);
|
|
13
|
-
type PaymentLinkStatus = 'pending' | 'paid' | '
|
|
14
|
-
type PaymentLinkType = 'default' | 'fixed' | (string & Record<never, never>);
|
|
15
|
-
type
|
|
13
|
+
type PaymentLinkStatus = 'pending' | 'active' | 'paid' | 'failed' | 'canceled' | 'expired' | 'stopped' | (string & Record<never, never>);
|
|
14
|
+
type PaymentLinkType = 'default' | 'fixed' | 'subscription' | 'donation' | (string & Record<never, never>);
|
|
15
|
+
type PaymentLinkOrigin = 'pabilo' | 'api' | (string & Record<never, never>);
|
|
16
|
+
type MovementType = 'GENERIC' | 'MOVIL_PAY' | 'TRANSFER' | 'C2P' | (string & Record<never, never>);
|
|
17
|
+
type UserBankPaymentStatus = 'pending' | 'paid' | 'failed' | (string & Record<never, never>);
|
|
18
|
+
type UserType = 'system' | 'user' | 'admin' | 'test' | 'commerce' | (string & Record<never, never>);
|
|
19
|
+
type PlanType = 'credit' | 'unlimited' | 'counter' | (string & Record<never, never>);
|
|
20
|
+
type PlanPeriod = 'month' | 'six_months' | 'year' | (string & Record<never, never>);
|
|
21
|
+
type PabiloErrorCode = 'BANK_NOT_AVAILABLE' | 'PAYMENT_NOT_FOUND' | 'BAD_REQUEST' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'INTERNAL_SERVER_ERROR' | 'INTERNAL_ERROR' | 'NETWORK_ERROR' | 'REQUEST_FAILED' | 'MISSING_CONFIG' | 'REQUEST_LIMIT_REACHED' | 'BANK_ACCOUNT_LIMIT_REACHED' | 'USER_BANK_ALREADY_EXISTS' | 'USER_BANCK_NOT_FOUND' | 'USER_BANCK_BAD_PASSWORD' | 'USER_BANCK_PASSWORD_EXPIRED' | 'INVALID_MOVEMENT_TYPE' | 'INVALID_PHONE' | 'MOVEMENT_TYPE_REQUIRED' | 'INVALID_BANK_PROVIDER' | 'PLAN_IS_NOT_ACTIVE' | 'USER_IS_NOT_ACTIVE' | 'NOT_ENOUGH_CREDITS' | 'THIS_EMAIL_ALREADY_EXISTS' | 'THIS_USERNAME_ALREADY_EXISTS' | 'PLAN_IS_ALREADY_ACTIVE' | 'RENOVATION_IS_ALREADY_PAID' | 'GET_DOLAR_PRICE_FAILED' | 'PAYMENT_AMOUNT_NOT_VALID' | 'PAYMENT_ALREADY_EXISTS' | 'IS_NOT_POSITIVE_PAYMENT' | 'IS_NOT_POSITIVE_AMOUNT' | 'PAGE_NOT_FOUND' | 'SESSION_ALREADY_ACTIVE' | 'PROXY_ERROR' | 'NOT_IMPLEMENTED' | 'METHOD_NOT_SUPPORT' | 'COORDINATE_KEY_EXTRACTION_FAILED' | 'COORDINATE_KEY_NOT_VALID' | 'BANK_TEMPORARILY_INACTIVE' | 'BANK_TOO_MANY_REQUESTS' | (string & Record<never, never>);
|
|
16
22
|
interface BankAccountEntry {
|
|
17
23
|
account_number: string;
|
|
18
24
|
account_type: AccountType;
|
|
@@ -28,27 +34,52 @@ interface UserBank {
|
|
|
28
34
|
interface User {
|
|
29
35
|
id: string;
|
|
30
36
|
email?: string;
|
|
31
|
-
|
|
37
|
+
username?: string;
|
|
38
|
+
fullName?: string;
|
|
39
|
+
companyName?: string;
|
|
40
|
+
credits?: number;
|
|
41
|
+
planIsActive?: boolean;
|
|
42
|
+
isDemo?: boolean;
|
|
43
|
+
userType?: UserType;
|
|
44
|
+
}
|
|
45
|
+
interface PlanBenefit {
|
|
46
|
+
description: string;
|
|
47
|
+
contain: boolean;
|
|
32
48
|
}
|
|
33
49
|
interface Plan {
|
|
50
|
+
id?: string;
|
|
34
51
|
name: string;
|
|
35
|
-
|
|
52
|
+
description?: string;
|
|
53
|
+
planType?: PlanType;
|
|
54
|
+
period?: PlanPeriod;
|
|
55
|
+
price?: number;
|
|
56
|
+
requestLimit?: number;
|
|
57
|
+
bankAccountLimit?: number;
|
|
58
|
+
initialCredits?: number;
|
|
59
|
+
maxAcumulatedCredits?: number;
|
|
60
|
+
benefits?: PlanBenefit[];
|
|
61
|
+
salient?: boolean;
|
|
62
|
+
hidden?: boolean;
|
|
36
63
|
}
|
|
37
64
|
interface PaymentLink {
|
|
38
65
|
id: string;
|
|
39
66
|
url: string;
|
|
40
67
|
amount?: number;
|
|
41
68
|
status?: PaymentLinkStatus;
|
|
69
|
+
statusDetail?: string;
|
|
42
70
|
type?: PaymentLinkType;
|
|
43
71
|
userId?: string;
|
|
72
|
+
userBankId?: string;
|
|
73
|
+
withSubscriptionId?: string;
|
|
44
74
|
name?: string;
|
|
45
75
|
description?: string;
|
|
46
76
|
isUsd?: boolean;
|
|
47
77
|
redirectUrl?: string;
|
|
48
78
|
webhookUrl?: string;
|
|
79
|
+
webhookMethod?: string;
|
|
49
80
|
notificationByWhatsapp?: boolean;
|
|
50
81
|
expirationTime?: number;
|
|
51
|
-
paymentLinkOrigin?:
|
|
82
|
+
paymentLinkOrigin?: PaymentLinkOrigin;
|
|
52
83
|
createdAt?: string;
|
|
53
84
|
updatedAt?: string;
|
|
54
85
|
}
|
|
@@ -70,11 +101,11 @@ interface UserBankPayment {
|
|
|
70
101
|
user_id: string;
|
|
71
102
|
amount: number;
|
|
72
103
|
user_bank_id: string;
|
|
73
|
-
status:
|
|
104
|
+
status: UserBankPaymentStatus;
|
|
74
105
|
credit_cost: number;
|
|
75
106
|
payment_params: PaymentParams;
|
|
76
107
|
confirmed_status: boolean;
|
|
77
|
-
details
|
|
108
|
+
details?: unknown[];
|
|
78
109
|
}
|
|
79
110
|
interface PaymentData {
|
|
80
111
|
is_new: boolean;
|
|
@@ -84,6 +115,33 @@ interface PaymentData {
|
|
|
84
115
|
user_credits_total_in_usd?: number;
|
|
85
116
|
[key: string]: unknown;
|
|
86
117
|
}
|
|
118
|
+
interface PaymentLinkWebhookPayload {
|
|
119
|
+
id: string;
|
|
120
|
+
created_at: string;
|
|
121
|
+
updated_at: string;
|
|
122
|
+
payment_link_id: string;
|
|
123
|
+
status: PaymentLinkStatus;
|
|
124
|
+
payment_link?: PaymentLink;
|
|
125
|
+
user_bank_payment?: UserBankPayment;
|
|
126
|
+
credit_balance: number;
|
|
127
|
+
metadata: Array<{
|
|
128
|
+
key: string;
|
|
129
|
+
value: string;
|
|
130
|
+
}>;
|
|
131
|
+
}
|
|
132
|
+
interface ListPaymentLinksRequest {
|
|
133
|
+
page?: number;
|
|
134
|
+
limit?: number;
|
|
135
|
+
type?: PaymentLinkType;
|
|
136
|
+
status?: PaymentLinkStatus;
|
|
137
|
+
search?: string;
|
|
138
|
+
}
|
|
139
|
+
interface PaymentLinksPage {
|
|
140
|
+
items: PaymentLink[];
|
|
141
|
+
total: number;
|
|
142
|
+
page: number;
|
|
143
|
+
limit: number;
|
|
144
|
+
}
|
|
87
145
|
interface CreatePaymentLinkRequest {
|
|
88
146
|
amount: number;
|
|
89
147
|
description: string;
|
|
@@ -105,7 +163,7 @@ interface UpdatePaymentLinkRequest {
|
|
|
105
163
|
interface VerifyPaymentRequest {
|
|
106
164
|
amount: number;
|
|
107
165
|
bankReference: string;
|
|
108
|
-
movementType?:
|
|
166
|
+
movementType?: MovementType;
|
|
109
167
|
}
|
|
110
168
|
type VerifyPaymentResult = {
|
|
111
169
|
found: false;
|
|
@@ -147,6 +205,7 @@ interface IBankAccountsPort {
|
|
|
147
205
|
}
|
|
148
206
|
|
|
149
207
|
interface IPaymentLinksPort {
|
|
208
|
+
list(req?: ListPaymentLinksRequest): Promise<PaymentLinksPage>;
|
|
150
209
|
create(req: CreatePaymentLinkRequest): Promise<PaymentLink>;
|
|
151
210
|
update(id: string, req: UpdatePaymentLinkRequest): Promise<PaymentLink>;
|
|
152
211
|
getInfo(id: string): Promise<PaymentLink>;
|
|
@@ -207,4 +266,4 @@ declare class PabiloHttpClient implements IHttpClient {
|
|
|
207
266
|
request<T>(options: RequestOptions): Promise<T>;
|
|
208
267
|
}
|
|
209
268
|
|
|
210
|
-
export { type AccountType, type BankAccountEntry, type BankProvider, type CreateBankTestRequest, type CreatePaymentLinkRequest, type CreateUserBankRequest, type CreateVeBanEmpV2Request, type CreateVeBanRequest, FetchHttpClient, type IBankAccountsPort, type IHttpClient, type IMePort, type IPaymentLinksPort, type IPaymentsPort, PabiloClient, type PabiloClientOptions, PabiloError, type PabiloErrorCode, PabiloHttpClient, type PabiloHttpClientOptions, type PaymentData, type PaymentLink, type PaymentLinkStatus, type PaymentLinkType, type PaymentParams, type Plan, type RequestOptions, type UpdatePaymentLinkRequest, type User, type UserBank, type UserBankMetadataEntry, type UserBankPayment, type VerifyPaymentRequest, type VerifyPaymentResult };
|
|
269
|
+
export { type AccountType, type BankAccountEntry, type BankProvider, type CreateBankTestRequest, type CreatePaymentLinkRequest, type CreateUserBankRequest, type CreateVeBanEmpV2Request, type CreateVeBanRequest, FetchHttpClient, type IBankAccountsPort, type IHttpClient, type IMePort, type IPaymentLinksPort, type IPaymentsPort, type ListPaymentLinksRequest, type MovementType, PabiloClient, type PabiloClientOptions, PabiloError, type PabiloErrorCode, PabiloHttpClient, type PabiloHttpClientOptions, type PaymentData, type PaymentLink, type PaymentLinkOrigin, type PaymentLinkStatus, type PaymentLinkType, type PaymentLinkWebhookPayload, type PaymentLinksPage, type PaymentParams, type Plan, type PlanBenefit, type PlanPeriod, type PlanType, type RequestOptions, type UpdatePaymentLinkRequest, type User, type UserBank, type UserBankMetadataEntry, type UserBankPayment, type UserBankPaymentStatus, type UserType, type VerifyPaymentRequest, type VerifyPaymentResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,11 +8,17 @@ interface IHttpClient {
|
|
|
8
8
|
request<T>(options: RequestOptions): Promise<T>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
type BankProvider = '
|
|
11
|
+
type BankProvider = 'VE_BAN' | 'VE_BAN_EMP' | 'VE_BAN_EMP_V2' | 'VE_PROV' | 'VE_PROV_EMP' | 'BANK_TEST' | 'MERCANTIL_EMP_TEST_V1' | 'MERCANTIL_EMP_V1' | (string & Record<never, never>);
|
|
12
12
|
type AccountType = 'SAVINGS' | 'CHECKING' | (string & Record<never, never>);
|
|
13
|
-
type PaymentLinkStatus = 'pending' | 'paid' | '
|
|
14
|
-
type PaymentLinkType = 'default' | 'fixed' | (string & Record<never, never>);
|
|
15
|
-
type
|
|
13
|
+
type PaymentLinkStatus = 'pending' | 'active' | 'paid' | 'failed' | 'canceled' | 'expired' | 'stopped' | (string & Record<never, never>);
|
|
14
|
+
type PaymentLinkType = 'default' | 'fixed' | 'subscription' | 'donation' | (string & Record<never, never>);
|
|
15
|
+
type PaymentLinkOrigin = 'pabilo' | 'api' | (string & Record<never, never>);
|
|
16
|
+
type MovementType = 'GENERIC' | 'MOVIL_PAY' | 'TRANSFER' | 'C2P' | (string & Record<never, never>);
|
|
17
|
+
type UserBankPaymentStatus = 'pending' | 'paid' | 'failed' | (string & Record<never, never>);
|
|
18
|
+
type UserType = 'system' | 'user' | 'admin' | 'test' | 'commerce' | (string & Record<never, never>);
|
|
19
|
+
type PlanType = 'credit' | 'unlimited' | 'counter' | (string & Record<never, never>);
|
|
20
|
+
type PlanPeriod = 'month' | 'six_months' | 'year' | (string & Record<never, never>);
|
|
21
|
+
type PabiloErrorCode = 'BANK_NOT_AVAILABLE' | 'PAYMENT_NOT_FOUND' | 'BAD_REQUEST' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'INTERNAL_SERVER_ERROR' | 'INTERNAL_ERROR' | 'NETWORK_ERROR' | 'REQUEST_FAILED' | 'MISSING_CONFIG' | 'REQUEST_LIMIT_REACHED' | 'BANK_ACCOUNT_LIMIT_REACHED' | 'USER_BANK_ALREADY_EXISTS' | 'USER_BANCK_NOT_FOUND' | 'USER_BANCK_BAD_PASSWORD' | 'USER_BANCK_PASSWORD_EXPIRED' | 'INVALID_MOVEMENT_TYPE' | 'INVALID_PHONE' | 'MOVEMENT_TYPE_REQUIRED' | 'INVALID_BANK_PROVIDER' | 'PLAN_IS_NOT_ACTIVE' | 'USER_IS_NOT_ACTIVE' | 'NOT_ENOUGH_CREDITS' | 'THIS_EMAIL_ALREADY_EXISTS' | 'THIS_USERNAME_ALREADY_EXISTS' | 'PLAN_IS_ALREADY_ACTIVE' | 'RENOVATION_IS_ALREADY_PAID' | 'GET_DOLAR_PRICE_FAILED' | 'PAYMENT_AMOUNT_NOT_VALID' | 'PAYMENT_ALREADY_EXISTS' | 'IS_NOT_POSITIVE_PAYMENT' | 'IS_NOT_POSITIVE_AMOUNT' | 'PAGE_NOT_FOUND' | 'SESSION_ALREADY_ACTIVE' | 'PROXY_ERROR' | 'NOT_IMPLEMENTED' | 'METHOD_NOT_SUPPORT' | 'COORDINATE_KEY_EXTRACTION_FAILED' | 'COORDINATE_KEY_NOT_VALID' | 'BANK_TEMPORARILY_INACTIVE' | 'BANK_TOO_MANY_REQUESTS' | (string & Record<never, never>);
|
|
16
22
|
interface BankAccountEntry {
|
|
17
23
|
account_number: string;
|
|
18
24
|
account_type: AccountType;
|
|
@@ -28,27 +34,52 @@ interface UserBank {
|
|
|
28
34
|
interface User {
|
|
29
35
|
id: string;
|
|
30
36
|
email?: string;
|
|
31
|
-
|
|
37
|
+
username?: string;
|
|
38
|
+
fullName?: string;
|
|
39
|
+
companyName?: string;
|
|
40
|
+
credits?: number;
|
|
41
|
+
planIsActive?: boolean;
|
|
42
|
+
isDemo?: boolean;
|
|
43
|
+
userType?: UserType;
|
|
44
|
+
}
|
|
45
|
+
interface PlanBenefit {
|
|
46
|
+
description: string;
|
|
47
|
+
contain: boolean;
|
|
32
48
|
}
|
|
33
49
|
interface Plan {
|
|
50
|
+
id?: string;
|
|
34
51
|
name: string;
|
|
35
|
-
|
|
52
|
+
description?: string;
|
|
53
|
+
planType?: PlanType;
|
|
54
|
+
period?: PlanPeriod;
|
|
55
|
+
price?: number;
|
|
56
|
+
requestLimit?: number;
|
|
57
|
+
bankAccountLimit?: number;
|
|
58
|
+
initialCredits?: number;
|
|
59
|
+
maxAcumulatedCredits?: number;
|
|
60
|
+
benefits?: PlanBenefit[];
|
|
61
|
+
salient?: boolean;
|
|
62
|
+
hidden?: boolean;
|
|
36
63
|
}
|
|
37
64
|
interface PaymentLink {
|
|
38
65
|
id: string;
|
|
39
66
|
url: string;
|
|
40
67
|
amount?: number;
|
|
41
68
|
status?: PaymentLinkStatus;
|
|
69
|
+
statusDetail?: string;
|
|
42
70
|
type?: PaymentLinkType;
|
|
43
71
|
userId?: string;
|
|
72
|
+
userBankId?: string;
|
|
73
|
+
withSubscriptionId?: string;
|
|
44
74
|
name?: string;
|
|
45
75
|
description?: string;
|
|
46
76
|
isUsd?: boolean;
|
|
47
77
|
redirectUrl?: string;
|
|
48
78
|
webhookUrl?: string;
|
|
79
|
+
webhookMethod?: string;
|
|
49
80
|
notificationByWhatsapp?: boolean;
|
|
50
81
|
expirationTime?: number;
|
|
51
|
-
paymentLinkOrigin?:
|
|
82
|
+
paymentLinkOrigin?: PaymentLinkOrigin;
|
|
52
83
|
createdAt?: string;
|
|
53
84
|
updatedAt?: string;
|
|
54
85
|
}
|
|
@@ -70,11 +101,11 @@ interface UserBankPayment {
|
|
|
70
101
|
user_id: string;
|
|
71
102
|
amount: number;
|
|
72
103
|
user_bank_id: string;
|
|
73
|
-
status:
|
|
104
|
+
status: UserBankPaymentStatus;
|
|
74
105
|
credit_cost: number;
|
|
75
106
|
payment_params: PaymentParams;
|
|
76
107
|
confirmed_status: boolean;
|
|
77
|
-
details
|
|
108
|
+
details?: unknown[];
|
|
78
109
|
}
|
|
79
110
|
interface PaymentData {
|
|
80
111
|
is_new: boolean;
|
|
@@ -84,6 +115,33 @@ interface PaymentData {
|
|
|
84
115
|
user_credits_total_in_usd?: number;
|
|
85
116
|
[key: string]: unknown;
|
|
86
117
|
}
|
|
118
|
+
interface PaymentLinkWebhookPayload {
|
|
119
|
+
id: string;
|
|
120
|
+
created_at: string;
|
|
121
|
+
updated_at: string;
|
|
122
|
+
payment_link_id: string;
|
|
123
|
+
status: PaymentLinkStatus;
|
|
124
|
+
payment_link?: PaymentLink;
|
|
125
|
+
user_bank_payment?: UserBankPayment;
|
|
126
|
+
credit_balance: number;
|
|
127
|
+
metadata: Array<{
|
|
128
|
+
key: string;
|
|
129
|
+
value: string;
|
|
130
|
+
}>;
|
|
131
|
+
}
|
|
132
|
+
interface ListPaymentLinksRequest {
|
|
133
|
+
page?: number;
|
|
134
|
+
limit?: number;
|
|
135
|
+
type?: PaymentLinkType;
|
|
136
|
+
status?: PaymentLinkStatus;
|
|
137
|
+
search?: string;
|
|
138
|
+
}
|
|
139
|
+
interface PaymentLinksPage {
|
|
140
|
+
items: PaymentLink[];
|
|
141
|
+
total: number;
|
|
142
|
+
page: number;
|
|
143
|
+
limit: number;
|
|
144
|
+
}
|
|
87
145
|
interface CreatePaymentLinkRequest {
|
|
88
146
|
amount: number;
|
|
89
147
|
description: string;
|
|
@@ -105,7 +163,7 @@ interface UpdatePaymentLinkRequest {
|
|
|
105
163
|
interface VerifyPaymentRequest {
|
|
106
164
|
amount: number;
|
|
107
165
|
bankReference: string;
|
|
108
|
-
movementType?:
|
|
166
|
+
movementType?: MovementType;
|
|
109
167
|
}
|
|
110
168
|
type VerifyPaymentResult = {
|
|
111
169
|
found: false;
|
|
@@ -147,6 +205,7 @@ interface IBankAccountsPort {
|
|
|
147
205
|
}
|
|
148
206
|
|
|
149
207
|
interface IPaymentLinksPort {
|
|
208
|
+
list(req?: ListPaymentLinksRequest): Promise<PaymentLinksPage>;
|
|
150
209
|
create(req: CreatePaymentLinkRequest): Promise<PaymentLink>;
|
|
151
210
|
update(id: string, req: UpdatePaymentLinkRequest): Promise<PaymentLink>;
|
|
152
211
|
getInfo(id: string): Promise<PaymentLink>;
|
|
@@ -207,4 +266,4 @@ declare class PabiloHttpClient implements IHttpClient {
|
|
|
207
266
|
request<T>(options: RequestOptions): Promise<T>;
|
|
208
267
|
}
|
|
209
268
|
|
|
210
|
-
export { type AccountType, type BankAccountEntry, type BankProvider, type CreateBankTestRequest, type CreatePaymentLinkRequest, type CreateUserBankRequest, type CreateVeBanEmpV2Request, type CreateVeBanRequest, FetchHttpClient, type IBankAccountsPort, type IHttpClient, type IMePort, type IPaymentLinksPort, type IPaymentsPort, PabiloClient, type PabiloClientOptions, PabiloError, type PabiloErrorCode, PabiloHttpClient, type PabiloHttpClientOptions, type PaymentData, type PaymentLink, type PaymentLinkStatus, type PaymentLinkType, type PaymentParams, type Plan, type RequestOptions, type UpdatePaymentLinkRequest, type User, type UserBank, type UserBankMetadataEntry, type UserBankPayment, type VerifyPaymentRequest, type VerifyPaymentResult };
|
|
269
|
+
export { type AccountType, type BankAccountEntry, type BankProvider, type CreateBankTestRequest, type CreatePaymentLinkRequest, type CreateUserBankRequest, type CreateVeBanEmpV2Request, type CreateVeBanRequest, FetchHttpClient, type IBankAccountsPort, type IHttpClient, type IMePort, type IPaymentLinksPort, type IPaymentsPort, type ListPaymentLinksRequest, type MovementType, PabiloClient, type PabiloClientOptions, PabiloError, type PabiloErrorCode, PabiloHttpClient, type PabiloHttpClientOptions, type PaymentData, type PaymentLink, type PaymentLinkOrigin, type PaymentLinkStatus, type PaymentLinkType, type PaymentLinkWebhookPayload, type PaymentLinksPage, type PaymentParams, type Plan, type PlanBenefit, type PlanPeriod, type PlanType, type RequestOptions, type UpdatePaymentLinkRequest, type User, type UserBank, type UserBankMetadataEntry, type UserBankPayment, type UserBankPaymentStatus, type UserType, type VerifyPaymentRequest, type VerifyPaymentResult };
|
package/dist/index.js
CHANGED
|
@@ -167,6 +167,27 @@ var PaymentLinksResource = class {
|
|
|
167
167
|
constructor(http) {
|
|
168
168
|
this.http = http;
|
|
169
169
|
}
|
|
170
|
+
async list(req) {
|
|
171
|
+
const body = {
|
|
172
|
+
page: req?.page ?? 1,
|
|
173
|
+
limit: req?.limit ?? 10
|
|
174
|
+
};
|
|
175
|
+
if (req?.type !== void 0) body["type"] = req.type;
|
|
176
|
+
if (req?.status !== void 0) body["status"] = req.status;
|
|
177
|
+
if (req?.search !== void 0) body["search"] = req.search;
|
|
178
|
+
const res = await this.http.request({
|
|
179
|
+
method: "POST",
|
|
180
|
+
path: "/me/payment-links",
|
|
181
|
+
body
|
|
182
|
+
});
|
|
183
|
+
const raw = Array.isArray(res["payment_links"]) ? res["payment_links"] : [];
|
|
184
|
+
return {
|
|
185
|
+
items: raw.map((item) => normalizePaymentLink(item)),
|
|
186
|
+
total: typeof res["total"] === "number" ? res["total"] : 0,
|
|
187
|
+
page: typeof res["page"] === "number" ? res["page"] : 1,
|
|
188
|
+
limit: typeof res["limit"] === "number" ? res["limit"] : raw.length
|
|
189
|
+
};
|
|
190
|
+
}
|
|
170
191
|
async create(req) {
|
|
171
192
|
const body = {
|
|
172
193
|
amount: req.amount,
|
|
@@ -221,13 +242,17 @@ function normalizePaymentLink(raw) {
|
|
|
221
242
|
url: String(src["url"] ?? ""),
|
|
222
243
|
...typeof src["amount"] === "number" ? { amount: src["amount"] } : {},
|
|
223
244
|
...typeof src["status"] === "string" ? { status: src["status"] } : {},
|
|
245
|
+
...typeof src["status_detail"] === "string" ? { statusDetail: src["status_detail"] } : {},
|
|
224
246
|
...typeof src["type"] === "string" ? { type: src["type"] } : {},
|
|
225
247
|
...userId !== void 0 ? { userId } : {},
|
|
248
|
+
...typeof src["user_bank_id"] === "string" ? { userBankId: src["user_bank_id"] } : {},
|
|
249
|
+
...typeof src["with_subscription_id"] === "string" ? { withSubscriptionId: src["with_subscription_id"] } : {},
|
|
226
250
|
...typeof src["name"] === "string" ? { name: src["name"] } : {},
|
|
227
251
|
...typeof src["description"] === "string" ? { description: src["description"] } : {},
|
|
228
252
|
...typeof src["is_usd"] === "boolean" ? { isUsd: src["is_usd"] } : {},
|
|
229
253
|
...typeof src["redirect_url"] === "string" ? { redirectUrl: src["redirect_url"] } : {},
|
|
230
254
|
...typeof src["webhook_url"] === "string" ? { webhookUrl: src["webhook_url"] } : {},
|
|
255
|
+
...typeof src["webhook_method"] === "string" ? { webhookMethod: src["webhook_method"] } : {},
|
|
231
256
|
...typeof src["notification_by_whastapp"] === "boolean" ? { notificationByWhatsapp: src["notification_by_whastapp"] } : {},
|
|
232
257
|
...typeof src["expiration_time"] === "number" ? { expirationTime: src["expiration_time"] } : {},
|
|
233
258
|
...typeof src["payment_link_origin"] === "string" ? { paymentLinkOrigin: src["payment_link_origin"] } : {},
|
|
@@ -283,17 +308,35 @@ var MeResource = class {
|
|
|
283
308
|
return {
|
|
284
309
|
id: String(u["id"] ?? ""),
|
|
285
310
|
...typeof u["email"] === "string" ? { email: u["email"] } : {},
|
|
286
|
-
...typeof u["
|
|
311
|
+
...typeof u["username"] === "string" ? { username: u["username"] } : {},
|
|
312
|
+
...typeof u["full_name"] === "string" ? { fullName: u["full_name"] } : {},
|
|
313
|
+
...typeof u["company_name"] === "string" ? { companyName: u["company_name"] } : {},
|
|
314
|
+
...typeof u["credits"] === "number" ? { credits: u["credits"] } : {},
|
|
315
|
+
...typeof u["plan_is_active"] === "boolean" ? { planIsActive: u["plan_is_active"] } : {},
|
|
316
|
+
...typeof u["is_demo"] === "boolean" ? { isDemo: u["is_demo"] } : {},
|
|
317
|
+
...typeof u["user_type"] === "string" ? { userType: u["user_type"] } : {}
|
|
287
318
|
};
|
|
288
319
|
}
|
|
289
320
|
async getPlan() {
|
|
290
|
-
const
|
|
321
|
+
const raw = await this.http.request({
|
|
291
322
|
method: "GET",
|
|
292
323
|
path: "/me/plan"
|
|
293
324
|
});
|
|
325
|
+
const res = raw["plan"] ?? raw;
|
|
294
326
|
return {
|
|
295
327
|
name: String(res["name"] ?? ""),
|
|
296
|
-
...typeof res["
|
|
328
|
+
...typeof res["id"] === "string" ? { id: res["id"] } : {},
|
|
329
|
+
...typeof res["description"] === "string" ? { description: res["description"] } : {},
|
|
330
|
+
...typeof res["planType"] === "string" ? { planType: res["planType"] } : {},
|
|
331
|
+
...typeof res["period"] === "string" ? { period: res["period"] } : {},
|
|
332
|
+
...typeof res["price"] === "number" ? { price: res["price"] } : {},
|
|
333
|
+
...typeof res["requestLimit"] === "number" ? { requestLimit: res["requestLimit"] } : {},
|
|
334
|
+
...typeof res["bankAccountLimit"] === "number" ? { bankAccountLimit: res["bankAccountLimit"] } : {},
|
|
335
|
+
...typeof res["initialCredits"] === "number" ? { initialCredits: res["initialCredits"] } : {},
|
|
336
|
+
...typeof res["maxAcumulatedCredits"] === "number" ? { maxAcumulatedCredits: res["maxAcumulatedCredits"] } : {},
|
|
337
|
+
...Array.isArray(res["benefits"]) ? { benefits: res["benefits"] } : {},
|
|
338
|
+
...typeof res["salient"] === "boolean" ? { salient: res["salient"] } : {},
|
|
339
|
+
...typeof res["hidden"] === "boolean" ? { hidden: res["hidden"] } : {}
|
|
297
340
|
};
|
|
298
341
|
}
|
|
299
342
|
};
|