@billionaire-sh/node-sdk 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.mjs CHANGED
@@ -169,6 +169,43 @@ class BaseResource {
169
169
  }
170
170
  }
171
171
 
172
+ class PlatformCustomersResource extends BaseResource {
173
+ constructor(tokenManager, baseUrl) {
174
+ super(tokenManager, baseUrl, "/customers");
175
+ }
176
+ rootPath() {
177
+ return "/platform";
178
+ }
179
+ /**
180
+ * Hand over a paying customer's details as they stand after a change;
181
+ * the entity's party for the customer takes them, or is filed with them.
182
+ * Idempotent: the same details again change nothing.
183
+ * @param request - The platform's name and its customer's details
184
+ * @returns The party the customer is in the entity's books
185
+ */
186
+ async process(request) {
187
+ return this.request("POST", "", request);
188
+ }
189
+ /**
190
+ * Read back the party a customer is in the entity's books, as the books
191
+ * keep it today (BLNR-1979). Throws `HTTP 404` where the platform has
192
+ * handed over no customer of the reference.
193
+ * @param customer - The platform, as it names itself, and its own
194
+ * reference of its customer
195
+ * @returns The party: its name, email, VAT ID, tax number and billing
196
+ * address
197
+ */
198
+ async get({
199
+ platform,
200
+ reference
201
+ }) {
202
+ return this.request(
203
+ "GET",
204
+ `/${encodeURIComponent(reference)}?${new URLSearchParams({ platform })}`
205
+ );
206
+ }
207
+ }
208
+
172
209
  class PlatformInvoicesResource extends BaseResource {
173
210
  constructor(tokenManager, baseUrl) {
174
211
  super(tokenManager, baseUrl, "/invoices");
@@ -232,6 +269,51 @@ class PlatformInvoicesResource extends BaseResource {
232
269
  request
233
270
  );
234
271
  }
272
+ /**
273
+ * The invoices the entity issued to the tenants of one of the platform's
274
+ * accounts, the newest first — what the platform shows the account as its
275
+ * invoices (BLNR-626).
276
+ * @param request - The platform (`filters.platform`) and its own ids of
277
+ * the account's tenants (`filters.tenantIds`)
278
+ * @returns Each invoice's number, dates, amount, state, the tenant it is
279
+ * addressed to, and whether its PDF is kept
280
+ */
281
+ async listForCustomers(request) {
282
+ return this.request(
283
+ "POST",
284
+ "/customers",
285
+ request
286
+ );
287
+ }
288
+ /**
289
+ * What the entity invoiced the platform's customers since a day, summed
290
+ * per month of issue, currency and state (KLVR-2470) — what the
291
+ * platform's Revenue tab shows of the entity's books.
292
+ * @param request - The platform (`filters.platform`) and the first day of
293
+ * issue read (`filters.since`)
294
+ * @returns Per month, currency and state what was invoiced, tax included
295
+ */
296
+ async listMonths(request) {
297
+ return this.request(
298
+ "POST",
299
+ "/months",
300
+ request
301
+ );
302
+ }
303
+ /**
304
+ * A link to the PDF of an invoice the entity issued to one of these
305
+ * tenants, valid for a few minutes — asked for the moment the account
306
+ * opens it (BLNR-626). An invoice of any other tenant answers 404.
307
+ * @param stripeInvoiceId - The payment provider's id of the platform's invoice
308
+ * @param request - The platform and its own ids of the account's tenants
309
+ */
310
+ async documentUrl(stripeInvoiceId, request) {
311
+ return this.request(
312
+ "POST",
313
+ `/${encodeURIComponent(stripeInvoiceId)}/document`,
314
+ request
315
+ );
316
+ }
235
317
  /**
236
318
  * Get the entity's invoice for a platform invoice.
237
319
  * @param stripeInvoiceId - The payment provider's id of the platform's invoice
@@ -273,10 +355,16 @@ class PlatformInvoicesResource extends BaseResource {
273
355
  * Hand over a credit note the payment provider issued for a platform
274
356
  * invoice — money back to the card, a credit on the customer's balance.
275
357
  * One for all of it cancels the entity's invoice, and what the customer
276
- * had paid becomes their credit; one for part of it is answered
277
- * `partial_credit` and changes nothing.
358
+ * had paid becomes their credit; one for part of it corrects the invoice
359
+ * by the lines it takes back, by a correction invoice of its own
360
+ * (`corrected`). One whose lines do not say which part it takes back is
361
+ * answered `partial_credit` and changes nothing. What it sent back to the
362
+ * card (`refundedAmount`, with the `paymentProviderAccount` it left) is
363
+ * recorded as an outgoing payment on the money account of that balance
364
+ * and pays back the customer's credit; `refund` answers what became of
365
+ * it.
278
366
  * @param stripeInvoiceId - The payment provider's id of the credited invoice
279
- * @param request - The credit note, when it was issued and what it takes back
367
+ * @param request - The credit note, when it was issued, what it takes back and what it refunded
280
368
  */
281
369
  async processCredit(stripeInvoiceId, request) {
282
370
  return this.request(
@@ -292,6 +380,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
292
380
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
293
381
  class BLNRClient {
294
382
  constructor(config) {
383
+ __publicField(this, "platformCustomers");
295
384
  __publicField(this, "platformInvoices");
296
385
  __publicField(this, "baseUrl");
297
386
  __publicField(this, "tokenManager");
@@ -303,6 +392,10 @@ class BLNRClient {
303
392
  tokenUrl,
304
393
  config.entityId
305
394
  );
395
+ this.platformCustomers = new PlatformCustomersResource(
396
+ this.tokenManager,
397
+ this.baseUrl
398
+ );
306
399
  this.platformInvoices = new PlatformInvoicesResource(
307
400
  this.tokenManager,
308
401
  this.baseUrl