Skip to content

Commit 3de404c

Browse files
Add Vendor-Continue to Cart and Client-AddToCartStatus events (#16)
Co-authored-by: Utsav Beri <uberi@wayfair.com>
1 parent d06a350 commit 3de404c

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ and this project adheres to
1010

1111
### TBA
1212

13+
## [v4.1.0] - 2022-12-23
14+
15+
- Added Continue to Cart Event to the Vendor Communicator
16+
- Added Add To Cart Status Event to the Client Communicator
17+
1318
## [v4.0.0] - 2022-11-23
1419

1520
- Update Metadata shape to add source and price

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ no parameters
105105

106106
no parameters
107107

108+
### `continueToCart`
109+
110+
| Parameter Name | Required | Description | Type | Default |
111+
| -------------- | -------- | ---------------------- | ------ | --------- |
112+
| customerUid | yes | customer identifier | string | |
113+
| projectId | yes | project identifier | string | |
114+
| projectVersion | no | project version | string | |
115+
| brand | yes | brand description | string | |
116+
| style | yes | style description | string | |
117+
| color | yes | color | string | |
118+
| url | yes | thumbnail image url | string | |
119+
| bom | yes | bill of materials | string | |
120+
108121
## Client Communicator API
109122

110123
### `init`
@@ -120,6 +133,15 @@ no parameters
120133
| -------------- | -------- | ------------------------------------- | ------ | ------- |
121134
| token | yes | JWT token with initialization payload | string | |
122135

136+
### `addToCartStatus`
137+
138+
| Parameter Name | Required | Description | Type | Default |
139+
| ----------------- | -------- | -------------------------------------------------------- | ------ | ------- |
140+
| success | yes | flag indicating if the add to cart event succeded or not | boolean| |
141+
| message | yes | status message | string | |
142+
| projectId | yes | project id | string | |
143+
| versionId | yes | project version | string | |
144+
123145
## Roadmap
124146

125147
See the

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postmessage-communicator",
3-
"version": "4.0.0",
3+
"version": "4.1.0",
44
"description": "[![Release](https://img.shields.io/github/v/release/wayfair-incubator/oss-template?display_name=tag)](CHANGELOG.md) [![Lint](https://github.com/wayfair-incubator/oss-template/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/wayfair-incubator/oss-template/actions/workflows/lint.yml) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md) [![Maintainer](https://img.shields.io/badge/Maintainer-Wayfair-7F187F)](https://wayfair.github.io)",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/classes/ClientCommunicator.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@ import {Communicator} from './Communicator';
33
export enum ClientEvent {
44
LoginWithToken = 'LoginWithToken',
55
RefreshWithToken = 'RefreshWithToken',
6+
AddToCartStatus = 'AddToCartStatus',
67
}
78

89
interface InitPayload {
910
token: string;
1011
landingExperience: string;
1112
}
1213

14+
interface AddToCartStatusPayload {
15+
success: boolean;
16+
message: string;
17+
projectId: string;
18+
versionId: string;
19+
}
1320
export class ClientCommunicator extends Communicator {
1421
init(payload: InitPayload): void {
1522
this.post({type: ClientEvent.LoginWithToken, payload});
1623
}
1724
refreshWithToken(token: string): void {
1825
this.post({type: ClientEvent.RefreshWithToken, payload: token});
1926
}
27+
addToCartStatus(payload: AddToCartStatusPayload): void {
28+
this.post({type: ClientEvent.AddToCartStatus, payload})
29+
}
2030
}

src/classes/VendorCommunicator.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export enum VendorEvent {
1111
TrackingEvent = 'TrackingEvent',
1212
TokenRefreshRequested = 'TokenRefreshRequested',
1313
UnauthorizedToken = 'UnauthorizedToken',
14+
ContinueToCart = 'ContinueToCart',
1415
}
1516

1617
interface Metadata {
@@ -85,4 +86,8 @@ export class VendorCommunicator extends Communicator {
8586
unauthorizedToken(error: string): void {
8687
this.post({type: VendorEvent.UnauthorizedToken, payload: error});
8788
}
89+
90+
continueToCart(payload: EventPayload): void {
91+
this.post({type: VendorEvent.ContinueToCart, payload})
92+
}
8893
}

0 commit comments

Comments
 (0)