Skip to content

Commit 17bb22a

Browse files
Apply suggestions from code review
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent aea9a7e commit 17bb22a

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

packages/api/src/crm/contact/services/leadsquared/mappers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class LeadSquaredContactMapper implements IContactMapper {
4141
if (primaryPhone && source.phone_numbers?.[0]?.phone_type == 'MOBILE') {
4242
result.Mobile = primaryPhone;
4343
}
44-
if (source.addresses && source.addresses[0]) {
44+
if (source.addresses?.[0]) {
4545
result.Account_Street1 = source.addresses[0].street_1;
4646
result.Account_City = source.addresses[0].city;
4747
result.Account_State = source.addresses[0].state;
@@ -109,7 +109,7 @@ export class LeadSquaredContactMapper implements IContactMapper {
109109
}
110110
// Constructing email and phone details
111111
const email_addresses =
112-
contact && contact.EmailAddress
112+
contact?.EmailAddress
113113
? [
114114
{
115115
email_address: contact.EmailAddress,
@@ -132,13 +132,13 @@ export class LeadSquaredContactMapper implements IContactMapper {
132132
phone_type: 'MOBILE',
133133
});
134134
}
135-
if (contact && contact.Account_Fax) {
135+
if (contact?.Account_Fax) {
136136
phone_numbers.push({
137137
phone_number: contact.Account_Fax,
138138
phone_type: 'fax',
139139
});
140140
}
141-
if (contact && contact.Phone) {
141+
if (contact?.Phone) {
142142
phone_numbers.push({
143143
phone_number: contact.Phone,
144144
phone_type: 'home',

packages/api/src/crm/contact/services/leadsquared/types.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ type LeadSquaredContact = {
8787
[key: string]: string | number | boolean | null;
8888
};
8989

90+
type LeadProperty = {
91+
Attribute: string;
92+
Value: string;
93+
};
94+
9095
export type LeadSquaredContactResponse = {
91-
LeadPropertyList: [
92-
{
93-
Attribute: string;
94-
Value: string;
95-
},
96-
];
96+
LeadPropertyList: LeadProperty[];
9797
};
9898

9999
export type LeadSquaredContactInput = Partial<LeadSquaredContact>;

packages/api/src/crm/engagement/services/leadsquared/mappers.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ export class LeadSquaredEngagementMapper implements IEngagementMapper {
197197
Direction: source.direction === 'INBOUND' ? 'Inbound' : 'Outbound',
198198
CallerSource: source.content || '',
199199
LeadId: source.company_id || '',
200-
SourceNumber: '+91-8611795988', // todo,
201-
DisplayNumber: '+91-8611795989', // todo
202-
DestinationNumber: '+91-9611795983', // todo,
200+
SourceNumber: source.source_number || '',
201+
DisplayNumber: source.display_number || '',
202+
DestinationNumber: source.destination_number || '',
203203
};
204204

205205
if (source.start_at && source.end_time) {

packages/api/src/crm/engagement/services/leadsquared/types.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
interface KeyValuePair {
2-
[key: string]: unknown;
3-
}
1+
type KeyValuePair = Record<string, unknown>;
42

53
export type LeadSquaredEngagementCall = {
64
SourceNumber: string; //'+91-8611795988';

packages/api/src/crm/task/services/leadsquared/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class LeadSquaredService implements ITaskService {
7171
CrmObject.task,
7272
ActionType.POST,
7373
);
74+
return {
75+
data: null,
76+
message: 'Failed to create Leadsquared task',
77+
statusCode: 500,
78+
};
7479
}
7580
}
7681

@@ -123,6 +128,11 @@ export class LeadSquaredService implements ITaskService {
123128
CrmObject.task,
124129
ActionType.POST,
125130
);
131+
return {
132+
data: [],
133+
message: 'Failed to retrieve Leadsquared tasks',
134+
statusCode: 500,
135+
};
126136
}
127137
}
128138
}

packages/api/src/crm/task/services/leadsquared/types.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
interface KeyValuePair {
2-
[key: string]: unknown;
3-
}
1+
type KeyValuePair = Record<string, unknown>;
42

53
interface LeadSquaredTask {
64
UserTaskId: string;

0 commit comments

Comments
 (0)