Skip to content

Commit

Permalink
feat: do away myaxios
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Mar 31, 2024
1 parent 81290e8 commit 349e83d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/v0/destinations/sfmc/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const {
isDefinedAndNotNull,
isEmpty,
} = require('@rudderstack/integrations-lib');
const myAxios = require('../../../util/myAxios');
const { EventType } = require('../../../constants');
const { CONFIG_CATEGORIES, MAPPING_CONFIG, ENDPOINTS } = require('./config');
const {
Expand All @@ -28,14 +27,16 @@ const {
} = require('../../../adapters/utils/networkUtils');
const tags = require('../../util/tags');
const { JSON_MIME_TYPE } = require('../../util/constant');
const { handleHttpRequest } = require('../../../adapters/network');

const CONTACT_KEY_KEY = 'Contact Key';

// DOC: https://developer.salesforce.com/docs/atlas.en-us.mc-app-development.meta/mc-app-development/access-token-s2s.htm

const getToken = async (clientId, clientSecret, subdomain) => {
try {
const resp = await myAxios.post(
const { processedResponse: processedResponseSfmc } = await handleHttpRequest(
'post',
`https://${subdomain}.${ENDPOINTS.GET_TOKEN}`,
{
grant_type: 'client_credentials',
Expand All @@ -53,17 +54,16 @@ const getToken = async (clientId, clientSecret, subdomain) => {
module: 'router',
},
);
if (resp && resp.data) {
return resp.data.access_token;
if (processedResponseSfmc.response) {
return processedResponseSfmc.response.access_token;
}
const status = resp.status || 400;
throw new NetworkError(
'Could not retrieve access token',
status,
processedResponseSfmc.status || 400,

Check warning on line 62 in src/v0/destinations/sfmc/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/sfmc/transform.js#L62

Added line #L62 was not covered by tests
{
[tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(status),
[tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(processedResponseSfmc.status || 400),

Check warning on line 64 in src/v0/destinations/sfmc/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/sfmc/transform.js#L64

Added line #L64 was not covered by tests
},
resp,
JSON.stringify(processedResponseSfmc),
);
} catch (error) {
if (!isEmpty(error.response)) {
Expand Down

0 comments on commit 349e83d

Please sign in to comment.