-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsd-specific.example.ts
More file actions
executable file
·119 lines (97 loc) · 3.95 KB
/
Copy pathsd-specific.example.ts
File metadata and controls
executable file
·119 lines (97 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import {
QUERYPARAM_MODELSTATEID,
QUERYPARAM_SETTINGSURL,
} from "@AppBuilderShared/shared/config/queryparams";
import type {IAppBuilderUrlBuilderData} from "@AppBuilderShared/shared/lib/urlbuilder";
import type {
IAddItemToCartData,
IAddItemToCartReply,
IECommerceApiActions,
IGetParentPageInfoReply,
IGetUserProfileReply,
IMessageToParentData,
IMessageToParentReply,
IScrollingApiLoadMoreData,
IScrollingApiLoadMoreReply,
IScrollingApiSetParametersData,
IScrollingApiSetParametersReply,
IUpdateSharingLinkData,
IUpdateSharingLinkReply,
} from "@AppBuilderShared/features/ecommerce/config/ecommerceapi";
/**
* This file contains an example override implementation of IECommerceApiAction
* for the App Builder iframe. If you need specific actions to be implemented
* for your WordPress setup, this is a good starting point. Rename this file
* to sd-specific.ts and implement your custom actions. Then build the plugin.
*/
/**
* Specific implementation of IECommerceApiActions for the App Builder iframe.
* This can be used to override the default actions.
*/
class SpecificECommerceApiActions implements IECommerceApiActions {
constructor(private defaultActions?: IECommerceApiActions) {}
getParentPageInfo(): Promise<IGetParentPageInfoReply> {
// remove the following line if you want to implement a custom action
if (this.defaultActions) return this.defaultActions.getParentPageInfo();
return Promise.reject("Not implemented");
}
closeConfigurator(): Promise<boolean> {
// remove the following line if you want to implement a custom action
if (this.defaultActions) return this.defaultActions.closeConfigurator();
return Promise.reject("Not implemented");
}
addItemToCart(data: IAddItemToCartData): Promise<IAddItemToCartReply> {
// remove the following line if you want to implement a custom action
if (this.defaultActions) return this.defaultActions.addItemToCart(data);
return Promise.reject("Not implemented");
}
getUserProfile(): Promise<IGetUserProfileReply> {
// remove the following line if you want to implement a custom action
if (this.defaultActions) return this.defaultActions.getUserProfile();
return Promise.reject("Not implemented");
}
updateSharingLink(
data: IUpdateSharingLinkData,
): Promise<IUpdateSharingLinkReply> {
// remove the following line if you want to implement a custom action
if (this.defaultActions)
return this.defaultActions.updateSharingLink(data);
return Promise.reject("Not implemented");
}
async scrollingApiSetParameters(
data: IScrollingApiSetParametersData,
): Promise<IScrollingApiSetParametersReply<unknown>> {
// remove the following line if you want to implement a custom action
if (this.defaultActions)
return this.defaultActions.scrollingApiSetParameters(data);
return Promise.reject("Not implemented");
}
async scrollingApiLoadMore(
data: IScrollingApiLoadMoreData,
): Promise<IScrollingApiLoadMoreReply<unknown>> {
// remove the following line if you want to implement a custom action
if (this.defaultActions)
return this.defaultActions.scrollingApiLoadMore(data);
return Promise.reject("Not implemented");
}
messageToParent(
data: IMessageToParentData,
): Promise<IMessageToParentReply> {
if (this.defaultActions)
return this.defaultActions.messageToParent(data);
return Promise.reject("Not implemented");
}
}
(globalThis as {[key: string]: any}).specificECommerceApiActions =
new SpecificECommerceApiActions();
const urlParams = new URLSearchParams(window.location.search);
/**
* URL builder options for local development environment.
*/
export const developmentUrlBuilderOptions: IAppBuilderUrlBuilderData = {
baseUrl: `https://appbuilder.shapediver.com/v1/main/${urlParams.get("appBuilderVersion") ?? "development"}/`,
settingsUrl: urlParams.get(QUERYPARAM_SETTINGSURL) ?? undefined,
modelStateId: urlParams.get(QUERYPARAM_MODELSTATEID) ?? undefined,
};
(globalThis as {[key: string]: any}).developmentUrlBuilderOptions =
developmentUrlBuilderOptions;