Skip to content

Commit 7badcf4

Browse files
Merge remote-tracking branch 'origin/master' into release
2 parents 7b168a8 + fa5c962 commit 7badcf4

21 files changed

+884
-11
lines changed

AsposeWordsCloud.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'AsposeWordsCloud'
3-
s.version = '21.11'
3+
s.version = '21.12'
44
s.summary = 'Aspose Words for Cloud.'
55
s.homepage = 'https://github.com/aspose-words-cloud/aspose-words-cloud-swift.git'
66
s.license = { :type => 'MIT', :file => 'LICENSE' }

Examples/AcceptAllRevisions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import AsposeWordsCloud
22

33
let config = Configuration(clientId: "####-####-####-####-####", clientSecret: "##################");
44
let api = try WordsAPI(configuration: config);
5-
let fileName = "test_doc.docx";
5+
let fileName = "test_doc.docx";
66

77
// Upload original document to cloud storage.
88
let myVar1 = InputStream(url: URL(string: fileName))!;

Examples/AcceptAllRevisionsOnline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let config = Configuration(clientId: "####-####-####-####-####", clientSecret: "##################");
22
let api = try WordsAPI(configuration: config);
3-
let fileName = "test_doc.docx";
3+
let fileName = "test_doc.docx";
44

55
// Calls AcceptAllRevisionsOnline method for document in cloud.
66
let requestDocument = InputStream(url: URL(string: fileName))!;

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ This repository contains Aspose.Words Cloud SDK for Swift source code. This SDK
1313
* Watermarks and protection
1414
* Full read & write access to Document Object Model, including sections, paragraphs, text, images, tables, headers/footers and many others
1515

16+
## Enhancements in Version 21.12
17+
18+
- Added 'timeout' parameter to api configuration
19+
1620
## Enhancements in Version 21.11
1721

1822
- Support encryption of 'CommonRequest.Password'. Automatic encryption of all passwords sent to the API server as request parameters.
@@ -169,7 +173,7 @@ Add link to this repository as dependency to your Package.swift:
169173

170174
dependencies: [
171175
// Dependencies declare other packages that this package depends on.
172-
.package(url: "https://github.com/aspose-words-cloud/aspose-words-cloud-swift", from: "21.11"),
176+
.package(url: "https://github.com/aspose-words-cloud/aspose-words-cloud-swift", from: "21.12"),
173177
],
174178
targets: [
175179
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
@@ -187,7 +191,7 @@ targets: [
187191
Add link to git repository as dependency to your Podfile:
188192

189193
```ruby
190-
pod 'AsposeWordsCloud', :git => 'https://github.com/aspose-words-cloud/aspose-words-cloud-swift.git', :tag => '21.11'
194+
pod 'AsposeWordsCloud', :git => 'https://github.com/aspose-words-cloud/aspose-words-cloud-swift.git', :tag => '21.12'
191195
```
192196

193197
## Getting Started

Sources/AsposeWordsCloud/Api/ApiInvoker.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public class ApiInvoker {
9090
// Create URL request object
9191
var request = URLRequest(url: apiRequestData.getURL());
9292
request.httpMethod = apiRequestData.getMethod();
93+
request.timeoutInterval = self.configuration.getTimeout();
9394

9495
// Fill headers
9596
for (key, value) in apiRequestData.getHeaders() {
@@ -238,6 +239,7 @@ public class ApiInvoker {
238239
let urlPath = URL(string: self.configuration.getBaseUrl())!.appendingPathComponent("connect/token");
239240
var request = URLRequest(url: urlPath);
240241
request.httpMethod = "POST";
242+
request.timeoutInterval = self.configuration.getTimeout();
241243
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type");
242244
request.httpBody = "grant_type=client_credentials&client_id=\(configuration.getClientId())&client_secret=\(configuration.getClientSecret())".data(using: .utf8);
243245
invokeRequest(urlRequest: &request, accessToken: nil, callback: { response in

Sources/AsposeWordsCloud/Api/Configuration.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,25 @@ public class Configuration : Codable {
4242
// Indicating whether debug mode
4343
private var debugMode: Bool?;
4444

45+
// Specify request timeout
46+
private var timeout: TimeInterval;
47+
4548
private enum CodingKeys: String, CodingKey {
4649
case baseUrl = "BaseUrl";
4750
case clientId = "ClientId";
4851
case clientSecret = "ClientSecret";
4952
case debugMode = "DebugMode";
53+
case timeout = "Timeout";
5054
case invalidCodingKey;
5155
}
5256

5357
// Initialize new instance of Aspose.Words for Cloud configuration object with given parameters
54-
public init(clientId: String, clientSecret: String, baseUrl: String = "https://api.aspose.cloud", debugMode: Bool = false) {
58+
public init(clientId: String, clientSecret: String, baseUrl: String = "https://api.aspose.cloud", debugMode: Bool = false, timeout: TimeInterval = 300) {
5559
self.clientId = clientId;
5660
self.clientSecret = clientSecret;
5761
self.baseUrl = baseUrl;
5862
self.debugMode = debugMode;
63+
self.timeout = timeout;
5964
}
6065

6166
public required init(from decoder: Decoder) throws {
@@ -64,6 +69,7 @@ public class Configuration : Codable {
6469
self.clientId = try container.decode(String.self, forKey: .clientId);
6570
self.clientSecret = try container.decode(String.self, forKey: .clientSecret);
6671
self.debugMode = try container.decodeIfPresent(Bool.self, forKey: .debugMode);
72+
self.timeout = try container.decodeIfPresent(TimeInterval.self, forKey: .timeout) ?? 300;
6773
}
6874

6975
public func encode(to encoder: Encoder) throws {
@@ -74,6 +80,7 @@ public class Configuration : Codable {
7480
if (self.debugMode != nil) {
7581
try container.encode(self.debugMode, forKey: .debugMode);
7682
}
83+
try container.encode(self.timeout, forKey: .timeout);
7784
}
7885

7986
// Returns Aspose.Words for Cloud base URL
@@ -96,6 +103,11 @@ public class Configuration : Codable {
96103
return self.debugMode != nil ? self.debugMode! : false;
97104
}
98105

106+
// Gets request timeout
107+
public func getTimeout() -> TimeInterval {
108+
return self.timeout;
109+
}
110+
99111
// Returns general version of cloud api
100112
public func getApiVersion() -> String {
101113
return "v4.0";
@@ -118,6 +130,6 @@ public class Configuration : Codable {
118130

119131
// Returns SDK version for using in statistics headers
120132
public func getSdkVersion() -> String {
121-
return "21.11";
133+
return "21.12";
122134
}
123135
}

Sources/AsposeWordsCloud/Api/WordsAPI.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6116,6 +6116,52 @@ public class WordsAPI {
61166116
return responseObject!;
61176117
}
61186118

6119+
// Async representation of getInfo method
6120+
// Returns application info.
6121+
public func getInfo(request : GetInfoRequest, callback : @escaping (_ response : InfoResponse?, _ error : Error?) -> ()) {
6122+
do {
6123+
apiInvoker.invoke(
6124+
apiRequestData: try request.createApiRequestData(apiInvoker: self.apiInvoker, configuration: self.configuration),
6125+
callback: { response, error in
6126+
if (error != nil) {
6127+
callback(nil, error);
6128+
}
6129+
else {
6130+
do {
6131+
callback(try request.deserializeResponse(data: response!) as? InfoResponse, nil);
6132+
}
6133+
catch let deserializeError {
6134+
callback(nil, deserializeError);
6135+
}
6136+
}
6137+
}
6138+
);
6139+
}
6140+
catch let error {
6141+
callback(nil, error);
6142+
}
6143+
}
6144+
6145+
// Sync representation of getInfo method
6146+
// Returns application info.
6147+
public func getInfo(request : GetInfoRequest) throws -> InfoResponse {
6148+
let semaphore = DispatchSemaphore(value: 0);
6149+
var responseObject : InfoResponse? = nil;
6150+
var responseError : Error? = nil;
6151+
self.getInfo(request : request, callback: { response, error in
6152+
responseObject = response;
6153+
responseError = error;
6154+
semaphore.signal();
6155+
});
6156+
6157+
_ = semaphore.wait();
6158+
6159+
if (responseError != nil) {
6160+
throw responseError!;
6161+
}
6162+
return responseObject!;
6163+
}
6164+
61196165
// Async representation of getList method
61206166
// Reads a list from the document.
61216167
public func getList(request : GetListRequest, callback : @escaping (_ response : ListResponse?, _ error : Error?) -> ()) {

0 commit comments

Comments
 (0)