Skip to content

Commit

Permalink
fix: handle subaccount case in gaec
Browse files Browse the repository at this point in the history
  • Loading branch information
AASHISH MALIK committed Nov 13, 2024
1 parent d76c37d commit db5669b
Show file tree
Hide file tree
Showing 2 changed files with 393 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ const responseBuilder = async (metadata, message, { Config }, payload) => {
let { customerId, loginCustomerId } = Config;
const { configData } = Config;

let configDetails = {};
if (isDefinedAndNotNull(configData)) {
const configDetails = JSON.parse(configData);
configDetails = JSON.parse(configData);
customerId = configDetails.customerId;
if (isDefined(configDetails.loginCustomerId)) {
loginCustomerId = configDetails.loginCustomerId;
Expand All @@ -70,6 +71,7 @@ const responseBuilder = async (metadata, message, { Config }, payload) => {
'developer-token': getValueFromMessage(metadata, 'secret.developer_token'),
};
response.params = { event, customerId: filteredCustomerId };

if (subAccount) {
if (!loginCustomerId) {
throw new ConfigurationError(`loginCustomerId is required as subAccount is true.`);
Expand All @@ -84,7 +86,9 @@ const responseBuilder = async (metadata, message, { Config }, payload) => {
response.headers['login-customer-id'] = filteredLoginCustomerId;
}

if (loginCustomerId) {
// isDefined and non empty loginCustomerId
if (isDefined(configDetails.loginCustomerId) && configDetails.loginCustomerId) {
loginCustomerId = configDetails.loginCustomerId;
const filteredLoginCustomerId = removeHyphens(loginCustomerId);
response.headers['login-customer-id'] = filteredLoginCustomerId;
}
Expand Down
Loading

0 comments on commit db5669b

Please sign in to comment.