Skip to content

Commit 0e949af

Browse files
committed
Release Aspose.Cells.Cloud SDK 20.2
1 parent 5219b84 commit 0e949af

File tree

6 files changed

+122
-81
lines changed

6 files changed

+122
-81
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Aspose.Cells Cloud SDK for Java
22

33
- API version: 3.0
4-
- SDK version: 20.1
4+
- SDK version: 20.2
55

66
This repository contains Aspose.Cells Cloud SDK for Java source code. This SDK allows you to work with Aspose.Cells Cloud REST APIs in your Java applications quickly and easily, with zero initial cost.
77

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'idea'
22
apply plugin: 'eclipse'
33

44
group = 'com.aspose'
5-
version = '19.9'
5+
version = '20.2'
66

77
buildscript {
88
repositories {

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>aspose-cells-cloud</artifactId>
66
<packaging>jar</packaging>
77
<name>aspose-cells-cloud</name>
8-
<version>20.1</version>
8+
<version>20.2</version>
99
<url>https://github.com/aspose-cells-cloud/aspose-cells-cloud-java</url>
1010
<scm>
1111
<connection>scm:git:[email protected]:aspose-cells-cloud/aspose-cells-cloud-java</connection>

src/main/java/com/aspose/cloud/cells/api/CellsApi.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,33 @@ public CellsApi() {
160160
this(Configuration.getDefaultApiClient());
161161
}
162162

163+
164+
public CellsApi(String appSid, String appKey) throws ApiException {
165+
ApiClient apiClient = new ApiClient();
166+
apiClient.setBasePath("https://api.aspose.cloud");
167+
String accesstoken = apiClient.getAccessToken("client_credentials",
168+
appSid, appKey, "v3.0");
169+
170+
apiClient.setBasePath("https://api.aspose.cloud/v3.0");
171+
apiClient.addDefaultHeader("Authorization", "Bearer " + accesstoken);
172+
setApiClient(apiClient);
173+
}
174+
175+
public CellsApi(String appSid, String appKey, String Version)
176+
throws ApiException {
177+
178+
ApiClient apiClient = new ApiClient();
179+
apiClient.setBasePath("https://api.aspose.cloud");
180+
String accesstoken = apiClient.getAccessToken("client_credentials",
181+
appSid, appKey, Version);
182+
183+
apiClient.setBasePath("https://api.aspose.cloud/" + Version);
184+
apiClient.addDefaultHeader("Authorization", "Bearer " + accesstoken);
185+
setApiClient(apiClient);
186+
}
163187
public CellsApi(ApiClient apiClient) {
164188
this.apiClient = apiClient;
165189
}
166-
public CellsApi( String appSid,String appKey) throws ApiException{
167-
ApiClient apiClient =new ApiClient();
168-
apiClient.setBasePath("https://api.aspose.cloud");
169-
setApiClient( apiClient);
170-
AccessTokenResponse response = oAuthPost("client_credentials", appSid, appKey);
171-
String accesstoken = response.getAccessToken();
172-
apiClient.setBasePath("https://api.aspose.cloud/v3.0");
173-
apiClient.addDefaultHeader("Authorization", "Bearer " + accesstoken);
174-
setApiClient( apiClient);
175-
}
176-
177-
public CellsApi(String appSID,String appKey ,String Version) throws ApiException {
178-
ApiClient apiClient =new ApiClient();
179-
apiClient.setBasePath("https://api.aspose.cloud");
180-
String accesstoken = apiClient.getAccessToken("client_credentials", appSID, appKey,Version);
181-
apiClient.setBasePath("https://api.aspose.cloud/"+Version);
182-
apiClient.addDefaultHeader("Authorization", "Bearer " + accesstoken);
183-
setApiClient( apiClient);
184-
}
185190
public ApiClient getApiClient() {
186191
return apiClient;
187192
}

src/main/java/com/aspose/cloud/cells/client/ApiClient.java

Lines changed: 91 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
import javax.net.ssl.TrustManagerFactory;
7878
import javax.net.ssl.X509TrustManager;
7979

80+
import org.joda.time.DateTime;
81+
8082
import okio.BufferedSink;
8183
import okio.Okio;
8284

@@ -178,14 +180,95 @@ public ApiClient() {
178180
authentications = Collections.unmodifiableMap(authentications);
179181
}
180182

181-
/**
182-
* Get base path
183-
*
184-
* @return Baes path
185-
*/
186-
public String getBasePath() {
187-
return basePath;
188-
}
183+
private String appSid;
184+
private String appKey;
185+
private String appVersion;
186+
private String appGrantType;
187+
private DateTime getAccessTokenTime;
188+
189+
/**
190+
* Get access token
191+
*
192+
* @param grantType
193+
* @param clientId
194+
* @param clientSecret
195+
* @param version
196+
* @return
197+
* @throws ApiException
198+
*/
199+
public String getAccessToken(String grantType, String clientId,
200+
String clientSecret, String version) throws ApiException {
201+
Object localVarPostBody = null;
202+
203+
// create path and map variables]
204+
appGrantType = grantType;
205+
appSid = clientId;
206+
appKey = clientSecret;
207+
appVersion = version;
208+
209+
String localVarPath = "/connect/token";
210+
if (version == "v1.1") {
211+
localVarPath = "/oauth2/token";
212+
}
213+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
214+
215+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
216+
217+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
218+
if (grantType != null)
219+
localVarFormParams.put("grant_type", grantType);
220+
if (clientId != null)
221+
localVarFormParams.put("client_id", clientId);
222+
if (clientSecret != null)
223+
localVarFormParams.put("client_secret", clientSecret);
224+
225+
final String[] localVarAccepts = { "application/json" };
226+
final String localVarAccept = selectHeaderAccept(localVarAccepts);
227+
if (localVarAccept != null)
228+
localVarHeaderParams.put("Accept", localVarAccept);
229+
230+
final String[] localVarContentTypes = { "application/x-www-form-urlencoded" };
231+
final String localVarContentType = selectHeaderContentType(localVarContentTypes);
232+
localVarHeaderParams.put("Content-Type", localVarContentType);
233+
234+
String[] localVarAuthNames = new String[] {};
235+
236+
Request request = buildRequest(localVarPath, "POST", localVarQueryParams, localVarPostBody,
237+
localVarHeaderParams, localVarFormParams, localVarAuthNames, null);
238+
239+
com.squareup.okhttp.Call call = httpClient.newCall(request);
240+
241+
Type localVarReturnType = new TypeToken<AccessTokenResponse>() {
242+
}.getType();
243+
ApiResponse<AccessTokenResponse> resp = execute(call,
244+
localVarReturnType);
245+
String accessToken = resp.getData().getAccessToken();
246+
getAccessTokenTime = DateTime.now();
247+
return accessToken;
248+
}
249+
250+
public void checkAccessToken() throws ApiException {
251+
if (getAccessTokenTime == null) {
252+
return;
253+
}
254+
if (DateTime.now().compareTo(getAccessTokenTime.plusSeconds(86300))>0 ) {
255+
setBasePath("https://api.aspose.cloud");
256+
String accessToken = getAccessToken(appGrantType, appSid, appKey,
257+
appVersion);
258+
getAccessTokenTime = DateTime.now();
259+
setBasePath("https://api.aspose.cloud/" + appVersion);
260+
addDefaultHeader("Authorization", "Bearer " + accessToken);
261+
}
262+
}
263+
264+
/**
265+
* Get base path
266+
*
267+
* @return Baes path
268+
*/
269+
public String getBasePath() {
270+
return basePath;
271+
}
189272

190273
/**
191274
* Set base path
@@ -457,56 +540,7 @@ public Map<String, Authentication> getAuthentications() {
457540
public Authentication getAuthentication(String authName) {
458541
return authentications.get(authName);
459542
}
460-
/**
461-
* Get access token
462-
* @param grantType
463-
* @param clientId
464-
* @param clientSecret
465-
* @param version
466-
* @return
467-
* @throws ApiException
468-
*/
469-
public String getAccessToken(String grantType, String clientId, String clientSecret,String version) throws ApiException {
470-
Object localVarPostBody = null;
471-
472-
// create path and map variables
473543

474-
String localVarPath = "/connect/token";
475-
if( version == "v1.1")
476-
{
477-
localVarPath ="/oauth2/token";
478-
}
479-
List<Pair> localVarQueryParams = new ArrayList<Pair>();
480-
481-
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
482-
483-
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
484-
if (grantType != null)
485-
localVarFormParams.put("grant_type", grantType);
486-
if (clientId != null)
487-
localVarFormParams.put("client_id", clientId);
488-
if (clientSecret != null)
489-
localVarFormParams.put("client_secret", clientSecret);
490-
491-
final String[] localVarAccepts = {
492-
"application/json"
493-
};
494-
final String localVarAccept = selectHeaderAccept(localVarAccepts);
495-
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
496-
497-
final String[] localVarContentTypes = {
498-
"application/x-www-form-urlencoded"
499-
};
500-
final String localVarContentType = selectHeaderContentType(localVarContentTypes);
501-
localVarHeaderParams.put("Content-Type", localVarContentType);
502-
503-
String[] localVarAuthNames = new String[] { };
504-
505-
com.squareup.okhttp.Call call= buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, null);
506-
Type localVarReturnType = new TypeToken<AccessTokenResponse>(){}.getType();
507-
ApiResponse<AccessTokenResponse> resp = execute(call, localVarReturnType);
508-
return resp.getData().getAccessToken();
509-
}
510544
/**
511545
* Helper method to set username for the first HTTP basic authentication.
512546
*

src/test/java/com/aspose/cloud/cells/api/CellsApiUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212

1313
public class CellsApiUtil {
1414
private static String grantType = "client_credentials";
15-
private static String clientId = "66164C51-693E-4904-A121-545961673EC1";//"";
16-
private static String clientSecret = "536e76768419db9585afdd37bb5f7533";//"";
15+
private static String clientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";//"";
16+
private static String clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";//"";
1717
private static String sourceFolder ="D:\\Projects\\Aspose\\Aspose.Cloud\\Aspose.Cells.Cloud.SDK\\src\\TestData\\";
18+
1819
public static String GetSourceFolder() {
1920
return sourceFolder;
2021
}
22+
2123
public static String GetGrantType() {
2224
return grantType;
2325
}

0 commit comments

Comments
 (0)