@passly-nl/data 1.4.2 → 1.4.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.4.2",
4
+ "version": "1.4.3",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/basmilius",
@@ -77,7 +77,9 @@ export class EventAdapter {
77
77
  return new ShopDesignDto(
78
78
  data.background_color,
79
79
  data.foreground_color,
80
- data.primary_color
80
+ data.primary_color,
81
+ optional(data.background, FileSystemAdapter.parsePicture),
82
+ data.background_scrim ?? 0
81
83
  );
82
84
  }
83
85
 
@@ -27,7 +27,9 @@ export class PublicShopAdapter {
27
27
  return new PublicShopDesignDto(
28
28
  data.background_color,
29
29
  data.foreground_color,
30
- data.primary_color
30
+ data.primary_color,
31
+ optional(data.background, FileSystemAdapter.parsePicture),
32
+ data.background_scrim ?? 0
31
33
  );
32
34
  }
33
35
 
@@ -1,4 +1,5 @@
1
1
  import { dto } from '@basmilius/http-client';
2
+ import type { PictureDto } from '#data/dto';
2
3
 
3
4
  @dto
4
5
  export class ShopDesignDto {
@@ -26,13 +27,33 @@ export class ShopDesignDto {
26
27
  this.#primaryColor = value;
27
28
  }
28
29
 
30
+ get background(): PictureDto | null {
31
+ return this.#background;
32
+ }
33
+
34
+ set background(value: PictureDto | null) {
35
+ this.#background = value;
36
+ }
37
+
38
+ get backgroundScrim(): number {
39
+ return this.#backgroundScrim;
40
+ }
41
+
42
+ set backgroundScrim(value: number) {
43
+ this.#backgroundScrim = value;
44
+ }
45
+
29
46
  #backgroundColor: string;
30
47
  #foregroundColor: string;
31
48
  #primaryColor: string;
49
+ #background: PictureDto | null;
50
+ #backgroundScrim: number;
32
51
 
33
- constructor(backgroundColor: string, foregroundColor: string, primaryColor: string) {
52
+ constructor(backgroundColor: string, foregroundColor: string, primaryColor: string, background: PictureDto | null, backgroundScrim: number) {
34
53
  this.#backgroundColor = backgroundColor;
35
54
  this.#foregroundColor = foregroundColor;
36
55
  this.#primaryColor = primaryColor;
56
+ this.#background = background;
57
+ this.#backgroundScrim = backgroundScrim;
37
58
  }
38
59
  }
@@ -1,4 +1,5 @@
1
1
  import { dto } from '@basmilius/http-client';
2
+ import type { PictureDto } from '#data/dto';
2
3
 
3
4
  @dto
4
5
  export class PublicShopDesignDto {
@@ -26,13 +27,33 @@ export class PublicShopDesignDto {
26
27
  this.#primaryColor = value;
27
28
  }
28
29
 
30
+ get background(): PictureDto | null {
31
+ return this.#background;
32
+ }
33
+
34
+ set background(value: PictureDto | null) {
35
+ this.#background = value;
36
+ }
37
+
38
+ get backgroundScrim(): number {
39
+ return this.#backgroundScrim;
40
+ }
41
+
42
+ set backgroundScrim(value: number) {
43
+ this.#backgroundScrim = value;
44
+ }
45
+
29
46
  #backgroundColor: string;
30
47
  #foregroundColor: string;
31
48
  #primaryColor: string;
49
+ #background: PictureDto | null;
50
+ #backgroundScrim: number;
32
51
 
33
- constructor(backgroundColor: string, foregroundColor: string, primaryColor: string) {
52
+ constructor(backgroundColor: string, foregroundColor: string, primaryColor: string, background: PictureDto | null, backgroundScrim: number) {
34
53
  this.#backgroundColor = backgroundColor;
35
54
  this.#foregroundColor = foregroundColor;
36
55
  this.#primaryColor = primaryColor;
56
+ this.#background = background;
57
+ this.#backgroundScrim = backgroundScrim;
37
58
  }
38
59
  }
@@ -1,6 +1,6 @@
1
1
  import { BaseResponse, BaseService, QueryString } from '@basmilius/http-client';
2
- import { EventAdapter, ShortlinkAdapter } from '#data/adapter';
3
- import type { ShopDesignDto, ShopDto, ShopElementDto, ShortlinkDto } from '#data/dto';
2
+ import { CommonAdapter, EventAdapter, ShortlinkAdapter } from '#data/adapter';
3
+ import type { ShopDesignDto, ShopDto, ShopElementDto, ShortlinkDto, StatusResponseDto } from '#data/dto';
4
4
 
5
5
  export class MerchantEventShopService extends BaseService {
6
6
  async get(merchantId: string, eventId: string, shopId: string): Promise<BaseResponse<ShopDto>> {
@@ -60,7 +60,8 @@ export class MerchantEventShopService extends BaseService {
60
60
  .body({
61
61
  background_color: design.backgroundColor,
62
62
  foreground_color: design.foregroundColor,
63
- primary_color: design.primaryColor
63
+ primary_color: design.primaryColor,
64
+ background_scrim: design.backgroundScrim
64
65
  })
65
66
  .runAdapter(EventAdapter.parseShopDesign);
66
67
  }
@@ -95,6 +96,20 @@ export class MerchantEventShopService extends BaseService {
95
96
  .runAdapter(EventAdapter.parseShop);
96
97
  }
97
98
 
99
+ async postBackground(merchantId: string, eventId: string, shopId: string, picture: File): Promise<BaseResponse<StatusResponseDto>> {
100
+ const data = new FormData();
101
+ data.append('file', picture);
102
+
103
+ return await this
104
+ .request(`/merchants/${merchantId}/events/${eventId}/shops/${shopId}/design/background`)
105
+ .method('post')
106
+ .queryString(QueryString.builder()
107
+ .append('language', 'nl'))
108
+ .bearerToken()
109
+ .body(data)
110
+ .runAdapter(CommonAdapter.parseStatusResponse);
111
+ }
112
+
98
113
  async postShortlink(merchantId: string, eventId: string, shopId: string): Promise<BaseResponse<ShortlinkDto>> {
99
114
  return await this
100
115
  .request(`/merchants/${merchantId}/events/${eventId}/shops/${shopId}/shortlink`)
@@ -104,4 +119,14 @@ export class MerchantEventShopService extends BaseService {
104
119
  .bearerToken()
105
120
  .runAdapter(ShortlinkAdapter.parse);
106
121
  }
122
+
123
+ async deleteBackground(merchantId: string, eventId: string, shopId: string): Promise<BaseResponse<StatusResponseDto>> {
124
+ return await this
125
+ .request(`/merchants/${merchantId}/events/${eventId}/shops/${shopId}/design/background`)
126
+ .method('delete')
127
+ .queryString(QueryString.builder()
128
+ .append('language', 'nl'))
129
+ .bearerToken()
130
+ .runAdapter(CommonAdapter.parseStatusResponse);
131
+ }
107
132
  }