@dotdev/harmony-sdk 1.8.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/diary/diary.module.js +1 -1
- package/dist/modules/diary/diary.module.spec.d.ts +1 -0
- package/dist/modules/diary/diary.module.spec.js +121 -0
- package/dist/modules/diary/mappings/diary.mapper.js +16 -16
- package/dist/modules/diary/types/diary.interface.d.ts +32 -32
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ export class DiaryModule {
|
|
|
19
19
|
async createDiary(params, sessionId) {
|
|
20
20
|
try {
|
|
21
21
|
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `CreateDiary`, sessionId, ServiceAlias.DIARY, this.axiosInstance, mapCreateDiaryQueryParams(params));
|
|
22
|
-
return response?.result[0];
|
|
22
|
+
return Boolean(response?.result[0]);
|
|
23
23
|
}
|
|
24
24
|
catch (error) {
|
|
25
25
|
throw await ApiHelper.parseError(error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { ApiHelper, Utils } from "../../helpers";
|
|
3
|
+
import { ServiceAlias } from "../shared";
|
|
4
|
+
import { DiaryModule } from "./diary.module";
|
|
5
|
+
import { DiaryTitle } from "./types";
|
|
6
|
+
jest.mock("axios");
|
|
7
|
+
const mAxios = axios;
|
|
8
|
+
describe("DiaryModule", () => {
|
|
9
|
+
const sessionId = "test-sid"; // process.env.SESSION_ID as string;
|
|
10
|
+
let diaryModule;
|
|
11
|
+
let mockApiHelperSendRequest;
|
|
12
|
+
beforeAll(() => {
|
|
13
|
+
diaryModule = new DiaryModule(mAxios);
|
|
14
|
+
mockApiHelperSendRequest = jest.spyOn(ApiHelper, "sendSoapRequest");
|
|
15
|
+
});
|
|
16
|
+
test("createDiary should map customer details and send request correctly", async () => {
|
|
17
|
+
const token = "test-token";
|
|
18
|
+
const ns = "S";
|
|
19
|
+
const SERVICE = ServiceAlias.DIARY;
|
|
20
|
+
const expectedPayload = `
|
|
21
|
+
<${ns}:Envelope xmlns:${ns}="http://schemas.xmlsoap.org/soap/envelope/" xmlns:${SERVICE}="http://${SERVICE}.ws.fbsaust.com.au">
|
|
22
|
+
<${ns}:Header>
|
|
23
|
+
<${SERVICE}:SessionId>${token}</${SERVICE}:SessionId>
|
|
24
|
+
</${ns}:Header>
|
|
25
|
+
<${ns}:Body>
|
|
26
|
+
<${SERVICE}:CreateDiary >
|
|
27
|
+
<Diary>
|
|
28
|
+
<namekey>WS-7430</namekey>
|
|
29
|
+
<title>MR</title>
|
|
30
|
+
<surname>TIGGER</surname>
|
|
31
|
+
<first_name>TONY</first_name>
|
|
32
|
+
<is_active>Y</is_active>
|
|
33
|
+
<address_1>150</address_1>
|
|
34
|
+
<address_2>Hawthorn Road</address_2>
|
|
35
|
+
<address_3>Caulfield</address_3>
|
|
36
|
+
<address_4>Vic</address_4>
|
|
37
|
+
<postcode>3161</postcode>
|
|
38
|
+
<postal_address_id>1200</postal_address_id>
|
|
39
|
+
<delivery_address_1>75 - 79</delivery_address_1>
|
|
40
|
+
<delivery_address_2>Elizabeth Street</delivery_address_2>
|
|
41
|
+
<delivery_address_3>Wetherill Park</delivery_address_3>
|
|
42
|
+
<delivery_address_4>NSW</delivery_address_4>
|
|
43
|
+
<delivery_postcode>2164</delivery_postcode>
|
|
44
|
+
<delivery_address_id>2200</delivery_address_id>
|
|
45
|
+
<date_of_birth>01-01-2009</date_of_birth>
|
|
46
|
+
<email>softwhite@delight.com.au</email>
|
|
47
|
+
<telephone_1>95239762</telephone_1>
|
|
48
|
+
<telephone_2>56677778</telephone_2>
|
|
49
|
+
<telephone_3>77766677</telephone_3>
|
|
50
|
+
<fax>45454545</fax>
|
|
51
|
+
<membership_no>MB-WS-7430</membership_no>
|
|
52
|
+
<agent>9999</agent>
|
|
53
|
+
<class_1>STAFF</class_1>
|
|
54
|
+
<class_2>AUS</class_2>
|
|
55
|
+
<class_3>WEB</class_3>
|
|
56
|
+
<text_1>created today</text_1>
|
|
57
|
+
<text_2></text_2>
|
|
58
|
+
<first_contact_date>02-01-2001</first_contact_date>
|
|
59
|
+
<last_contact_date>03-01-2001</last_contact_date>
|
|
60
|
+
<next_contact_date>04-01-2001</next_contact_date>
|
|
61
|
+
</Diary>
|
|
62
|
+
</${SERVICE}:CreateDiary>
|
|
63
|
+
</${ns}:Body>
|
|
64
|
+
</${ns}:Envelope>
|
|
65
|
+
`;
|
|
66
|
+
const params = {
|
|
67
|
+
namekey: "WS-7430",
|
|
68
|
+
title: DiaryTitle.MR,
|
|
69
|
+
surname: "TIGGER",
|
|
70
|
+
firstName: "TONY",
|
|
71
|
+
isActive: "Y",
|
|
72
|
+
address1: "150",
|
|
73
|
+
address2: "Hawthorn Road",
|
|
74
|
+
address3: "Caulfield",
|
|
75
|
+
address4: "Vic",
|
|
76
|
+
postcode: "3161",
|
|
77
|
+
postalAddressId: 1200,
|
|
78
|
+
deliveryAddress1: "75 - 79",
|
|
79
|
+
deliveryAddress2: "Elizabeth Street",
|
|
80
|
+
deliveryAddress3: "Wetherill Park",
|
|
81
|
+
deliveryAddress4: "NSW",
|
|
82
|
+
deliveryPostcode: "2164",
|
|
83
|
+
deliveryAddressId: 2200,
|
|
84
|
+
dateOfBirth: "01-01-2009",
|
|
85
|
+
email: "softwhite@delight.com.au",
|
|
86
|
+
telephone1: "95239762",
|
|
87
|
+
telephone2: "56677778",
|
|
88
|
+
telephone3: "77766677",
|
|
89
|
+
fax: "45454545",
|
|
90
|
+
membershipNo: "MB-WS-7430",
|
|
91
|
+
agent: 9999,
|
|
92
|
+
class1: "STAFF",
|
|
93
|
+
class2: "AUS",
|
|
94
|
+
class3: "WEB",
|
|
95
|
+
text1: "created today",
|
|
96
|
+
text2: "",
|
|
97
|
+
firstContactDate: "02-01-2001",
|
|
98
|
+
lastContactDate: "03-01-2001",
|
|
99
|
+
nextContactDate: "04-01-2001",
|
|
100
|
+
};
|
|
101
|
+
const mockedResp = `
|
|
102
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
103
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
|
104
|
+
<S:Body><ns2:CreateDiaryResponse xmlns:ns2="http://${SERVICE}.ws.fbsaust.com.au">
|
|
105
|
+
<result>true</result>
|
|
106
|
+
</ns2:CreateDiaryResponse></S:Body>
|
|
107
|
+
</S:Envelope>
|
|
108
|
+
`;
|
|
109
|
+
const expectedResult = true;
|
|
110
|
+
mAxios.post.mockResolvedValueOnce({ data: mockedResp });
|
|
111
|
+
const response = await diaryModule.createDiary(params, token);
|
|
112
|
+
console.log(response);
|
|
113
|
+
// Test that expected response is correct
|
|
114
|
+
expect(typeof response).toEqual("boolean");
|
|
115
|
+
expect(response).toEqual(expectedResult);
|
|
116
|
+
const actualPayload = mAxios.post.mock.calls[0][1];
|
|
117
|
+
// Test that actual payload sent in the API matches expected payload
|
|
118
|
+
expect(Utils.removeEmptySpaces(actualPayload)).toEqual(Utils.removeEmptySpaces(expectedPayload));
|
|
119
|
+
mAxios.post.mockClear();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -75,27 +75,27 @@ export function mapCreateDiaryQueryParams(src) {
|
|
|
75
75
|
postcode: src?.postcode,
|
|
76
76
|
postal_address_id: src?.postalAddressId,
|
|
77
77
|
delivery_address_1: src?.deliveryAddress1,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
membershipno: src?.membershipNo,
|
|
78
|
+
delivery_address_2: src?.deliveryAddress2,
|
|
79
|
+
delivery_address_3: src?.deliveryAddress3,
|
|
80
|
+
delivery_address_4: src?.deliveryAddress4,
|
|
81
|
+
delivery_postcode: src?.deliveryPostcode,
|
|
82
|
+
delivery_address_id: src?.deliveryAddressId,
|
|
83
|
+
date_of_birth: src?.dateOfBirth,
|
|
85
84
|
email: src?.email,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
telephone_1: src?.telephone1,
|
|
86
|
+
telephone_2: src?.telephone2,
|
|
87
|
+
telephone_3: src?.telephone3,
|
|
89
88
|
fax: src?.fax,
|
|
89
|
+
membership_no: src?.membershipNo,
|
|
90
90
|
agent: src?.agent,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
class_1: src?.class1,
|
|
92
|
+
class_2: src?.class2,
|
|
93
|
+
class_3: src?.class3,
|
|
94
|
+
text_1: src?.text1,
|
|
95
|
+
text_2: src?.text2,
|
|
96
96
|
first_contact_date: src?.firstContactDate,
|
|
97
97
|
last_contact_date: src?.lastContactDate,
|
|
98
98
|
next_contact_date: src?.nextContactDate,
|
|
99
99
|
};
|
|
100
|
-
return `<Diary>${Utils.toXml(params)}</Diary>`;
|
|
100
|
+
return `<Diary>${Utils.toXml(Utils.deleteUndefinedProps(params))}</Diary>`;
|
|
101
101
|
}
|
|
@@ -89,38 +89,38 @@ export type CreateDiaryQueryParams = DiaryBase;
|
|
|
89
89
|
export type CreateDiaryResponse = BooleanResponse;
|
|
90
90
|
export interface DiaryBase {
|
|
91
91
|
namekey: string;
|
|
92
|
-
title
|
|
93
|
-
surname
|
|
94
|
-
firstName
|
|
95
|
-
isActive
|
|
96
|
-
address1
|
|
97
|
-
address2
|
|
98
|
-
address3
|
|
99
|
-
address4
|
|
100
|
-
postcode
|
|
101
|
-
postalAddressId
|
|
102
|
-
deliveryAddress1
|
|
103
|
-
deliveryAddress2
|
|
104
|
-
deliveryAddress3
|
|
105
|
-
deliveryAddress4
|
|
106
|
-
deliveryPostcode
|
|
107
|
-
deliveryAddressId
|
|
108
|
-
dateOfBirth
|
|
109
|
-
email
|
|
110
|
-
telephone1
|
|
111
|
-
telephone2
|
|
112
|
-
telephone3
|
|
113
|
-
fax
|
|
114
|
-
membershipNo
|
|
115
|
-
agent
|
|
116
|
-
class1
|
|
117
|
-
class2
|
|
118
|
-
class3
|
|
119
|
-
text1
|
|
120
|
-
text2
|
|
121
|
-
firstContactDate
|
|
122
|
-
lastContactDate
|
|
123
|
-
nextContactDate
|
|
92
|
+
title?: DiaryTitle;
|
|
93
|
+
surname?: string;
|
|
94
|
+
firstName?: string;
|
|
95
|
+
isActive?: string;
|
|
96
|
+
address1?: string;
|
|
97
|
+
address2?: string;
|
|
98
|
+
address3?: string;
|
|
99
|
+
address4?: string;
|
|
100
|
+
postcode?: string;
|
|
101
|
+
postalAddressId?: number;
|
|
102
|
+
deliveryAddress1?: string;
|
|
103
|
+
deliveryAddress2?: string;
|
|
104
|
+
deliveryAddress3?: string;
|
|
105
|
+
deliveryAddress4?: string;
|
|
106
|
+
deliveryPostcode?: string;
|
|
107
|
+
deliveryAddressId?: number;
|
|
108
|
+
dateOfBirth?: string;
|
|
109
|
+
email?: string;
|
|
110
|
+
telephone1?: string;
|
|
111
|
+
telephone2?: string;
|
|
112
|
+
telephone3?: string;
|
|
113
|
+
fax?: string;
|
|
114
|
+
membershipNo?: string;
|
|
115
|
+
agent?: number;
|
|
116
|
+
class1?: string;
|
|
117
|
+
class2?: string;
|
|
118
|
+
class3?: string;
|
|
119
|
+
text1?: string;
|
|
120
|
+
text2?: string;
|
|
121
|
+
firstContactDate?: string;
|
|
122
|
+
lastContactDate?: string;
|
|
123
|
+
nextContactDate?: string;
|
|
124
124
|
}
|
|
125
125
|
export declare enum DiaryTitle {
|
|
126
126
|
LADY = "LADY",
|