@@ -31,11 +31,11 @@ export class LeadSquaredService implements IContactService {
31
31
32
32
formatDateForLeadSquared ( date : Date ) : string {
33
33
const year = date . getUTCFullYear ( ) ;
34
- const month = date . getUTCMonth ( ) + 1 ;
35
- const currentDate = date . getUTCDate ( ) ;
36
- const hours = date . getUTCHours ( ) ;
37
- const minutes = date . getUTCMinutes ( ) ;
38
- const seconds = date . getUTCSeconds ( ) ;
34
+ const month = ( date . getUTCMonth ( ) + 1 ) . toString ( ) . padStart ( 2 , '0' ) ;
35
+ const currentDate = date . getUTCDate ( ) . toString ( ) . padStart ( 2 , '0' ) ;
36
+ const hours = date . getUTCHours ( ) . toString ( ) . padStart ( 2 , '0' ) ;
37
+ const minutes = date . getUTCMinutes ( ) . toString ( ) . padStart ( 2 , '0' ) ;
38
+ const seconds = date . getUTCSeconds ( ) . toString ( ) . padStart ( 2 , '0' ) ;
39
39
return `${ year } -${ month } -${ currentDate } ${ hours } :${ minutes } :${ seconds } ` ;
40
40
}
41
41
@@ -121,17 +121,15 @@ export class LeadSquaredService implements IContactService {
121
121
headers,
122
122
} ,
123
123
) ;
124
+
124
125
const leads = resp ?. data [ 'Leads' ] . map (
125
- ( lead : LeadSquaredContactResponse ) => {
126
- const leadSquaredContact : LeadSquaredContactOutput = { } ;
127
- lead . LeadPropertyList . map (
128
- ( { Attribute, Value } : { Attribute : string ; Value : string } ) => {
129
- leadSquaredContact [ Attribute ] = Value ;
130
- } ,
131
- ) ;
132
- return leadSquaredContact ;
133
- } ,
134
- ) ;
126
+ ( lead : LeadSquaredContactResponse ) =>
127
+ lead . LeadPropertyList . reduce ( ( acc , { Attribute, Value } : { Attribute : string ; Value : string } ) => {
128
+ acc [ Attribute ] = Value ;
129
+ return acc ;
130
+ } , { } as LeadSquaredContactOutput )
131
+ ) ;
132
+
135
133
//this.logger.log('CONTACTS LEADSQUARED ' + JSON.stringify(resp.data.data));
136
134
this . logger . log ( `Synced leadsquared contacts !` ) ;
137
135
return {
0 commit comments