@zohoim/client-sdk 1.0.0-poc61 → 1.0.0-poc63

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,7 +89,7 @@ export default class BaseAPI {
89
89
  return httpRequest;
90
90
  }
91
91
 
92
- createAPIProxy(customAPI, defaultAPI) {
92
+ createAPIProxy(customAPI, defaultAPI, defaultAPIInstance) {
93
93
  // If no custom API provided, just use default
94
94
  if (!customAPI) {
95
95
  return defaultAPI;
@@ -99,7 +99,7 @@ export default class BaseAPI {
99
99
  return new Proxy({}, {
100
100
  get: (target, prop) => {
101
101
  // For methods, check if custom implementation exists
102
- if (typeof prop === 'string' && typeof customAPI[prop] === 'function' && this.isMethodOverridden(defaultAPI, customAPI, prop)) {
102
+ if (typeof prop === 'string' && typeof customAPI[prop] === 'function' && this.isMethodOverridden(defaultAPIInstance, customAPI, prop)) {
103
103
  // Use custom implementation if available
104
104
  return customAPI[prop].bind(customAPI);
105
105
  } // Fall back to default implementation
@@ -110,12 +110,10 @@ export default class BaseAPI {
110
110
  });
111
111
  }
112
112
 
113
- isMethodOverridden(defaultAPI, customAPI, methodName) {
114
- if (!customAPI || customAPI === defaultAPI) {
115
- return false;
116
- }
117
-
118
- return customAPI[methodName] !== defaultAPI[methodName];
113
+ isMethodOverridden(defaultAPIInstance, customAPI, methodName) {
114
+ const basePrototype = defaultAPIInstance.prototype;
115
+ const injectedMethod = customAPI[methodName];
116
+ return injectedMethod !== basePrototype[methodName];
119
117
  }
120
118
 
121
119
  }
@@ -10,12 +10,12 @@ export default class BotRepository extends IBotRepository {
10
10
  } = _ref;
11
11
  super();
12
12
  this.defaultAPI = new BotAPI();
13
- this.botAPI = this.createAPIProxy(botAPI, this.defaultAPI);
13
+ this.botAPI = this.createAPIProxy(botAPI, this.defaultAPI, BotAPI);
14
14
  this.botAdapter = botAdapter || new BotAdapter();
15
15
  }
16
16
 
17
17
  isOverridden(methodName) {
18
- return this.isMethodOverridden(this.defaultAPI, this.botAPI, methodName);
18
+ return this.isMethodOverridden(BotAPI, this.botAPI, methodName);
19
19
  }
20
20
 
21
21
  async getBots(request) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "1.0.0-poc61",
3
+ "version": "1.0.0-poc63",
4
4
  "description": "To have the client sdk for the IM",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",