Skip to content

Commit

Permalink
refactor: rename SF_ -> SALESFORCE_
Browse files Browse the repository at this point in the history
  • Loading branch information
Nat Dean-Lewis committed Nov 27, 2024
1 parent 10c1e89 commit 8787e3d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 46 deletions.
16 changes: 8 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ services:
DUN_AND_BRADSTREET_KEY:
DUN_AND_BRADSTREET_MAX_REDIRECTS:
DUN_AND_BRADSTREET_TIMEOUT:
SF_CLIENT_ID:
SF_CLIENT_SECRET:
SF_USERNAME:
SF_PASSWORD:
SF_INSTANCE_URL:
SF_ACCESS_URL:
SF_MAX_REDIRECTS:
SF_TIMEOUT:
SALESFORCE_CLIENT_ID:
SALESFORCE_CLIENT_SECRET:
SALESFORCE_USERNAME:
SALESFORCE_PASSWORD:
SALESFORCE_INSTANCE_URL:
SALESFORCE_ACCESS_URL:
SALESFORCE_MAX_REDIRECTS:
SALESFORCE_TIMEOUT:
API_KEY:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${PORT}"]
Expand Down
34 changes: 17 additions & 17 deletions src/config/salesforce.config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ describe('salesforceConfig', () => {
const configDirectlyFromEnvironmentVariables: { configPropertyName: keyof SalesforceConfig; environmentVariableName: string }[] = [
{
configPropertyName: 'baseUrl',
environmentVariableName: 'SF_INSTANCE_URL',
environmentVariableName: 'SALESFORCE_INSTANCE_URL',
},
{
configPropertyName: 'clientId',
environmentVariableName: 'SF_CLIENT_ID',
environmentVariableName: 'SALESFORCE_CLIENT_ID',
},

{
configPropertyName: 'clientSecret',
environmentVariableName: 'SF_CLIENT_SECRET',
environmentVariableName: 'SALESFORCE_CLIENT_SECRET',
},
{
configPropertyName: 'username',
environmentVariableName: 'SF_USERNAME',
environmentVariableName: 'SALESFORCE_USERNAME',
},
{
configPropertyName: 'password',
environmentVariableName: 'SF_PASSWORD',
environmentVariableName: 'SALESFORCE_PASSWORD',
},
{
configPropertyName: 'accessUrl',
environmentVariableName: 'SF_ACCESS_URL',
environmentVariableName: 'SALESFORCE_ACCESS_URL',
},
];

Expand All @@ -36,17 +36,17 @@ describe('salesforceConfig', () => {
environmentVariableName: string;
defaultConfigValue: number;
}[] = [
{
configPropertyName: 'maxRedirects',
environmentVariableName: 'SF_MAX_REDIRECTS',
defaultConfigValue: 5,
},
{
configPropertyName: 'timeout',
environmentVariableName: 'SF_TIMEOUT',
defaultConfigValue: 30000, // in milliseconds
},
];
{
configPropertyName: 'maxRedirects',
environmentVariableName: 'SALESFORCE_MAX_REDIRECTS',
defaultConfigValue: 5,
},
{
configPropertyName: 'timeout',
environmentVariableName: 'SALESFORCE_TIMEOUT',
defaultConfigValue: 30000, // in milliseconds
},
];

withEnvironmentVariableParsingUnitTests({
configDirectlyFromEnvironmentVariables,
Expand Down
16 changes: 8 additions & 8 deletions src/config/salesforce.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export interface SalesforceConfig {
export default registerAs(
KEY,
(): SalesforceConfig => ({
baseUrl: process.env.SF_INSTANCE_URL,
clientId: process.env.SF_CLIENT_ID,
clientSecret: process.env.SF_CLIENT_SECRET,
username: process.env.SF_USERNAME,
password: process.env.SF_PASSWORD,
accessUrl: process.env.SF_ACCESS_URL,
maxRedirects: getIntConfig(process.env.SF_MAX_REDIRECTS, 5),
timeout: getIntConfig(process.env.SF_TIMEOUT, 30000), // in milliseconds
baseUrl: process.env.SALESFORCE_INSTANCE_URL,
clientId: process.env.SALESFORCE_CLIENT_ID,
clientSecret: process.env.SALESFORCE_CLIENT_SECRET,
username: process.env.SALESFORCE_USERNAME,
password: process.env.SALESFORCE_PASSWORD,
accessUrl: process.env.SALESFORCE_ACCESS_URL,
maxRedirects: getIntConfig(process.env.SALESFORCE_MAX_REDIRECTS, 5),
timeout: getIntConfig(process.env.SALESFORCE_TIMEOUT, 30000), // in milliseconds
}),
);
2 changes: 1 addition & 1 deletion src/modules/customers/customers.controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('CustomersController', () => {
const expectedResponse: GetCustomersSalesforceResponse = [{
partyUrn: CUSTOMERS.EXAMPLES.PARTYURN,
name: CUSTOMERS.EXAMPLES.NAME,
sfId: 'TEST_SF_ID',
sfId: 'TEST_SALESFORCE_ID',
companyRegNo: CUSTOMERS.EXAMPLES.COMPANYREG,
}];

Expand Down
22 changes: 11 additions & 11 deletions src/modules/customers/customers.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ describe('CustomerService', () => {
const salesforceService = new SalesforceService(null, salesforceConfigService);
salesforceService.getCustomers = salesforceServiceGetCustomers;
salesforceService.createCustomer = salesforceServiceCreateCustomer;

numbersServiceCreate = jest.fn();
const numbersService = new NumbersService(null, null)
numbersService.create = numbersServiceCreate;

const dunAndBradstreetConfigService = new ConfigService();
dunAndBradstreetConfigServiceGet = jest.fn().mockReturnValue({ key: 'TEST_KEY' });
dunAndBradstreetConfigService.get = dunAndBradstreetConfigServiceGet;
Expand Down Expand Up @@ -82,14 +82,14 @@ describe('CustomerService', () => {
const expectedSalesforceResponse: GetCustomersSalesforceResponseItems = [{
Party_URN__c: CUSTOMERS.EXAMPLES.PARTYURN,
Name: CUSTOMERS.EXAMPLES.NAME,
Id: 'TEST_SF_ID',
Id: 'TEST_SALESFORCE_ID',
Company_Registration_Number__c: CUSTOMERS.EXAMPLES.COMPANYREG,
}];

const expectedResponse: GetCustomersSalesforceResponse = [{
partyUrn: CUSTOMERS.EXAMPLES.PARTYURN,
name: CUSTOMERS.EXAMPLES.NAME,
sfId: 'TEST_SF_ID',
sfId: 'TEST_SALESFORCE_ID',
companyRegNo: CUSTOMERS.EXAMPLES.COMPANYREG,
}];

Expand All @@ -109,16 +109,16 @@ describe('CustomerService', () => {
});

describe('createCustomer', () => {
const DTFSCustomerDto: DTFSCustomerDto = { companyRegistrationNumber: '12345678', companyName: 'TEST NAME'};
const salesforceCreateCustomerResponse: CreateCustomerSalesforceResponseDto = {
id: 'customer-id',
const DTFSCustomerDto: DTFSCustomerDto = { companyRegistrationNumber: '12345678', companyName: 'TEST NAME' };
const salesforceCreateCustomerResponse: CreateCustomerSalesforceResponseDto = {
id: 'customer-id',
errors: null,
success: true
success: true
};
const createUkefIdResponse: UkefId[] = [{"maskedId": "TEST PARTY_URN", "type": null, "createdBy": null, "createdDatetime": null, "requestingSystem": null}];
const createUkefIdResponse: UkefId[] = [{ "maskedId": "TEST PARTY_URN", "type": null, "createdBy": null, "createdDatetime": null, "requestingSystem": null }];
const dunAndBradstreetGetDunsNumberResponse: string = "TEST DUNS_NUMBER";
const createCustomerResponse: GetCustomersSalesforceResponse = [{"companyRegNo": "12345678", "name": "TEST NAME", "partyUrn": "TEST PARTY_URN", "sfId": "customer-id"}];
const createCustomerResponseWithNoPartyUrn: GetCustomersSalesforceResponse = [{"companyRegNo": "12345678", "name": "TEST NAME", "partyUrn": null, "sfId": "customer-id"}];
const createCustomerResponse: GetCustomersSalesforceResponse = [{ "companyRegNo": "12345678", "name": "TEST NAME", "partyUrn": "TEST PARTY_URN", "sfId": "customer-id" }];
const createCustomerResponseWithNoPartyUrn: GetCustomersSalesforceResponse = [{ "companyRegNo": "12345678", "name": "TEST NAME", "partyUrn": null, "sfId": "customer-id" }];

it('creates a customer successfully and returns the response', async () => {
when(salesforceServiceCreateCustomer).calledWith(expect.any(Object)).mockResolvedValueOnce(salesforceCreateCustomerResponse);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/customers/customers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class CustomersService {
let dunsNumber: string = null
try {
dunsNumber = await this.dunAndBradstreetService.getDunAndBradstreetNumberByRegistrationNumber(DTFSCustomerDto.companyRegistrationNumber)
} catch(error) { }
} catch (error) { }

const createCustomerDto: CreateCustomerDto = {
"Name": DTFSCustomerDto.companyName,
Expand Down

0 comments on commit 8787e3d

Please sign in to comment.