@zohoim/client-sdk 1.0.0-poc57 → 1.0.0-poc59
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.
|
@@ -89,4 +89,33 @@ export default class BaseAPI {
|
|
|
89
89
|
return httpRequest;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
createAPIProxy(customAPI, defaultAPI) {
|
|
93
|
+
// If no custom API provided, just use default
|
|
94
|
+
if (!customAPI) {
|
|
95
|
+
return defaultAPI;
|
|
96
|
+
} // Create a proxy for method delegation
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
return new Proxy({}, {
|
|
100
|
+
get: (target, prop) => {
|
|
101
|
+
// For methods, check if custom implementation exists
|
|
102
|
+
if (typeof prop === 'string' && typeof customAPI[prop] === 'function') {
|
|
103
|
+
// Use custom implementation if available
|
|
104
|
+
return customAPI[prop].bind(customAPI);
|
|
105
|
+
} // Fall back to default implementation
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
return defaultAPI[prop].bind(defaultAPI);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
isMethodOverridden(defaultAPI, customAPI, methodName) {
|
|
114
|
+
if (!customAPI || customAPI === defaultAPI) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return customAPI[methodName] !== defaultAPI[methodName];
|
|
119
|
+
}
|
|
120
|
+
|
|
92
121
|
}
|
|
@@ -9,12 +9,23 @@ export default class BotRepository extends IBotRepository {
|
|
|
9
9
|
botAdapter
|
|
10
10
|
} = _ref;
|
|
11
11
|
super();
|
|
12
|
-
this.
|
|
12
|
+
this.defaultAPI = new BotAPI();
|
|
13
|
+
this.botAPI = this.createAPIProxy(botAPI, this.defaultAPI);
|
|
13
14
|
this.botAdapter = botAdapter || new BotAdapter();
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
isOverridden(methodName) {
|
|
18
|
+
return this.isMethodOverridden(this.defaultAPI, this.botAPI, methodName);
|
|
19
|
+
}
|
|
20
|
+
|
|
16
21
|
async getBots(request) {
|
|
17
22
|
const response = await this.botAPI.getBots(request);
|
|
23
|
+
const isOverridden = this.isOverridden('getBots');
|
|
24
|
+
|
|
25
|
+
if (isOverridden) {
|
|
26
|
+
return response;
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
return ResponseUtils.adaptListResponse(response, this.botAdapter.adapt);
|
|
19
30
|
}
|
|
20
31
|
|