@passly-nl/data 1.0.0-rc.9 → 1.0.1

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.0.0-rc.9",
4
+ "version": "1.0.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/basmilius",
@@ -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,
@@ -12,6 +12,7 @@ export class PublicShopAdapter {
12
12
  DateTimeAdapter.parseDateTime(data.starts_on),
13
13
  DateTimeAdapter.parseDateTime(data.ends_on),
14
14
  data.field_address,
15
+ data.field_address_mode,
15
16
  data.field_birthdate,
16
17
  data.field_gender,
17
18
  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
+ }
@@ -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';
@@ -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
@@ -11,6 +11,7 @@ export * from './product';
11
11
  export * from './publicPay';
12
12
  export * from './publicShop';
13
13
  export * from './reservation';
14
+ export * from './service';
14
15
  export * from './shortlink';
15
16
  export * from './statistics';
16
17
  export * from './ticket';
@@ -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';
@@ -78,6 +78,23 @@ export class MerchantEventShopService extends BaseService {
78
78
  .runArrayAdapter(EventAdapter.parseShopElement);
79
79
  }
80
80
 
81
+ async patchFields(merchantId: string, eventId: string, shop: ShopDto): Promise<BaseResponse<ShopDto>> {
82
+ return await this
83
+ .request(`/merchants/${merchantId}/events/${eventId}/shops/${shop.id}/fields`)
84
+ .method('patch')
85
+ .queryString(QueryString.builder()
86
+ .append('language', 'nl'))
87
+ .bearerToken()
88
+ .body({
89
+ field_address: shop.fieldAddress,
90
+ field_address_mode: shop.fieldAddressMode,
91
+ field_birthdate: shop.fieldBirthdate,
92
+ field_gender: shop.fieldGender,
93
+ field_phone_number: shop.fieldPhoneNumber
94
+ })
95
+ .runAdapter(EventAdapter.parseShop);
96
+ }
97
+
81
98
  async postShortlink(merchantId: string, eventId: string, shopId: string): Promise<BaseResponse<ShortlinkDto>> {
82
99
  return await this
83
100
  .request(`/merchants/${merchantId}/events/${eventId}/shops/${shopId}/shortlink`)
@@ -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 = {
@@ -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';
@@ -18,6 +18,11 @@ export type ShopElementType =
18
18
  | 'product'
19
19
  | 'text';
20
20
 
21
+ export type ShopAddressMode =
22
+ | 'full'
23
+ | 'city'
24
+ | 'postal_code_number';
25
+
21
26
  export type ShopFieldRequirement =
22
27
  | 'disabled'
23
28
  | 'enabled'