@passly-nl/data 1.0.0-rc.9 → 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/index.d.mts +39 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/adapter/EventAdapter.ts +1 -0
- package/src/adapter/PublicShopAdapter.ts +1 -0
- package/src/adapter/ServiceAdapter.ts +13 -0
- package/src/adapter/index.ts +1 -0
- package/src/dto/event/ShopDto.ts +12 -2
- package/src/dto/index.ts +1 -0
- package/src/dto/publicShop/PublicShopDto.ts +12 -2
- package/src/dto/service/ServiceInfoDto.ts +38 -0
- package/src/dto/service/index.ts +1 -0
- package/src/service/MerchantShopService.ts +35 -0
- package/src/service/MerchantShopsService.ts +17 -0
- package/src/service/PublicShopService.ts +22 -2
- package/src/service/ServicesService.ts +10 -0
- package/src/service/index.ts +2 -0
- package/src/types/event.ts +5 -0
package/package.json
CHANGED
|
@@ -61,6 +61,7 @@ export class EventAdapter {
|
|
|
61
61
|
optional(data.starts_on, DateTimeAdapter.parseDateTime),
|
|
62
62
|
optional(data.ends_on, DateTimeAdapter.parseDateTime),
|
|
63
63
|
data.field_address,
|
|
64
|
+
data.field_address_mode,
|
|
64
65
|
data.field_birthdate,
|
|
65
66
|
data.field_gender,
|
|
66
67
|
data.field_phone_number,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { adapter, type ForeignData } from '@basmilius/http-client';
|
|
2
|
+
import { ServiceInfoDto } from '#data/dto';
|
|
3
|
+
|
|
4
|
+
@adapter
|
|
5
|
+
export class ServiceAdapter {
|
|
6
|
+
static parseInfo(data: ForeignData): ServiceInfoDto {
|
|
7
|
+
return new ServiceInfoDto(
|
|
8
|
+
data.connecting_ip,
|
|
9
|
+
data.country,
|
|
10
|
+
data.ray
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/adapter/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './ProductAdapter';
|
|
|
15
15
|
export * from './PublicPayAdapter';
|
|
16
16
|
export * from './PublicShopAdapter';
|
|
17
17
|
export * from './ReservationAdapter';
|
|
18
|
+
export * from './ServiceAdapter';
|
|
18
19
|
export * from './ShortlinkAdapter';
|
|
19
20
|
export * from './StatisticsAdapter';
|
|
20
21
|
export * from './StatisticsBuyersAdapter';
|
package/src/dto/event/ShopDto.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dto } from '@basmilius/http-client';
|
|
2
2
|
import type { DateTime } from 'luxon';
|
|
3
3
|
import type { EventDto, MerchantDto, ShopDesignDto } from '#data/dto';
|
|
4
|
-
import type { ShopFieldRequirement, ShopStatus } from '#data/types';
|
|
4
|
+
import type { ShopAddressMode, ShopFieldRequirement, ShopStatus } from '#data/types';
|
|
5
5
|
|
|
6
6
|
@dto
|
|
7
7
|
export class ShopDto {
|
|
@@ -61,6 +61,14 @@ export class ShopDto {
|
|
|
61
61
|
this.#fieldAddress = value;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
get fieldAddressMode(): ShopAddressMode {
|
|
65
|
+
return this.#fieldAddressMode;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
set fieldAddressMode(value: ShopAddressMode) {
|
|
69
|
+
this.#fieldAddressMode = value;
|
|
70
|
+
}
|
|
71
|
+
|
|
64
72
|
get fieldBirthdate(): ShopFieldRequirement {
|
|
65
73
|
return this.#fieldBirthdate;
|
|
66
74
|
}
|
|
@@ -124,6 +132,7 @@ export class ShopDto {
|
|
|
124
132
|
#startsOn: DateTime | null;
|
|
125
133
|
#endsOn: DateTime | null;
|
|
126
134
|
#fieldAddress: ShopFieldRequirement;
|
|
135
|
+
#fieldAddressMode: ShopAddressMode;
|
|
127
136
|
#fieldBirthdate: ShopFieldRequirement;
|
|
128
137
|
#fieldGender: ShopFieldRequirement;
|
|
129
138
|
#fieldPhoneNumber: ShopFieldRequirement;
|
|
@@ -132,7 +141,7 @@ export class ShopDto {
|
|
|
132
141
|
#event: EventDto;
|
|
133
142
|
#merchant: MerchantDto;
|
|
134
143
|
|
|
135
|
-
constructor(id: string, name: string, isPublished: boolean, password: string, startsOn: DateTime | null, endsOn: DateTime | null, fieldAddress: ShopFieldRequirement, fieldBirthdate: ShopFieldRequirement, fieldGender: ShopFieldRequirement, fieldPhoneNumber: ShopFieldRequirement, status: ShopStatus, design: ShopDesignDto, event: EventDto, merchant: MerchantDto) {
|
|
144
|
+
constructor(id: string, name: string, isPublished: boolean, password: string, startsOn: DateTime | null, endsOn: DateTime | null, fieldAddress: ShopFieldRequirement, fieldAddressMode: ShopAddressMode, fieldBirthdate: ShopFieldRequirement, fieldGender: ShopFieldRequirement, fieldPhoneNumber: ShopFieldRequirement, status: ShopStatus, design: ShopDesignDto, event: EventDto, merchant: MerchantDto) {
|
|
136
145
|
this.#id = id;
|
|
137
146
|
this.#name = name;
|
|
138
147
|
this.#isPublished = isPublished;
|
|
@@ -140,6 +149,7 @@ export class ShopDto {
|
|
|
140
149
|
this.#startsOn = startsOn;
|
|
141
150
|
this.#endsOn = endsOn;
|
|
142
151
|
this.#fieldAddress = fieldAddress;
|
|
152
|
+
this.#fieldAddressMode = fieldAddressMode;
|
|
143
153
|
this.#fieldBirthdate = fieldBirthdate;
|
|
144
154
|
this.#fieldGender = fieldGender;
|
|
145
155
|
this.#fieldPhoneNumber = fieldPhoneNumber;
|
package/src/dto/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dto } from '@basmilius/http-client';
|
|
2
2
|
import type { DateTime } from 'luxon';
|
|
3
3
|
import type { PublicShopDesignDto, PublicShopElementDto, PublicShopEventDto, PublicShopMerchantDto } from '#data/dto';
|
|
4
|
-
import type { ShopFieldRequirement } from '#data/types';
|
|
4
|
+
import type { ShopAddressMode, ShopFieldRequirement } from '#data/types';
|
|
5
5
|
|
|
6
6
|
@dto
|
|
7
7
|
export class PublicShopDto {
|
|
@@ -45,6 +45,14 @@ export class PublicShopDto {
|
|
|
45
45
|
this.#fieldAddress = value;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
get fieldAddressMode(): ShopAddressMode {
|
|
49
|
+
return this.#fieldAddressMode;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
set fieldAddressMode(value: ShopAddressMode) {
|
|
53
|
+
this.#fieldAddressMode = value;
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
get fieldBirthdate(): ShopFieldRequirement {
|
|
49
57
|
return this.#fieldBirthdate;
|
|
50
58
|
}
|
|
@@ -106,6 +114,7 @@ export class PublicShopDto {
|
|
|
106
114
|
#startsOn: DateTime;
|
|
107
115
|
#endsOn: DateTime;
|
|
108
116
|
#fieldAddress: ShopFieldRequirement;
|
|
117
|
+
#fieldAddressMode: ShopAddressMode;
|
|
109
118
|
#fieldBirthdate: ShopFieldRequirement;
|
|
110
119
|
#fieldGender: ShopFieldRequirement;
|
|
111
120
|
#fieldPhoneNumber: ShopFieldRequirement;
|
|
@@ -114,12 +123,13 @@ export class PublicShopDto {
|
|
|
114
123
|
#event: PublicShopEventDto;
|
|
115
124
|
#merchant: PublicShopMerchantDto;
|
|
116
125
|
|
|
117
|
-
constructor(id: string, name: string, startsOn: DateTime, endsOn: DateTime, fieldAddress: ShopFieldRequirement, fieldBirthdate: ShopFieldRequirement, fieldGender: ShopFieldRequirement, fieldPhoneNumber: ShopFieldRequirement, design: PublicShopDesignDto, elements: PublicShopElementDto[] | null, event: PublicShopEventDto, merchant: PublicShopMerchantDto) {
|
|
126
|
+
constructor(id: string, name: string, startsOn: DateTime, endsOn: DateTime, fieldAddress: ShopFieldRequirement, fieldAddressMode: ShopAddressMode, fieldBirthdate: ShopFieldRequirement, fieldGender: ShopFieldRequirement, fieldPhoneNumber: ShopFieldRequirement, design: PublicShopDesignDto, elements: PublicShopElementDto[] | null, event: PublicShopEventDto, merchant: PublicShopMerchantDto) {
|
|
118
127
|
this.#id = id;
|
|
119
128
|
this.#name = name;
|
|
120
129
|
this.#startsOn = startsOn;
|
|
121
130
|
this.#endsOn = endsOn;
|
|
122
131
|
this.#fieldAddress = fieldAddress;
|
|
132
|
+
this.#fieldAddressMode = fieldAddressMode;
|
|
123
133
|
this.#fieldBirthdate = fieldBirthdate;
|
|
124
134
|
this.#fieldGender = fieldGender;
|
|
125
135
|
this.#fieldPhoneNumber = fieldPhoneNumber;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { dto } from '@basmilius/http-client';
|
|
2
|
+
|
|
3
|
+
@dto
|
|
4
|
+
export class ServiceInfoDto {
|
|
5
|
+
get connectingIp(): string {
|
|
6
|
+
return this.#connectingIp;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
set connectingIp(value: string) {
|
|
10
|
+
this.#connectingIp = value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get country(): string | null {
|
|
14
|
+
return this.#country;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
set country(value: string | null) {
|
|
18
|
+
this.#country = value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get ray(): string | null {
|
|
22
|
+
return this.#ray;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set ray(value: string | null) {
|
|
26
|
+
this.#ray = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#connectingIp: string;
|
|
30
|
+
#country: string | null;
|
|
31
|
+
#ray: string | null;
|
|
32
|
+
|
|
33
|
+
constructor(connectingIp: string, country: string | null, ray: string | null) {
|
|
34
|
+
this.#connectingIp = connectingIp;
|
|
35
|
+
this.#country = country;
|
|
36
|
+
this.#ray = ray;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ServiceInfoDto';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseResponse, BaseService, QueryString } from '@basmilius/http-client';
|
|
2
|
+
import { EventAdapter, PublicShopAdapter } from '#data/adapter';
|
|
3
|
+
import type { PublicShopDto, ShopDto, ShopElementDto } from '#data/dto';
|
|
4
|
+
|
|
5
|
+
export class MerchantShopService extends BaseService {
|
|
6
|
+
async get(merchantId: string, shopId: string): Promise<BaseResponse<ShopDto>> {
|
|
7
|
+
return await this
|
|
8
|
+
.request(`/merchants/${merchantId}/shops/${shopId}`)
|
|
9
|
+
.method('get')
|
|
10
|
+
.queryString(QueryString.builder()
|
|
11
|
+
.append('language', 'nl'))
|
|
12
|
+
.bearerToken()
|
|
13
|
+
.runAdapter(EventAdapter.parseShop);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getElements(merchantId: string, shopId: string): Promise<BaseResponse<ShopElementDto[]>> {
|
|
17
|
+
return await this
|
|
18
|
+
.request(`/merchants/${merchantId}/shops/${shopId}/elements`)
|
|
19
|
+
.method('get')
|
|
20
|
+
.queryString(QueryString.builder()
|
|
21
|
+
.append('language', 'nl'))
|
|
22
|
+
.bearerToken()
|
|
23
|
+
.runArrayAdapter(EventAdapter.parseShopElement);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getPreview(merchantId: string, shopId: string): Promise<BaseResponse<PublicShopDto>> {
|
|
27
|
+
return await this
|
|
28
|
+
.request(`/merchants/${merchantId}/shops/${shopId}/preview`)
|
|
29
|
+
.method('get')
|
|
30
|
+
.queryString(QueryString.builder()
|
|
31
|
+
.append('language', 'nl'))
|
|
32
|
+
.bearerToken()
|
|
33
|
+
.runAdapter(PublicShopAdapter.parsePublicShop);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseResponse, BaseService, Paginated, QueryString } from '@basmilius/http-client';
|
|
2
|
+
import { EventAdapter } from '#data/adapter';
|
|
3
|
+
import type { ShopDto } from '#data/dto';
|
|
4
|
+
|
|
5
|
+
export class MerchantShopsService extends BaseService {
|
|
6
|
+
async get(merchantId: string, offset: number, limit: number): Promise<BaseResponse<Paginated<ShopDto>>> {
|
|
7
|
+
return await this
|
|
8
|
+
.request(`/merchants/${merchantId}/shops`)
|
|
9
|
+
.method('get')
|
|
10
|
+
.queryString(QueryString.builder()
|
|
11
|
+
.append('language', 'nl')
|
|
12
|
+
.append('offset', offset)
|
|
13
|
+
.append('limit', limit))
|
|
14
|
+
.bearerToken()
|
|
15
|
+
.runPaginatedAdapter(EventAdapter.parseShop);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { DateTime } from 'luxon';
|
|
|
3
3
|
import { OrderAdapter, PublicShopAdapter } from '#data/adapter';
|
|
4
4
|
import type { OrderDto, PublicShopCartProductDto, PublicShopDto, PublicShopReservationDto } from '#data/dto';
|
|
5
5
|
import type { Gender } from '#data/types';
|
|
6
|
+
import { emptyNull } from '#data/util';
|
|
6
7
|
|
|
7
8
|
export class PublicShopService extends BaseService {
|
|
8
9
|
async get(shopId: string): Promise<BaseResponse<PublicShopDto>> {
|
|
@@ -14,7 +15,25 @@ export class PublicShopService extends BaseService {
|
|
|
14
15
|
.runAdapter(PublicShopAdapter.parsePublicShop);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
async buy(shopId: string, reservationId: string, firstName: string, lastName: string, email: string, phoneNumber: string, dateOfBirth: DateTime | null, gender: Gender | null): Promise<BaseResponse<OrderDto>> {
|
|
18
|
+
async buy(shopId: string, reservationId: string, firstName: string, lastName: string, email: string, phoneNumber: string, dateOfBirth: DateTime | null, gender: Gender | null, addressCity: string | null, addressCountry: string | null, addressNumber: string | null, addressPostalCode: string | null, addressStreet: string | null): Promise<BaseResponse<OrderDto>> {
|
|
19
|
+
let address: Record<string, string | null> = null;
|
|
20
|
+
|
|
21
|
+
addressCity = emptyNull(addressCity);
|
|
22
|
+
addressCountry = emptyNull(addressCountry);
|
|
23
|
+
addressNumber = emptyNull(addressNumber);
|
|
24
|
+
addressPostalCode = emptyNull(addressPostalCode);
|
|
25
|
+
addressStreet = emptyNull(addressStreet);
|
|
26
|
+
|
|
27
|
+
if (addressCity || addressCountry || addressNumber || addressPostalCode || addressStreet) {
|
|
28
|
+
address = {
|
|
29
|
+
city: addressCity,
|
|
30
|
+
country_code: addressCountry,
|
|
31
|
+
number: addressNumber,
|
|
32
|
+
postal_code: addressPostalCode,
|
|
33
|
+
street: addressStreet
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
18
37
|
return await this
|
|
19
38
|
.request(`/shops/${shopId}/buy/${reservationId}`)
|
|
20
39
|
.method('post')
|
|
@@ -26,7 +45,8 @@ export class PublicShopService extends BaseService {
|
|
|
26
45
|
email: email,
|
|
27
46
|
phone_number: phoneNumber.trim() === '' ? null : phoneNumber.trim(),
|
|
28
47
|
date_of_birth: dateOfBirth?.toISODate(),
|
|
29
|
-
gender: gender
|
|
48
|
+
gender: gender,
|
|
49
|
+
address
|
|
30
50
|
})
|
|
31
51
|
.runAdapter(OrderAdapter.parseOrder);
|
|
32
52
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BaseResponse, BaseService, QueryString } from '@basmilius/http-client';
|
|
2
|
+
import { ServiceInfoDto } from '#data/dto';
|
|
2
3
|
|
|
3
4
|
export class ServicesService extends BaseService {
|
|
4
5
|
async checkEmail(email: string): Promise<BaseResponse<CheckEmailResponse>> {
|
|
@@ -10,6 +11,15 @@ export class ServicesService extends BaseService {
|
|
|
10
11
|
.append('language', 'nl'))
|
|
11
12
|
.run();
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
async getInfo(): Promise<BaseResponse<ServiceInfoDto>> {
|
|
16
|
+
return await this
|
|
17
|
+
.request('/service/info')
|
|
18
|
+
.method('get')
|
|
19
|
+
.queryString(QueryString.builder()
|
|
20
|
+
.append('language', 'nl'))
|
|
21
|
+
.run();
|
|
22
|
+
}
|
|
13
23
|
}
|
|
14
24
|
|
|
15
25
|
type CheckEmailResponse = {
|
package/src/service/index.ts
CHANGED
|
@@ -22,6 +22,8 @@ export * from './MerchantFinanceInvoicesService';
|
|
|
22
22
|
export * from './MerchantFinanceService';
|
|
23
23
|
export * from './MerchantOrderService';
|
|
24
24
|
export * from './MerchantOrdersService';
|
|
25
|
+
export * from './MerchantShopService';
|
|
26
|
+
export * from './MerchantShopsService';
|
|
25
27
|
export * from './MerchantStatisticsService';
|
|
26
28
|
export * from './MerchantStatisticsBuyersService';
|
|
27
29
|
export * from './MerchantStatisticsEventsService';
|