Skip to content

Commit

Permalink
Merge pull request #12 from 3ch023/MWPW-152283
Browse files Browse the repository at this point in the history
MWPW-152283: add acom wcs endpoint
  • Loading branch information
3ch023 authored Jun 24, 2024
2 parents dd5f72e + c22c3d6 commit f18620d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions commerce/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ declare global {
wcsBufferDelay: number;
wcsBufferLimit: number;
wcsEnv: Environment;
domainSwitch: boolean;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions commerce/src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ function getSettings(config = {}) {
getParameter('wcsBufferLimit', commerce),
Defaults.wcsBufferLimit
);
const domainSwitch = toBoolean(getParameter('domain.switch', commerce), false);

return {
...getLocaleSettings({ locale }),
Expand All @@ -228,6 +229,7 @@ function getSettings(config = {}) {
wcsBufferLimit,
wcsEnv: env === Env.STAGE ? WcsEnv.STAGE : WcsEnv.PRODUCTION,
landscape,
domainSwitch,
};
}

Expand Down
10 changes: 6 additions & 4 deletions commerce/src/wcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import { Log } from './log.js';
* reject: (reason: Error) => void
* }>} WcsPromises
*/

const ACOM = '_acom';
const WcsBaseUrl = {
[Env.PRODUCTION]: 'https://wcs.adobe.com',
[Env.STAGE]: 'https://wcs.stage.adobe.com',
[Env.PRODUCTION + ACOM]: 'https://www.adobe.com',
[Env.STAGE + ACOM]: 'https://www.stage.adobe.com',
};

/**
Expand All @@ -32,12 +34,12 @@ const WcsBaseUrl = {
*/
export function Wcs({ settings }) {
const log = Log.module('wcs');
const { env, wcsApiKey: apiKey } = settings;

const { env, domainSwitch, wcsApiKey: apiKey } = settings;
const baseUrl = domainSwitch ? WcsBaseUrl[env + ACOM] : WcsBaseUrl[env];
// Create @pandora Wcs client.
const fetchOptions = {
apiKey,
baseUrl: WcsBaseUrl[env],
baseUrl,
fetch: window.fetch.bind(window),
};
const getWcsOffers = webCommerceArtifact(fetchOptions);
Expand Down

0 comments on commit f18620d

Please sign in to comment.