@wlloyalty/wll-react-sdk 1.3.0 → 1.4.0

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.
@@ -11,6 +11,7 @@ export type SDKConfig = {
11
11
  userToken?: string;
12
12
  fetcher?: Fetcher;
13
13
  locale?: string;
14
+ environment?: 'PRODUCTION' | 'STAGING' | 'DEVELOPMENT';
14
15
  };
15
16
  export type APIResponse<T> = {
16
17
  status: 'success' | 'error';
package/dist/web.js CHANGED
@@ -7843,7 +7843,24 @@ var useNavigation = function (config) {
7843
7843
  return handleNavigation;
7844
7844
  };
7845
7845
 
7846
- var baseUrl = 'https://api.staging.core.wlloyalty.net/v1';
7846
+ var getBaseUrl = function (environment) {
7847
+ if (environment === void 0) {
7848
+ environment = 'STAGING';
7849
+ }
7850
+ switch (environment) {
7851
+ case 'PRODUCTION':
7852
+ return 'https://api.core.wlloyalty.net/v1';
7853
+ case 'PRODUCTION-US':
7854
+ return 'https://api.core.us.wlloyalty.net/v1';
7855
+ case 'STAGING-US':
7856
+ return 'https://api.core.wlloyalty.net/v1';
7857
+ case 'DEVELOPMENT':
7858
+ return 'https://localhost:8080/v1';
7859
+ case 'STAGING':
7860
+ default:
7861
+ return 'https://api.staging.core.wlloyalty.net/v1';
7862
+ }
7863
+ };
7847
7864
  var useCreateRequestOptions = function (config) {
7848
7865
  return React.useCallback(function (options) {
7849
7866
  if (options === void 0) {
@@ -7915,9 +7932,11 @@ var createResourceGetter = function (resource, includeHydrate) {
7915
7932
  }
7916
7933
  // Always append locale=en
7917
7934
  params.append('locale', config.locale || 'en');
7935
+ var env = config.environment || 'STAGING';
7936
+ var baseUrl = getBaseUrl(env);
7918
7937
  var queryString = params.toString();
7919
7938
  return makeRequest("".concat(baseUrl, "/tiles-management/").concat(resource, "/").concat(id).concat(queryString ? "?".concat(queryString) : ''));
7920
- }, [makeRequest]);
7939
+ }, [makeRequest, config.environment]);
7921
7940
  };
7922
7941
  };
7923
7942
  var useGetGroupByID = createResourceGetter('groups', true);
@@ -8655,6 +8674,9 @@ var validateConfig = function (config) {
8655
8674
  if (config.locale && !/^[a-z]{2}$/.test(config.locale)) {
8656
8675
  throw new Error('Invalid locale format. Expected ISO 639-1 language code (e.g. "en")');
8657
8676
  }
8677
+ if (!config.environment) {
8678
+ config.environment = 'STAGING';
8679
+ }
8658
8680
  };
8659
8681
 
8660
8682
  function createVariantSystem(baseStyle, variantStyles) {