Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-152283: add acom wcs endpoint #12

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need to introduce a new parameter with a confusing name:domainSwitch ?
I would like to avoid having to support temporarily introduced parameters for ever.
Can we just switch to this new domain?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just to verify options request will be gone.
I will remove it in the following PR when actually implementing the switch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yesil we need both domains to work so we can compare stuff from same domain

}
}
}
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