@passly-nl/data 1.3.2 → 1.3.4

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.4",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/basmilius",
@@ -17,6 +17,7 @@ export class OrderAdapter {
17
17
  optional(data.payment_provider, OrderAdapter.parseOrderPaymentProvider),
18
18
  optional(data.platform_cost, PaymentAdapter.parseCost)!,
19
19
  optional(data.refunded_total, PaymentAdapter.parseCost)!,
20
+ data.refund_status,
20
21
  optional(data.sub_total, PaymentAdapter.parseCost)!,
21
22
  optional(data.total, PaymentAdapter.parseCost)!,
22
23
  data.url,
@@ -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,
@@ -1,7 +1,7 @@
1
1
  import { dto } from '@basmilius/http-client';
2
2
  import type { DateTime } from 'luxon';
3
3
  import type { BuyerDto, CostDto, EventDto, MarketingAttributionDto, OrderLineDto, OrderPaymentProviderDto, PublicShopDto, TransactionDto } from '#data/dto';
4
- import type { OrderOrigin, OrderType } from '#data/types';
4
+ import type { OrderOrigin, OrderRefundStatus, OrderType } from '#data/types';
5
5
 
6
6
  @dto
7
7
  export class OrderDto {
@@ -85,6 +85,14 @@ export class OrderDto {
85
85
  this.#refundedTotal = value;
86
86
  }
87
87
 
88
+ get refundStatus(): OrderRefundStatus {
89
+ return this.#refundStatus;
90
+ }
91
+
92
+ set refundStatus(value: OrderRefundStatus) {
93
+ this.#refundStatus = value;
94
+ }
95
+
88
96
  get subTotal(): CostDto {
89
97
  return this.#subTotal;
90
98
  }
@@ -167,6 +175,7 @@ export class OrderDto {
167
175
  #paymentProvider: OrderPaymentProviderDto | null;
168
176
  #platformCost: CostDto;
169
177
  #refundedTotal: CostDto;
178
+ #refundStatus: OrderRefundStatus;
170
179
  #subTotal: CostDto;
171
180
  #total: CostDto;
172
181
  #url: string;
@@ -177,7 +186,7 @@ export class OrderDto {
177
186
  #transaction: TransactionDto | null;
178
187
  #attribution: MarketingAttributionDto | null;
179
188
 
180
- constructor(id: string, code: string, origin: OrderOrigin, type: OrderType, createdOn: DateTime, discountAmount: CostDto | null, discountCodeApplied: string | null, paymentProvider: OrderPaymentProviderDto | null, platformCost: CostDto, refundedTotal: CostDto, subTotal: CostDto, total: CostDto, url: string, buyer: BuyerDto | null, event: EventDto | null, lines: OrderLineDto[] | null, shop: PublicShopDto | null, transaction: TransactionDto | null, attribution: MarketingAttributionDto | null) {
189
+ constructor(id: string, code: string, origin: OrderOrigin, type: OrderType, createdOn: DateTime, discountAmount: CostDto | null, discountCodeApplied: string | null, paymentProvider: OrderPaymentProviderDto | null, platformCost: CostDto, refundedTotal: CostDto, refundStatus: OrderRefundStatus, subTotal: CostDto, total: CostDto, url: string, buyer: BuyerDto | null, event: EventDto | null, lines: OrderLineDto[] | null, shop: PublicShopDto | null, transaction: TransactionDto | null, attribution: MarketingAttributionDto | null) {
181
190
  this.#id = id;
182
191
  this.#code = code;
183
192
  this.#origin = origin;
@@ -188,6 +197,7 @@ export class OrderDto {
188
197
  this.#paymentProvider = paymentProvider;
189
198
  this.#platformCost = platformCost;
190
199
  this.#refundedTotal = refundedTotal;
200
+ this.#refundStatus = refundStatus;
191
201
  this.#subTotal = subTotal;
192
202
  this.#total = total;
193
203
  this.#url = url;
@@ -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`)
@@ -2,6 +2,11 @@ export type OrderOrigin =
2
2
  | 'local'
3
3
  | 'ticketswap';
4
4
 
5
+ export type OrderRefundStatus =
6
+ | 'not_refunded'
7
+ | 'partially_refunded'
8
+ | 'fully_refunded';
9
+
5
10
  export type OrderType =
6
11
  | 'default'
7
12
  | 'guest';
@@ -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';