natureco-sdk 1.0.2 → 1.0.4

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.
Files changed (3) hide show
  1. package/README.md +7 -1
  2. package/index.js +24 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -181,13 +181,19 @@ await client.apiKeys.revoke('key_id');
181
181
  ### Web Widget
182
182
 
183
183
  ```javascript
184
- // Get embed code
184
+ // Get embed code (simple usage)
185
+ const embedCode = client.widget.getEmbedCode('bot_id');
186
+
187
+ // Get embed code (with options)
185
188
  const embedCode = client.widget.getEmbedCode({
186
189
  botId: 'bot_id',
187
190
  theme: 'light', // 'light' or 'dark'
188
191
  position: 'bottom-right' // 'bottom-right', 'bottom-left', etc.
189
192
  });
190
193
 
194
+ // Or with separate parameters
195
+ const embedCode = client.widget.getEmbedCode('bot_id', 'dark', 'bottom-left');
196
+
191
197
  // Update widget settings
192
198
  await client.widget.updateSettings({
193
199
  botId: 'bot_id',
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * NatureCo JavaScript SDK
3
- * @version 1.0.2
3
+ * @version 1.0.4
4
4
  * @description Official JavaScript SDK for NatureCo API
5
5
  */
6
6
 
@@ -294,8 +294,29 @@ class WidgetModule {
294
294
  this.client = client;
295
295
  }
296
296
 
297
- getEmbedCode({ botId, theme = 'light', position = 'bottom-right' }) {
298
- return `<script src="https://cdn.natureco.me/widget.js" data-bot-id="${botId}" data-theme="${theme}" data-position="${position}"></script>`;
297
+ getEmbedCode(botIdOrOptions, theme = 'light', position = 'bottom-right') {
298
+ // Backward compatibility: botId string olarak geçilebilir veya options object
299
+ let botId, finalTheme, finalPosition;
300
+
301
+ if (typeof botIdOrOptions === 'string') {
302
+ // Eski kullanım: getEmbedCode(botId, theme, position)
303
+ botId = botIdOrOptions;
304
+ finalTheme = theme;
305
+ finalPosition = position;
306
+ } else if (typeof botIdOrOptions === 'object') {
307
+ // Yeni kullanım: getEmbedCode({ botId, theme, position })
308
+ botId = botIdOrOptions.botId;
309
+ finalTheme = botIdOrOptions.theme || 'light';
310
+ finalPosition = botIdOrOptions.position || 'bottom-right';
311
+ } else {
312
+ throw new Error('botId is required');
313
+ }
314
+
315
+ if (!botId) {
316
+ throw new Error('botId is required');
317
+ }
318
+
319
+ return `<script src="https://api.natureco.me/widget.js" data-bot-id="${botId}" data-theme="${finalTheme}" data-position="${finalPosition}"></script>`;
299
320
  }
300
321
 
301
322
  async updateSettings({ botId, theme, position, welcomeMessage, primaryColor }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Official JavaScript SDK for NatureCo API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",