2626 */
2727package com .aspose .words .cloud ;
2828
29- import com .google .gson .JsonElement ;
30- import com .google .gson .JsonObject ;
31- import com .google .gson .JsonParser ;
3229import com .squareup .okhttp .*;
3330import com .squareup .okhttp .internal .http .HttpMethod ;
3431import com .squareup .okhttp .logging .HttpLoggingInterceptor ;
3734import okio .Okio ;
3835import org .threeten .bp .LocalDate ;
3936import org .threeten .bp .OffsetDateTime ;
40- import org .threeten .bp .format .DateTimeFormatter ;
41-
42- import javax .net .ssl .*;
43-
44- import java .io .Console ;
45- import java .io .File ;
46- import java .io .IOException ;
47- import java .io .InputStream ;
48- import java .io .UnsupportedEncodingException ;
49- import java .lang .reflect .Field ;
50- import java .lang .reflect .Method ;
51- import java .lang .reflect .ParameterizedType ;
37+
38+ import java .io .*;
5239import java .lang .reflect .Type ;
5340import java .net .URLConnection ;
5441import java .net .URLEncoder ;
55- import java .security .GeneralSecurityException ;
56- import java .security .KeyStore ;
57- import java .security .SecureRandom ;
58- import java .security .cert .Certificate ;
59- import java .security .cert .CertificateException ;
60- import java .security .cert .CertificateFactory ;
61- import java .security .cert .X509Certificate ;
62- import java .text .DateFormat ;
6342import java .util .*;
6443import java .util .Map .Entry ;
6544import java .util .concurrent .TimeUnit ;
@@ -71,7 +50,7 @@ public class ApiClient {
7150 private String apiVersion = "v4.0" ;
7251 private String baseUrl = "https://api.aspose.cloud" ;
7352 private String basePath = baseUrl + "/" + apiVersion ;
74- private String clientVersion = "19.10 .0" ;
53+ private String clientVersion = "20.3 .0" ;
7554 private boolean debugging = false ;
7655 private Map <String , String > defaultHeaderMap = new HashMap <String , String >();
7756 private String tempFolderPath = null ;
@@ -85,6 +64,15 @@ public class ApiClient {
8564 private String refreshToken ;
8665 private String appKey ;
8766 private String appSid ;
67+
68+ public ApiClient (String appSid , String appKey , String baseUrl ) {
69+ this ();
70+ this .appSid = appSid ;
71+ this .appKey = appKey ;
72+ if (baseUrl != null ) {
73+ this .setBaseUrl (baseUrl );
74+ }
75+ }
8876
8977 /*
9078 * Constructor for ApiClient
@@ -194,7 +182,7 @@ public ApiClient setBaseUrl(String baseUrl) {
194182 */
195183 public ApiClient setBasePath (String basePath ) {
196184 this .basePath = basePath ;
197- this .baseUrl = basePath .replace ("/v4.0 " , "" );
185+ this .baseUrl = basePath .replace ("/v1.1" , "" ). replace ( "/v1" , "" ). replace ( "/v2" , "" ). replace ( "/v3 " , "" );
198186 return this ;
199187 }
200188
@@ -893,7 +881,7 @@ public <T> T handleResponse(Response response, Type returnType) throws ApiExcept
893881 * @return The HTTP call
894882 * @throws ApiException If fail to serialize the request body object
895883 */
896- public Call buildCall (String path , String method , List <Pair > queryParams , List <Pair > collectionQueryParams , Object body , Map <String , String > headerParams , Map <String , Object > formParams , String [] authNames , ProgressRequestBody .ProgressRequestListener progressRequestListener ) throws ApiException {
884+ public Call buildCall (String path , String method , List <Pair > queryParams , List <Pair > collectionQueryParams , Object body , Map <String , String > headerParams , Map <String , Object > formParams , String [] authNames , ProgressRequestBody .ProgressRequestListener progressRequestListener ) throws ApiException , IOException {
897885 Request request = buildRequest (path , method , queryParams , collectionQueryParams , body , headerParams , formParams , authNames , progressRequestListener );
898886
899887 return httpClient .newCall (request );
@@ -914,7 +902,7 @@ public Call buildCall(String path, String method, List<Pair> queryParams, List<P
914902 * @return The HTTP request
915903 * @throws ApiException If fail to serialize the request body object
916904 */
917- public Request buildRequest (String path , String method , List <Pair > queryParams , List <Pair > collectionQueryParams , Object body , Map <String , String > headerParams , Map <String , Object > formParams , String [] authNames , ProgressRequestBody .ProgressRequestListener progressRequestListener ) throws ApiException {
905+ public Request buildRequest (String path , String method , List <Pair > queryParams , List <Pair > collectionQueryParams , Object body , Map <String , String > headerParams , Map <String , Object > formParams , String [] authNames , ProgressRequestBody .ProgressRequestListener progressRequestListener ) throws ApiException , IOException {
918906 addOAuthAuthentication (headerParams );
919907 final String url = buildUrl (path , queryParams , collectionQueryParams );
920908 final Request .Builder reqBuilder = new Request .Builder ().url (url );
@@ -1052,12 +1040,12 @@ public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams)
10521040 * @param formParams Form parameters in the form of Map
10531041 * @return RequestBody
10541042 */
1055- public RequestBody buildRequestBodyMultipart (Map <String , Object > formParams ) {
1043+ public RequestBody buildRequestBodyMultipart (Map <String , Object > formParams ) throws IOException {
10561044 MultipartBuilder mpBuilder = new MultipartBuilder ().type (MultipartBuilder .FORM );
10571045 for (Entry <String , Object > param : formParams .entrySet ()) {
1058- if (param .getValue () instanceof File ) {
1059- File file = (File ) param .getValue ();
1060- Headers partHeaders = Headers .of ("Content-Disposition" , "form-data; name=\" " + param .getKey () + "\" ; filename=\" " + file . getName () + "\" " );
1046+ if (param .getValue () instanceof byte [] ) {
1047+ byte [] file = (byte [] ) param .getValue ();
1048+ Headers partHeaders = Headers .of ("Content-Disposition" , "form-data; name=\" " + param .getKey () + "\" ; filename=\" " + param . getKey () + "\" " );
10611049 MediaType mediaType = MediaType .parse (guessContentTypeFromFile (file ));
10621050 mpBuilder .addPart (partHeaders , RequestBody .create (mediaType , file ));
10631051 }
@@ -1075,8 +1063,8 @@ public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) {
10751063 * @param file The given file
10761064 * @return The guessed Content-Type
10771065 */
1078- public String guessContentTypeFromFile (File file ) {
1079- String contentType = URLConnection .guessContentTypeFromName ( file . getName ( ));
1066+ public String guessContentTypeFromFile (byte [] file ) throws IOException {
1067+ String contentType = URLConnection .guessContentTypeFromStream ( new ByteArrayInputStream ( file ));
10801068 if (contentType == null ) {
10811069 return "application/octet-stream" ;
10821070 }
@@ -1087,7 +1075,7 @@ public String guessContentTypeFromFile(File file) {
10871075
10881076 /**
10891077 * Request OAuth token
1090- * @throws ApiException If fails to authorize
1078+ @throw ApiException If authorization is failed
10911079 */
10921080 public void requestToken () throws ApiException {
10931081 try {
@@ -1131,6 +1119,5 @@ private void addOAuthAuthentication(Map<String, String> headerParams) throws Api
11311119 */
11321120 private class GetAccessTokenResult {
11331121 public String access_token ;
1134- public String refresh_token ;
11351122 }
11361123}
0 commit comments