@passly-nl/data 1.3.1 → 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/dist/index.d.mts +15 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +34 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/adapter/RefundAdapter.ts +8 -1
- package/src/dto/refund/RefundabilityDto.ts +29 -0
- package/src/dto/refund/index.ts +1 -0
- package/src/service/MerchantOrderService.ts +9 -1
- package/src/service/MerchantStatisticsService.ts +12 -0
- package/src/types/refund.ts +6 -0
package/package.json
CHANGED
|
@@ -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
|
+
}
|
package/src/dto/refund/index.ts
CHANGED
|
@@ -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`)
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { BaseResponse, BaseService, QueryString } from '@basmilius/http-client';
|
|
2
|
+
import { StatisticsChartAdapter } from '#data/adapter';
|
|
3
|
+
import type { StatisticsChartDto } from '#data/dto';
|
|
2
4
|
|
|
3
5
|
export class MerchantStatisticsService extends BaseService {
|
|
6
|
+
async getRevenueTrend(merchantId: string): Promise<BaseResponse<StatisticsChartDto>> {
|
|
7
|
+
return await this
|
|
8
|
+
.request(`/merchants/${merchantId}/statistics/revenue-trend`)
|
|
9
|
+
.method('get')
|
|
10
|
+
.queryString(QueryString.builder()
|
|
11
|
+
.append('language', 'nl'))
|
|
12
|
+
.bearerToken()
|
|
13
|
+
.runAdapter(StatisticsChartAdapter.parseChart);
|
|
14
|
+
}
|
|
15
|
+
|
|
4
16
|
async getStatus(merchantId: string): Promise<BaseResponse<boolean>> {
|
|
5
17
|
return await this
|
|
6
18
|
.request(`/merchants/${merchantId}/statistics/status`)
|