1- import { EmailApi } from "../src/api" ;
1+ import { EmailCloud } from "../src/api" ;
22import uuidv4 from "uuid/v4" ;
3- import * as requests from "../src/model/requests/requests" ;
43import 'mocha' ;
5- import * as models from "../src/model/model" ;
64import { Suite } from "mocha" ;
5+ import { CreateFolderRequest , DeleteFolderRequest , StorageFolderLocation } from "../src/model" ;
76
87class SuiteBase {
9- public api : ( ) => EmailApi ;
8+ public api : ( ) => EmailCloud ;
109 public folder : ( ) => string ;
1110 public storage : ( ) => string ;
12- constructor ( getApi : ( ) => EmailApi , getFolder : ( ) => string , getStorage : ( ) => string ) {
11+ constructor ( getApi : ( ) => EmailCloud , getFolder : ( ) => string , getStorage : ( ) => string ) {
1312 this . api = getApi ;
1413 this . folder = getFolder ;
1514 this . storage = getStorage ;
@@ -24,55 +23,25 @@ class SuiteBase {
2423 return result ;
2524 }
2625
27- public async createCalendar ( startDate ?: Date ) : Promise < string > {
28- const fileName = uuidv4 ( ) + '.ics' ;
29- startDate = ( startDate == null ) ? this . getDate ( undefined , 1 ) : startDate ;
30- const endDate = this . getDate ( startDate , 1 ) ;
31- await this . api ( ) . createCalendar ( new requests . CreateCalendarRequest (
32- fileName ,
33- new models . HierarchicalObjectRequest (
34- new models . HierarchicalObject (
35- 'CALENDAR' ,
36- undefined , [
37- new models . PrimitiveObject ( "LOCATION" , undefined , "location" ) ,
38- new models . PrimitiveObject ( "STARTDATE" , undefined , startDate . toUTCString ( ) ) ,
39- new models . PrimitiveObject ( "ENDDATE" , undefined , endDate . toUTCString ( ) ) ,
40- new models . HierarchicalObject ( "ORGANIZER" , undefined , [
41- new models . PrimitiveObject ( "ADDRESS" , undefined , "organizer@am.ru" ) ,
42- new models . PrimitiveObject ( "DISPLAYNAME" , undefined , "Organizer Name" )
43- ] ) ,
44- new models . HierarchicalObject ( "ATTENDEES" , undefined , [
45- new models . IndexedHierarchicalObject ( "ATTENDEE" , undefined , 0 , [
46- new models . PrimitiveObject ( "ADDRESS" , undefined , "attendee@am.ru" ) ,
47- new models . PrimitiveObject ( "DISPLAYNAME" , undefined , "Attendee Name" )
48- ] )
49- ] ) ]
50- ) ,
51- new models . StorageFolderLocation ( this . storage ( ) , this . folder ( ) )
52- )
53- ) ) ;
54- return fileName ;
55- }
56-
57- public getStorageFolderLocation ( ) : models . StorageFolderLocation {
58- return new models . StorageFolderLocation ( this . storage ( ) , this . folder ( ) ) ;
26+ public getStorageFolderLocation ( ) : StorageFolderLocation {
27+ return new StorageFolderLocation ( this . storage ( ) , this . folder ( ) ) ;
5928 }
6029}
6130
6231export function suiteBase ( suite : Suite ) : SuiteBase {
63- let api : EmailApi ;
32+ let api : EmailCloud ;
6433 let folder : string ;
6534 const storage = 'First Storage' ;
6635 suite . timeout ( 100000 ) ;
6736 suite . beforeAll ( async ( ) => {
68- api = new EmailApi ( process . env . appSid , process . env . appKey , process . env . apiBaseUrl ) ;
37+ api = new EmailCloud ( process . env . appSid , process . env . appKey , process . env . apiBaseUrl ) ;
6938 const authUrl = process . env . authUrl ;
7039 if ( authUrl != null ) api . configuration . authUrl = authUrl ;
7140 folder = uuidv4 ( ) ;
72- await api . createFolder ( new requests . CreateFolderRequest ( folder , storage ) ) ;
41+ await api . cloudStorage . folder . createFolder ( new CreateFolderRequest ( folder , storage ) ) ;
7342 } ) ;
7443 suite . afterAll ( async ( ) => {
75- await api . deleteFolder ( new requests . DeleteFolderRequest ( folder , storage , true ) ) ;
44+ await api . cloudStorage . folder . deleteFolder ( new DeleteFolderRequest ( folder , storage , true ) ) ;
7645 } ) ;
7746
7847 return new SuiteBase ( ( ) => api , ( ) => folder , ( ) => storage ) ;
0 commit comments