Guest User

Untitled

a guest
Aug 16th, 2021
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const csv = 'Email,FirstName,LastName,Birthdate,PhoneNumber,City,Country,Gender,Platform,Stars,SUBSCRIBEDATE\n'
  2. + '[email protected],Grégoire,Mathonet,16/05/1995,+352691623187,Luxembourg,LU,M,Y,5,01/07/2021';
  3.             Promise.all([
  4.                 this.hubspotClient.crm.imports.coreApi.create(JSON.stringify({
  5.                     name: 'anote_platform',
  6.                     files: [{
  7.                         fileName: 'platform.csv',
  8.                         fileFormat: 'CSV',
  9.                         dateFormat: 'DAY_MONTH_YEAR',
  10.                         fileImportPage: {
  11.                             hasHeader: true,
  12.                             columnMappings: [{
  13.                                 columnName: 'Email',
  14.                                 propertyName: 'email',
  15.                                 columnObjectType: 'CONTACT',
  16.                             }, {
  17.                                 columnName: 'Platform',
  18.                                 propertyName: 'hs_content_membership_email_confirmed',
  19.                                 columnObjectType: 'CONTACT',
  20.                             }, {
  21.                                 columnName: 'FirstName',
  22.                                 propertyName: 'firstname',
  23.                                 columnObjectType: 'CONTACT',
  24.                             }]
  25.                         }
  26.                     }]
  27.                 }), {
  28.                     value: Buffer.from(csv),
  29.                     options: {
  30.                         filename: 'platform.csv',
  31.                         contentType: 'text/csv',
  32.                     },
  33.                 })
  34.             ]).then(() => callback, e => {
  35.                 if(e.body) callback(JSON.stringify(e.body));
  36.                 else if(e.response) callback(JSON.stringify(e.response));
  37.                 else callback(e);
  38.             });
Advertisement
Add Comment
Please, Sign In to add comment