mollie-api-typescript 0.2.4 → 0.2.5

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.
@@ -13,6 +13,11 @@ import {
13
13
  Amount$outboundSchema,
14
14
  } from "./amount.js";
15
15
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
16
+ import {
17
+ PaymentMethod,
18
+ PaymentMethod$inboundSchema,
19
+ PaymentMethod$outboundSchema,
20
+ } from "./paymentmethod.js";
16
21
  import {
17
22
  SettlementStatus,
18
23
  SettlementStatus$inboundSchema,
@@ -31,6 +36,94 @@ import {
31
36
  UrlNullable$outboundSchema,
32
37
  } from "./urlnullable.js";
33
38
 
39
+ /**
40
+ * The service rates, further divided into `fixed` and `percentage` costs.
41
+ */
42
+ export type Rate = {
43
+ /**
44
+ * In v2 endpoints, monetary amounts are represented as objects with a `currency` and `value` field.
45
+ */
46
+ fixed?: Amount | undefined;
47
+ /**
48
+ * In v2 endpoints, monetary amounts are represented as objects with a `currency` and `value` field.
49
+ */
50
+ percentage?: Amount | undefined;
51
+ };
52
+
53
+ export type Cost = {
54
+ /**
55
+ * A description of the cost subtotal
56
+ */
57
+ description?: string | undefined;
58
+ /**
59
+ * The payment method, if applicable
60
+ */
61
+ method?: PaymentMethod | null | undefined;
62
+ /**
63
+ * The number of fees
64
+ */
65
+ count?: number | undefined;
66
+ /**
67
+ * The service rates, further divided into `fixed` and `percentage` costs.
68
+ */
69
+ rate?: Rate | undefined;
70
+ /**
71
+ * In v2 endpoints, monetary amounts are represented as objects with a `currency` and `value` field.
72
+ */
73
+ amountNet?: Amount | undefined;
74
+ /**
75
+ * In v2 endpoints, monetary amounts are represented as objects with a `currency` and `value` field.
76
+ */
77
+ amountVat?: Amount | undefined;
78
+ /**
79
+ * In v2 endpoints, monetary amounts are represented as objects with a `currency` and `value` field.
80
+ */
81
+ amountGross?: Amount | undefined;
82
+ };
83
+
84
+ export type Revenue = {
85
+ /**
86
+ * A description of the revenue subtotal
87
+ */
88
+ description?: string | undefined;
89
+ /**
90
+ * The payment method, if applicable
91
+ */
92
+ method?: PaymentMethod | null | undefined;
93
+ /**
94
+ * The number of payments
95
+ */
96
+ count?: number | undefined;
97
+ /**
98
+ * In v2 endpoints, monetary amounts are represented as objects with a `currency` and `value` field.
99
+ */
100
+ amountNet?: Amount | undefined;
101
+ /**
102
+ * In v2 endpoints, monetary amounts are represented as objects with a `currency` and `value` field.
103
+ */
104
+ amountVat?: Amount | undefined;
105
+ /**
106
+ * In v2 endpoints, monetary amounts are represented as objects with a `currency` and `value` field.
107
+ */
108
+ amountGross?: Amount | undefined;
109
+ };
110
+
111
+ export type Periods = {
112
+ /**
113
+ * An array of cost objects, describing the fees withheld for each payment method during this period.
114
+ */
115
+ costs?: Array<Cost> | undefined;
116
+ /**
117
+ * An array of revenue objects containing the total revenue for each payment method during this period.
118
+ */
119
+ revenue?: Array<Revenue> | undefined;
120
+ invoiceId?: string | undefined;
121
+ /**
122
+ * The invoice reference, if the invoice has been created already.
123
+ */
124
+ invoiceReference?: string | null | undefined;
125
+ };
126
+
34
127
  /**
35
128
  * An object with several relevant URLs. Every URL object will contain an `href` and a `type` field.
36
129
  */
@@ -115,13 +208,240 @@ export type EntitySettlement = {
115
208
  *
116
209
  * The example response should give a good idea of what this looks like in practise.
117
210
  */
118
- periods?: { [k: string]: any } | undefined;
211
+ periods?: { [k: string]: { [k: string]: Periods } } | undefined;
119
212
  /**
120
213
  * An object with several relevant URLs. Every URL object will contain an `href` and a `type` field.
121
214
  */
122
215
  links?: EntitySettlementLinks | undefined;
123
216
  };
124
217
 
218
+ /** @internal */
219
+ export const Rate$inboundSchema: z.ZodType<Rate, z.ZodTypeDef, unknown> = z
220
+ .object({
221
+ fixed: Amount$inboundSchema.optional(),
222
+ percentage: Amount$inboundSchema.optional(),
223
+ });
224
+
225
+ /** @internal */
226
+ export type Rate$Outbound = {
227
+ fixed?: Amount$Outbound | undefined;
228
+ percentage?: Amount$Outbound | undefined;
229
+ };
230
+
231
+ /** @internal */
232
+ export const Rate$outboundSchema: z.ZodType<Rate$Outbound, z.ZodTypeDef, Rate> =
233
+ z.object({
234
+ fixed: Amount$outboundSchema.optional(),
235
+ percentage: Amount$outboundSchema.optional(),
236
+ });
237
+
238
+ /**
239
+ * @internal
240
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
241
+ */
242
+ export namespace Rate$ {
243
+ /** @deprecated use `Rate$inboundSchema` instead. */
244
+ export const inboundSchema = Rate$inboundSchema;
245
+ /** @deprecated use `Rate$outboundSchema` instead. */
246
+ export const outboundSchema = Rate$outboundSchema;
247
+ /** @deprecated use `Rate$Outbound` instead. */
248
+ export type Outbound = Rate$Outbound;
249
+ }
250
+
251
+ export function rateToJSON(rate: Rate): string {
252
+ return JSON.stringify(Rate$outboundSchema.parse(rate));
253
+ }
254
+
255
+ export function rateFromJSON(
256
+ jsonString: string,
257
+ ): SafeParseResult<Rate, SDKValidationError> {
258
+ return safeParse(
259
+ jsonString,
260
+ (x) => Rate$inboundSchema.parse(JSON.parse(x)),
261
+ `Failed to parse 'Rate' from JSON`,
262
+ );
263
+ }
264
+
265
+ /** @internal */
266
+ export const Cost$inboundSchema: z.ZodType<Cost, z.ZodTypeDef, unknown> = z
267
+ .object({
268
+ description: z.string().optional(),
269
+ method: z.nullable(PaymentMethod$inboundSchema).optional(),
270
+ count: z.number().int().optional(),
271
+ rate: z.lazy(() => Rate$inboundSchema).optional(),
272
+ amountNet: Amount$inboundSchema.optional(),
273
+ amountVat: Amount$inboundSchema.optional(),
274
+ amountGross: Amount$inboundSchema.optional(),
275
+ });
276
+
277
+ /** @internal */
278
+ export type Cost$Outbound = {
279
+ description?: string | undefined;
280
+ method?: string | null | undefined;
281
+ count?: number | undefined;
282
+ rate?: Rate$Outbound | undefined;
283
+ amountNet?: Amount$Outbound | undefined;
284
+ amountVat?: Amount$Outbound | undefined;
285
+ amountGross?: Amount$Outbound | undefined;
286
+ };
287
+
288
+ /** @internal */
289
+ export const Cost$outboundSchema: z.ZodType<Cost$Outbound, z.ZodTypeDef, Cost> =
290
+ z.object({
291
+ description: z.string().optional(),
292
+ method: z.nullable(PaymentMethod$outboundSchema).optional(),
293
+ count: z.number().int().optional(),
294
+ rate: z.lazy(() => Rate$outboundSchema).optional(),
295
+ amountNet: Amount$outboundSchema.optional(),
296
+ amountVat: Amount$outboundSchema.optional(),
297
+ amountGross: Amount$outboundSchema.optional(),
298
+ });
299
+
300
+ /**
301
+ * @internal
302
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
303
+ */
304
+ export namespace Cost$ {
305
+ /** @deprecated use `Cost$inboundSchema` instead. */
306
+ export const inboundSchema = Cost$inboundSchema;
307
+ /** @deprecated use `Cost$outboundSchema` instead. */
308
+ export const outboundSchema = Cost$outboundSchema;
309
+ /** @deprecated use `Cost$Outbound` instead. */
310
+ export type Outbound = Cost$Outbound;
311
+ }
312
+
313
+ export function costToJSON(cost: Cost): string {
314
+ return JSON.stringify(Cost$outboundSchema.parse(cost));
315
+ }
316
+
317
+ export function costFromJSON(
318
+ jsonString: string,
319
+ ): SafeParseResult<Cost, SDKValidationError> {
320
+ return safeParse(
321
+ jsonString,
322
+ (x) => Cost$inboundSchema.parse(JSON.parse(x)),
323
+ `Failed to parse 'Cost' from JSON`,
324
+ );
325
+ }
326
+
327
+ /** @internal */
328
+ export const Revenue$inboundSchema: z.ZodType<Revenue, z.ZodTypeDef, unknown> =
329
+ z.object({
330
+ description: z.string().optional(),
331
+ method: z.nullable(PaymentMethod$inboundSchema).optional(),
332
+ count: z.number().int().optional(),
333
+ amountNet: Amount$inboundSchema.optional(),
334
+ amountVat: Amount$inboundSchema.optional(),
335
+ amountGross: Amount$inboundSchema.optional(),
336
+ });
337
+
338
+ /** @internal */
339
+ export type Revenue$Outbound = {
340
+ description?: string | undefined;
341
+ method?: string | null | undefined;
342
+ count?: number | undefined;
343
+ amountNet?: Amount$Outbound | undefined;
344
+ amountVat?: Amount$Outbound | undefined;
345
+ amountGross?: Amount$Outbound | undefined;
346
+ };
347
+
348
+ /** @internal */
349
+ export const Revenue$outboundSchema: z.ZodType<
350
+ Revenue$Outbound,
351
+ z.ZodTypeDef,
352
+ Revenue
353
+ > = z.object({
354
+ description: z.string().optional(),
355
+ method: z.nullable(PaymentMethod$outboundSchema).optional(),
356
+ count: z.number().int().optional(),
357
+ amountNet: Amount$outboundSchema.optional(),
358
+ amountVat: Amount$outboundSchema.optional(),
359
+ amountGross: Amount$outboundSchema.optional(),
360
+ });
361
+
362
+ /**
363
+ * @internal
364
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
365
+ */
366
+ export namespace Revenue$ {
367
+ /** @deprecated use `Revenue$inboundSchema` instead. */
368
+ export const inboundSchema = Revenue$inboundSchema;
369
+ /** @deprecated use `Revenue$outboundSchema` instead. */
370
+ export const outboundSchema = Revenue$outboundSchema;
371
+ /** @deprecated use `Revenue$Outbound` instead. */
372
+ export type Outbound = Revenue$Outbound;
373
+ }
374
+
375
+ export function revenueToJSON(revenue: Revenue): string {
376
+ return JSON.stringify(Revenue$outboundSchema.parse(revenue));
377
+ }
378
+
379
+ export function revenueFromJSON(
380
+ jsonString: string,
381
+ ): SafeParseResult<Revenue, SDKValidationError> {
382
+ return safeParse(
383
+ jsonString,
384
+ (x) => Revenue$inboundSchema.parse(JSON.parse(x)),
385
+ `Failed to parse 'Revenue' from JSON`,
386
+ );
387
+ }
388
+
389
+ /** @internal */
390
+ export const Periods$inboundSchema: z.ZodType<Periods, z.ZodTypeDef, unknown> =
391
+ z.object({
392
+ costs: z.array(z.lazy(() => Cost$inboundSchema)).optional(),
393
+ revenue: z.array(z.lazy(() => Revenue$inboundSchema)).optional(),
394
+ invoiceId: z.string().optional(),
395
+ invoiceReference: z.nullable(z.string()).optional(),
396
+ });
397
+
398
+ /** @internal */
399
+ export type Periods$Outbound = {
400
+ costs?: Array<Cost$Outbound> | undefined;
401
+ revenue?: Array<Revenue$Outbound> | undefined;
402
+ invoiceId?: string | undefined;
403
+ invoiceReference?: string | null | undefined;
404
+ };
405
+
406
+ /** @internal */
407
+ export const Periods$outboundSchema: z.ZodType<
408
+ Periods$Outbound,
409
+ z.ZodTypeDef,
410
+ Periods
411
+ > = z.object({
412
+ costs: z.array(z.lazy(() => Cost$outboundSchema)).optional(),
413
+ revenue: z.array(z.lazy(() => Revenue$outboundSchema)).optional(),
414
+ invoiceId: z.string().optional(),
415
+ invoiceReference: z.nullable(z.string()).optional(),
416
+ });
417
+
418
+ /**
419
+ * @internal
420
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
421
+ */
422
+ export namespace Periods$ {
423
+ /** @deprecated use `Periods$inboundSchema` instead. */
424
+ export const inboundSchema = Periods$inboundSchema;
425
+ /** @deprecated use `Periods$outboundSchema` instead. */
426
+ export const outboundSchema = Periods$outboundSchema;
427
+ /** @deprecated use `Periods$Outbound` instead. */
428
+ export type Outbound = Periods$Outbound;
429
+ }
430
+
431
+ export function periodsToJSON(periods: Periods): string {
432
+ return JSON.stringify(Periods$outboundSchema.parse(periods));
433
+ }
434
+
435
+ export function periodsFromJSON(
436
+ jsonString: string,
437
+ ): SafeParseResult<Periods, SDKValidationError> {
438
+ return safeParse(
439
+ jsonString,
440
+ (x) => Periods$inboundSchema.parse(JSON.parse(x)),
441
+ `Failed to parse 'Periods' from JSON`,
442
+ );
443
+ }
444
+
125
445
  /** @internal */
126
446
  export const EntitySettlementLinks$inboundSchema: z.ZodType<
127
447
  EntitySettlementLinks,
@@ -209,7 +529,7 @@ export const EntitySettlement$inboundSchema: z.ZodType<
209
529
  amount: Amount$inboundSchema.optional(),
210
530
  balanceId: z.string().optional(),
211
531
  invoiceId: z.string().optional(),
212
- periods: z.record(z.any()).optional(),
532
+ periods: z.record(z.record(z.lazy(() => Periods$inboundSchema))).optional(),
213
533
  _links: z.lazy(() => EntitySettlementLinks$inboundSchema).optional(),
214
534
  }).transform((v) => {
215
535
  return remap$(v, {
@@ -228,7 +548,7 @@ export type EntitySettlement$Outbound = {
228
548
  amount?: Amount$Outbound | undefined;
229
549
  balanceId?: string | undefined;
230
550
  invoiceId?: string | undefined;
231
- periods?: { [k: string]: any } | undefined;
551
+ periods?: { [k: string]: { [k: string]: Periods$Outbound } } | undefined;
232
552
  _links?: EntitySettlementLinks$Outbound | undefined;
233
553
  };
234
554
 
@@ -247,7 +567,7 @@ export const EntitySettlement$outboundSchema: z.ZodType<
247
567
  amount: Amount$outboundSchema.optional(),
248
568
  balanceId: z.string().optional(),
249
569
  invoiceId: z.string().optional(),
250
- periods: z.record(z.any()).optional(),
570
+ periods: z.record(z.record(z.lazy(() => Periods$outboundSchema))).optional(),
251
571
  links: z.lazy(() => EntitySettlementLinks$outboundSchema).optional(),
252
572
  }).transform((v) => {
253
573
  return remap$(v, {