@rebuy/rebuy 1.3.0 → 1.3.3

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 (2) hide show
  1. package/api.js +26 -5
  2. package/package.json +1 -1
package/api.js CHANGED
@@ -7,10 +7,24 @@ const config = {
7
7
  eventDomain: 'https://rebuyengine.com',
8
8
  };
9
9
 
10
- const makeCall = async (method, path, data, origin, options) => {
10
+ const staging = {
11
+ domain: 'https://enigneyuber.com',
12
+ cdnDomain: 'https://cdn.enigneyuber.com',
13
+ eventDomain: 'https://enigneyuber.com',
14
+ };
15
+
16
+ const stagingDomains = [
17
+ 'enigneyuber.com',
18
+ 'rebuy-dev-checkout-extensions.myshopify.com',
19
+ 'rebuy-engine-regression.myshopify.com',
20
+ 'rebuy-stage-currency-test.myshopify.com',
21
+ 'rebuy-staging-automation.myshopify.com',
22
+ ];
23
+
24
+ const makeCall = async (method, path, data, origin, options = {}) => {
11
25
  const url = `${origin}${path}`;
12
26
  const requestUrl = new URL(url);
13
- const fetchOptions = options.fetch ?? {};
27
+ const fetchOptions = options?.fetch ?? {};
14
28
 
15
29
  const requestData = {
16
30
  key: config.key,
@@ -52,17 +66,24 @@ export class Api {
52
66
  } else if (typeof options == 'object' && options != null) {
53
67
  Object.assign(config, options);
54
68
  }
69
+
70
+ for (const domain of stagingDomains) {
71
+ if (location?.host?.includes(domain)) {
72
+ Object.assign(config, staging);
73
+ break;
74
+ }
75
+ }
55
76
  }
56
77
 
57
- async callEvent(method, path, data, options) {
78
+ async callEvent(method, path, data, options = {}) {
58
79
  return await makeCall(method, path, data, config.eventDomain, options);
59
80
  }
60
81
 
61
- async callCdn(method, path, data, options) {
82
+ async callCdn(method, path, data, options = {}) {
62
83
  return await makeCall(method, path, data, config.cdnDomain, options);
63
84
  }
64
85
 
65
- async callApi(method, path, data, options) {
86
+ async callApi(method, path, data, options = {}) {
66
87
  return await makeCall(method, path, data, config.domain, options);
67
88
  }
68
89
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebuy/rebuy",
3
3
  "description": "This is the default library for Rebuy",
4
- "version": "1.3.0",
4
+ "version": "1.3.3",
5
5
  "license": "MIT",
6
6
  "author": "Rebuy, Inc.",
7
7
  "type": "module",