@@ -2,30 +2,33 @@ import {Communicator} from './Communicator';
22
33export enum VendorEvent {
44 AddToCart = 'AddToCart' ,
5- DesignerHandoff = 'DesignerHandoff' ,
6- RequestToken = 'RequestToken' ,
7- ProjectDirty = 'ProjectDirty' ,
5+ AppInitialized = 'AppInitialized' ,
6+ ContactDesigner = 'ContactDesigner' ,
7+ DirtyStateChanged = 'DirtyStateChanged' ,
8+ IframeLoaded = 'IframeLoaded' ,
89 ProjectSaved = 'ProjectSaved' ,
910 ProjectDeleted = 'ProjectDeleted' ,
11+ TokenRefreshRequested = 'TokenRefreshRequested' ,
12+ UnauthorizedToken = 'UnauthorizedToken' ,
1013}
1114
12- interface ProjectDetails {
13- customerUid : number ;
14- projectId : number ;
15- projectVersion ?: number ;
15+ interface MetaData {
16+ title : string ;
1617 brand : string ;
1718 style : string ;
1819 color : string ;
19- url : string ;
20+ thumbnailUri : string ;
21+ area ?: number ;
2022}
2123
22- interface AtcPayload extends ProjectDetails {
23- //TODO: match this with correct formatting
24- bom : { } ;
25- }
26-
27- interface DesignerHandoffPayload extends ProjectDetails {
28- area : number ;
24+ interface EventPayload {
25+ schema : string ;
26+ token : string ;
27+ customerId : string ;
28+ projectId : string ;
29+ versionId : number ;
30+ metadata : MetaData ;
31+ bom ?: { } ;
2932}
3033
3134export class VendorCommunicator extends Communicator {
@@ -35,27 +38,39 @@ export class VendorCommunicator extends Communicator {
3538 this . origin = origin ;
3639 }
3740
38- addToCart ( payload : AtcPayload ) {
41+ addToCart ( payload : EventPayload ) {
3942 this . post ( { type : VendorEvent . AddToCart , payload} ) ;
4043 }
4144
42- designerHandoff ( payload : DesignerHandoffPayload ) {
43- this . post ( { type : VendorEvent . DesignerHandoff , payload} ) ;
45+ appInitialized ( ) {
46+ this . post ( { type : VendorEvent . AddToCart } ) ;
47+ }
48+
49+ contactDesigner ( payload : EventPayload ) {
50+ this . post ( { type : VendorEvent . ContactDesigner , payload} ) ;
4451 }
4552
46- requestToken ( ) {
47- this . post ( { type : VendorEvent . RequestToken , payload : '' } ) ;
53+ dirtyStateChanged ( ) {
54+ this . post ( { type : VendorEvent . DirtyStateChanged } ) ;
4855 }
4956
50- projectDirty ( ) {
51- this . post ( { type : VendorEvent . ProjectDirty , payload : '' } ) ;
57+ iframeLoaded ( ) {
58+ this . post ( { type : VendorEvent . IframeLoaded } ) ;
5259 }
5360
5461 projectSaved ( ) {
55- this . post ( { type : VendorEvent . ProjectSaved , payload : '' } ) ;
62+ this . post ( { type : VendorEvent . ProjectSaved } ) ;
5663 }
5764
5865 projectDeleted ( ) {
59- this . post ( { type : VendorEvent . ProjectDeleted , payload : '' } ) ;
66+ this . post ( { type : VendorEvent . ProjectDeleted } ) ;
67+ }
68+
69+ tokenRefreshRequested ( ) {
70+ this . post ( { type : VendorEvent . TokenRefreshRequested } ) ;
71+ }
72+
73+ unauthorizedToken ( error : string ) {
74+ this . post ( { type : VendorEvent . UnauthorizedToken , payload : error } ) ;
6075 }
6176}
0 commit comments