44
55class ConversionClient
66{
7- const VERSION = '1.0.0 ' ;
7+ const VERSION = '1.0.1 ' ;
88
99 public static $ userAgent = 'conversiontools-php ' ;
10-
10+
1111 public static $ baseUrl = 'https://api.conversiontools.io/v1 ' ;
1212
1313 public static $ DEBUG = FALSE ;
@@ -29,11 +29,19 @@ public static function getUserAgent()
2929 return self ::$ userAgent . '/ ' . self ::VERSION ;
3030 }
3131
32- public function convert ($ type , $ fileInput , $ fileOutput , $ options = NULL )
32+ public function convert ($ type , $ fileOrUrlInput , $ fileOutput , $ options = [] )
3333 {
34- $ file_id = API ::uploadFile ($ fileInput );
35- $ task_id = API ::createTask ($ type , $ file_id , $ options );
36- while (TRUE ) {
34+ if (isset ($ fileOrUrlInput )) {
35+ if (is_file ($ fileOrUrlInput )) {
36+ $ file_id = API ::uploadFile ($ fileOrUrlInput );
37+ $ options = array_merge ($ options , ['file_id ' => $ file_id ]);
38+ }
39+ if (parse_url ($ fileOrUrlInput )) {
40+ $ options = array_merge ($ options , ['url ' => $ fileOrUrlInput ]);
41+ }
42+ }
43+ $ task_id = API ::createTask ($ type , $ options );
44+ while (isset ($ task_id )) {
3745 list ($ status , $ file_id_result ) = API ::getTaskStatus ($ task_id );
3846 switch ($ status ) {
3947 case 'SUCCESS ' :
0 commit comments