@passly-nl/data 1.3.2 → 1.3.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@passly-nl/data",
3
3
  "description": "API implementation for Passly.",
4
- "version": "1.3.2",
4
+ "version": "1.3.3",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/basmilius",
@@ -1,6 +1,6 @@
1
1
  import { adapter, ForeignData } from '@basmilius/http-client';
2
2
  import { DateTimeAdapter, PaymentAdapter } from '#data/adapter';
3
- import { RefundDto, RefundInitiatorDto, RefundTicketRefDto } from '#data/dto';
3
+ import { RefundabilityDto, RefundDto, RefundInitiatorDto, RefundTicketRefDto } from '#data/dto';
4
4
  import { optional } from '#data/util';
5
5
 
6
6
  @adapter
@@ -18,6 +18,13 @@ export class RefundAdapter {
18
18
  );
19
19
  }
20
20
 
21
+ static parseRefundability(data: ForeignData): RefundabilityDto {
22
+ return new RefundabilityDto(
23
+ data.supported,
24
+ data.reason
25
+ );
26
+ }
27
+
21
28
  static parseRefundInitiator(data: ForeignData): RefundInitiatorDto {
22
29
  return new RefundInitiatorDto(
23
30
  data.id,
@@ -0,0 +1,29 @@
1
+ import { dto } from '@basmilius/http-client';
2
+ import type { RefundabilityReason } from '#data/types';
3
+
4
+ @dto
5
+ export class RefundabilityDto {
6
+ get supported(): boolean {
7
+ return this.#supported;
8
+ }
9
+
10
+ set supported(value: boolean) {
11
+ this.#supported = value;
12
+ }
13
+
14
+ get reason(): RefundabilityReason | null {
15
+ return this.#reason;
16
+ }
17
+
18
+ set reason(value: RefundabilityReason | null) {
19
+ this.#reason = value;
20
+ }
21
+
22
+ #supported: boolean;
23
+ #reason: RefundabilityReason | null;
24
+
25
+ constructor(supported: boolean, reason: RefundabilityReason | null) {
26
+ this.#supported = supported;
27
+ this.#reason = reason;
28
+ }
29
+ }
@@ -1,3 +1,4 @@
1
+ export * from './RefundabilityDto';
1
2
  export * from './RefundDto';
2
3
  export * from './RefundInitiatorDto';
3
4
  export * from './RefundTicketRefDto';
@@ -1,6 +1,6 @@
1
1
  import { BaseResponse, BaseService, BlobResponse, QueryString } from '@basmilius/http-client';
2
2
  import { CashFlowAdapter, OrderAdapter, RefundAdapter, TicketAdapter } from '#data/adapter';
3
- import type { CashFlowDto, OrderDto, RefundDto, TicketDto } from '#data/dto';
3
+ import type { CashFlowDto, OrderDto, RefundabilityDto, RefundDto, TicketDto } from '#data/dto';
4
4
  import type { RefundReason } from '#data/types';
5
5
 
6
6
  export class MerchantOrderService extends BaseService {
@@ -24,6 +24,14 @@ export class MerchantOrderService extends BaseService {
24
24
  .runAdapter(CashFlowAdapter.parseCashFlow);
25
25
  }
26
26
 
27
+ async getRefundability(merchantId: string, orderId: string): Promise<BaseResponse<RefundabilityDto>> {
28
+ return await this
29
+ .request(`/merchants/${merchantId}/orders/${orderId}/refundability`)
30
+ .method('get')
31
+ .bearerToken()
32
+ .runAdapter(RefundAdapter.parseRefundability);
33
+ }
34
+
27
35
  async getPasses(merchantId: string, orderId: string): Promise<BlobResponse> {
28
36
  return await this
29
37
  .request(`/merchants/${merchantId}/orders/${orderId}/passes`)
@@ -10,3 +10,9 @@ export type RefundStatus =
10
10
  | 'processing'
11
11
  | 'completed'
12
12
  | 'failed';
13
+
14
+ export type RefundabilityReason =
15
+ | 'no_provider'
16
+ | 'order_not_refundable'
17
+ | 'provider_not_capable'
18
+ | 'transaction_not_paid';