1- import { EmailApi } from '../src/api'
1+ import { EmailApi } from '../src/api'
22import * as requests from '../src/model/requests/requests' ;
33import uuidv4 from 'uuid/v4' ;
44import * as models from '../src/model/model' ;
55import fs from 'fs' ;
66import 'mocha' ;
7- import { expect } from 'chai' ;
7+ import { expect } from 'chai' ;
88
9- describe ( 'EmailApi' , function ( ) {
9+ describe ( 'EmailApi' , function ( ) {
1010 let api : EmailApi ;
1111 let folder : string ;
1212 const storage = 'First Storage' ;
1313 this . timeout ( 100000 )
1414
15- before ( async function ( ) {
15+ before ( async function ( ) {
1616 api = new EmailApi ( process . env . appSid , process . env . appKey , process . env . apiBaseUrl ) ;
1717 const authUrl = process . env . authUrl ;
1818 if ( authUrl != null ) api . configuration . authUrl = authUrl ;
1919 folder = uuidv4 ( ) ;
2020 await api . createFolder ( new requests . CreateFolderRequest ( folder , storage ) ) ;
2121 } )
2222
23- after ( async function ( ) {
23+ after ( async function ( ) {
2424 await api . deleteFolder ( new requests . DeleteFolderRequest ( folder , storage , true ) ) ;
2525 } )
2626
@@ -29,7 +29,7 @@ describe('EmailApi', function() {
2929 * This test checks that BaseObject.Type field filled automatically by SDK
3030 * and properly used in serialization and deserialization
3131 */
32- it ( 'HierarchicalObject #pipeline' , async function ( ) {
32+ it ( 'HierarchicalObject #pipeline' , async function ( ) {
3333 const calendarFile = await createCalendar ( ) ;
3434 const calendar = await api . getCalendar ( new requests . GetCalendarRequest ( calendarFile , folder , storage ) ) ;
3535 expect ( calendar . body . name ) . to . be . equal ( 'CALENDAR' ) ;
@@ -42,7 +42,7 @@ describe('EmailApi', function() {
4242 /**
4343 * Buffer support test
4444 */
45- it ( 'FileTest #pipeline' , async function ( ) {
45+ it ( 'FileTest #pipeline' , async function ( ) {
4646 let calendarFile = await createCalendar ( ) ;
4747 let path = folder + '/' + calendarFile ;
4848 const downloaded = await api . downloadFile ( new requests . DownloadFileRequest ( path , storage ) ) ;
@@ -63,8 +63,8 @@ describe('EmailApi', function() {
6363 * Contact format specified as Enum, but SDK represents it as an advanced type of string constants a string.
6464 * Test checks that value parsing works properly
6565 */
66- it ( 'Contact format #pipeline' , async function ( ) {
67- for ( const format of [ 'VCard' , 'Msg' ] ) {
66+ it ( 'Contact format #pipeline' , async function ( ) {
67+ for ( const format of [ 'VCard' , 'Msg' ] ) {
6868 const extension = ( format == 'Msg' ) ? '.msg' : '.vcf' ;
6969 const fileName = uuidv4 ( ) + extension ;
7070 await api . createContact ( new requests . CreateContactRequest (
@@ -84,7 +84,7 @@ describe('EmailApi', function() {
8484 * Checks that SDK and Backend do not change Date during processing.
8585 * In most cases developer should carefully serialize and deserialize Date
8686 */
87- it ( 'Date #pipeline' , async function ( ) {
87+ it ( 'Date #pipeline' , async function ( ) {
8888 const startDate = getDate ( undefined , 24 ) ;
8989 startDate . setMilliseconds ( 0 ) ;
9090 const calendarFile = await createCalendar ( startDate ) ;
@@ -94,27 +94,27 @@ describe('EmailApi', function() {
9494 expect ( factStartDate . getTime ( ) ) . to . equal ( startDate . getTime ( ) ) ;
9595 } ) ;
9696
97- it ( 'Name gender detection #pipeline' , async function ( ) {
97+ it ( 'Name gender detection #pipeline' , async function ( ) {
9898 const result = await api . aiNameGenderize ( new requests . AiNameGenderizeRequest ( 'John Cane' ) ) ;
9999 expect ( result . body . value . length ) . to . be . at . least ( 1 ) ;
100100 expect ( result . body . value [ 0 ] . gender ) . to . be . equal ( 'Male' ) ;
101101 } ) ;
102102
103- it ( 'Name formatting #pipeline' , async function ( ) {
103+ it ( 'Name formatting #pipeline' , async function ( ) {
104104 const result = await api . aiNameFormat ( new requests . AiNameFormatRequest (
105105 'Mr. John Michael Cane' , undefined , undefined , undefined , undefined , '%t%L%f%m' ) ) ;
106106 expect ( result . body . name ) . to . be . equal ( 'Mr. Cane J. M.' ) ;
107107 } ) ;
108108
109- it ( 'Name match #pipeline' , async function ( ) {
109+ it ( 'Name match #pipeline' , async function ( ) {
110110 const first = 'John Michael Cane' ;
111111 const second = 'Cane J.' ;
112112 const result = await api . aiNameMatch ( new requests . AiNameMatchRequest (
113113 first , second ) ) ;
114114 expect ( result . body . similarity ) . to . be . at . least ( 0.5 ) ;
115115 } ) ;
116116
117- it ( 'Name expand #pipeline' , async function ( ) {
117+ it ( 'Name expand #pipeline' , async function ( ) {
118118 const result = await api . aiNameExpand ( new requests . AiNameExpandRequest (
119119 'Smith Bobby' ) ) ;
120120 const names = result . body . names
@@ -123,7 +123,7 @@ describe('EmailApi', function() {
123123 expect ( names ) . to . contain ( 'B. Smith' ) ;
124124 } ) ;
125125
126- it ( 'Name complete #pipeline' , async function ( ) {
126+ it ( 'Name complete #pipeline' , async function ( ) {
127127 const prefix = 'Dav' ;
128128 const result = await api . aiNameComplete ( new requests . AiNameCompleteRequest (
129129 prefix ) ) ;
@@ -134,7 +134,7 @@ describe('EmailApi', function() {
134134 expect ( names ) . to . contain ( 'Dave' ) ;
135135 } ) ;
136136
137- it ( 'Parse name from email address #pipeline' , async function ( ) {
137+ it ( 'Parse name from email address #pipeline' , async function ( ) {
138138 const result = await api . aiNameParseEmailAddress ( new requests . AiNameParseEmailAddressRequest (
139139 'john-cane@gmail.com' ) ) ;
140140 const extractedValues = result . body . value
@@ -146,7 +146,7 @@ describe('EmailApi', function() {
146146 expect ( surname . value ) . to . be . equal ( 'Cane' ) ;
147147 } ) ;
148148
149- it ( 'Parse business card images to VCard contact files #pipeline' , async function ( ) {
149+ it ( 'Parse business card images to VCard contact files #pipeline' , async function ( ) {
150150 const imageData = fs . readFileSync ( 'test/data/test_single_0001.png' ) ;
151151 const storageFileName = uuidv4 ( ) + '.png' ;
152152 // 1) Upload business card image to storage
@@ -176,7 +176,7 @@ describe('EmailApi', function() {
176176 expect ( contactProperties . body . internalProperties . length ) . to . be . at . least ( 3 ) ;
177177 } ) ;
178178
179- it ( 'Business card recognition without storage #pipeline' , async function ( ) {
179+ it ( 'Business card recognition without storage #pipeline' , async function ( ) {
180180 const imageData = fs . readFileSync ( 'test/data/test_single_0001.png' ) . toString ( 'base64' ) ;
181181 const result = await api . aiBcrParse ( new requests . AiBcrParseRequest (
182182 new models . AiBcrBase64Rq ( undefined , [ new models . AiBcrBase64Image ( true , imageData ) ] ) ) ) ;
@@ -186,7 +186,7 @@ describe('EmailApi', function() {
186186 expect ( displayName . value ) . to . contain ( "Thomas" ) ;
187187 } ) ;
188188
189- it ( 'Create calendar email #pipeline' , async function ( ) {
189+ it ( 'Create calendar email #pipeline' , async function ( ) {
190190 const calendar = new models . CalendarDto ( ) ;
191191 calendar . attendees = [
192192 new models . MailAddress ( 'Attendee Name' , 'attendee@am.ru' , 'Accepted' )
@@ -233,7 +233,7 @@ describe('EmailApi', function() {
233233 expect ( downloadedRaw ) . to . contain ( 'cloud.em@yandex.ru' ) ;
234234 } ) ;
235235
236- it ( 'Save contact model #pipeline' , async function ( ) {
236+ it ( 'Save contact model #pipeline' , async function ( ) {
237237 const contact = new models . ContactDto ( ) ;
238238 contact . gender = 'Male' ;
239239 contact . surname = 'Thomas' ;
@@ -256,15 +256,15 @@ describe('EmailApi', function() {
256256 expect ( exists . body . exists ) . to . be . ok ;
257257 } ) ;
258258
259- it ( 'Parse contact model from image #pipeline' , async function ( ) {
259+ it ( 'Parse contact model from image #pipeline' , async function ( ) {
260260 const imageData = fs . readFileSync ( 'test/data/test_single_0001.png' ) . toString ( 'base64' ) ;
261261 const result = await api . aiBcrParseModel ( new requests . AiBcrParseModelRequest (
262262 new models . AiBcrBase64Rq ( undefined , [ new models . AiBcrBase64Image ( true , imageData ) ] ) ) ) ;
263263 expect ( result . body . value . length ) . to . be . equal ( 1 ) ;
264264 expect ( result . body . value [ 0 ] . displayName ) . to . contain ( "Thomas" ) ;
265265 } ) ;
266266
267- it ( 'Create MAPI file #pipeline' , async function ( ) {
267+ it ( 'Create MAPI file #pipeline' , async function ( ) {
268268 const fileName = uuidv4 ( ) + '.msg' ;
269269 await api . createMapi ( new requests . CreateMapiRequest (
270270 fileName , new models . HierarchicalObjectRequest (
@@ -288,7 +288,7 @@ describe('EmailApi', function() {
288288 expect ( exist . body . exists ) . to . be . ok ;
289289 } ) ;
290290
291- it ( 'Add attachment to MAPI #pipeline' , async function ( ) {
291+ it ( 'Add attachment to MAPI #pipeline' , async function ( ) {
292292 const fileName = await createCalendar ( ) ;
293293 const attachmentName = await createCalendar ( ) ;
294294 await api . addMapiAttachment ( new requests . AddMapiAttachmentRequest (
@@ -308,15 +308,15 @@ describe('EmailApi', function() {
308308 expect ( properties . body . hierarchicalObject . name ) . to . contain ( "IPM.Schedule" ) ;
309309 } ) ;
310310
311- it ( 'Discover email config #pipeline' , async function ( ) {
311+ it ( 'Discover email config #pipeline' , async function ( ) {
312312 const configs = await api . discoverEmailConfig ( new requests . DiscoverEmailConfigRequest (
313313 'example@gmail.com' , true ) ) ;
314314 expect ( configs . body . value . length ) . to . be . at . least ( 2 ) ;
315315 const smtp = configs . body . value . filter ( item => item . protocolType == 'SMTP' ) [ 0 ] ;
316316 expect ( smtp . host ) . to . be . equal ( 'smtp.gmail.com' ) ;
317317 } ) ;
318318
319- it ( 'Check disposable email #pipeline' , async function ( ) {
319+ it ( 'Check disposable email #pipeline' , async function ( ) {
320320 const disposable = await api . isEmailAddressDisposable (
321321 new requests . IsEmailAddressDisposableRequest ( 'example@mailcatch.com' ) ) ;
322322 expect ( disposable . body . value ) . to . be . ok ;
@@ -325,16 +325,13 @@ describe('EmailApi', function() {
325325 expect ( regular . body . value ) . to . not . be . ok ;
326326 } ) ;
327327
328- it ( 'Check EmailClientAccount #pipeline' , async function ( ) {
328+ it ( 'Check EmailClientAccount #pipeline' , async function ( ) {
329329 const accountCredentials =
330330 new models . EmailClientAccountPasswordCredentials (
331- 'login' , undefined , 'password' ) ;
332- const account = new models . EmailClientAccount (
333- 'smtp.gmail.com' ,
334- 551 ,
335- 'SSLAuto' ,
336- 'SMTP' ,
337- accountCredentials ) ;
331+ 'example@gmail.com' , undefined , 'password' ) ;
332+ const account = new models . EmailClientAccount ( 'pop.gmail.com' , 995 , 'SSLAuto' , 'POP3' ,
333+ accountCredentials ,
334+ new models . StorageFileLocation ( storage , folder , 'account.cache' ) ) ;
338335 const fileName = uuidv4 ( ) + '.account' ;
339336 await api . saveEmailClientAccount ( new requests . SaveEmailClientAccountRequest (
340337 new models . StorageFileRqOfEmailClientAccount (
@@ -347,7 +344,7 @@ describe('EmailApi', function() {
347344 expect ( result . body . host ) . to . be . equal ( account . host ) ;
348345 } ) ;
349346
350- it ( 'Check EmailClientMultiAccount #pipeline' , async function ( ) {
347+ it ( 'Check EmailClientMultiAccount #pipeline' , async function ( ) {
351348 // Create multi account object
352349 const multiAccount = new models . EmailClientMultiAccount (
353350 [ new models . EmailClientAccount ( 'imap.gmail.com' , 993 , 'SSLAuto' , 'IMAP' ,
@@ -375,7 +372,7 @@ describe('EmailApi', function() {
375372 . to . be . equal ( multiAccount . sendAccount . credentials . discriminator ) ;
376373 } ) ;
377374
378- async function createCalendar ( startDate ? : Date ) : Promise < string > {
375+ async function createCalendar ( startDate ?: Date ) : Promise < string > {
379376 const fileName = uuidv4 ( ) + '.ics' ;
380377 startDate = ( startDate == null ) ? getDate ( undefined , 1 ) : startDate ;
381378 const endDate = getDate ( startDate , 1 ) ;
@@ -389,9 +386,9 @@ describe('EmailApi', function() {
389386 new models . PrimitiveObject ( "STARTDATE" , undefined , startDate . toUTCString ( ) ) ,
390387 new models . PrimitiveObject ( "ENDDATE" , undefined , endDate . toUTCString ( ) ) ,
391388 new models . HierarchicalObject ( "ORGANIZER" , undefined , [
392- new models . PrimitiveObject ( "ADDRESS" , undefined , "organizer@am.ru" ) ,
393- new models . PrimitiveObject ( "DISPLAYNAME" , undefined , "Organizer Name" )
394- ] ) ,
389+ new models . PrimitiveObject ( "ADDRESS" , undefined , "organizer@am.ru" ) ,
390+ new models . PrimitiveObject ( "DISPLAYNAME" , undefined , "Organizer Name" )
391+ ] ) ,
395392 new models . HierarchicalObject ( "ATTENDEES" , undefined , [
396393 new models . IndexedHierarchicalObject ( "ATTENDEE" , undefined , 0 , [
397394 new models . PrimitiveObject ( "ADDRESS" , undefined , "attendee@am.ru" ) ,
@@ -405,12 +402,12 @@ describe('EmailApi', function() {
405402 return fileName ;
406403 }
407404
408- function getDate ( baseDate ?: Date , addHours ?:number ) : Date {
405+ function getDate ( baseDate ?: Date , addHours ?: number ) : Date {
409406 baseDate = ( baseDate == null ) ? new Date ( ) : baseDate ;
410407 addHours = ( addHours == null ) ? 0 : addHours ;
411408 const hour = 60 * 60 * 1000 ;
412409 const result = new Date ( ) ;
413410 result . setTime ( baseDate . getTime ( ) + addHours * hour ) ;
414411 return result ;
415412 }
416- } ) ;
413+ } ) ;
0 commit comments