Skip to content

Commit a115053

Browse files
Merge remote-tracking branch 'origin/master' into release
2 parents 4237e84 + 5717220 commit a115053

File tree

489 files changed

+17499
-15487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

489 files changed

+17499
-15487
lines changed

.gitattributes

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# default behavior
2+
* text=auto
3+
4+
# code files
5+
*.swift text eol=lf
6+
7+
# test files
8+
*.xml text eol=lf
9+
*.json text eol=lf
10+
11+
# scripts
12+
*.bat text eol=crlf
13+
*.ps1 text eol=crlf
14+
*.sh text eol=lf
15+
16+
17+
18+

Jenkinsfile

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
parameters {
2-
string(name: 'branch', defaultValue: 'master', description: 'branch to test')
3-
string(name: 'apiUrl', defaultValue: 'https://api-qa.aspose.cloud', description: 'server url')
4-
}
1+
properties([
2+
gitLabConnection('gitlab'),
3+
[$class: 'ParametersDefinitionProperty',
4+
parameterDefinitions: [
5+
[$class: 'StringParameterDefinition', name: 'branch', defaultValue: 'master', description: 'the branch to build'],
6+
[$class: 'StringParameterDefinition', name: 'apiUrl', defaultValue: 'https://api-qa.aspose.cloud', description: 'api url'],
7+
[$class: 'BooleanParameterDefinition', name: 'ignoreCiSkip', defaultValue: false, description: 'ignore CI Skip'],
8+
]
9+
]
10+
])
11+
12+
def needToBuild = false
513

614
node('words-linux') {
715
cleanWs()
@@ -10,30 +18,41 @@ node('words-linux') {
1018
try {
1119
stage('checkout'){
1220
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-sdk-swift.git']]])
13-
withCredentials([usernamePassword(credentialsId: '6839cbe8-39fa-40c0-86ce-90706f0bae5d', passwordVariable: 'AppKey', usernameVariable: 'AppSid')]) {
14-
sh 'mkdir -p Settings'
15-
sh 'echo "{\\"AppSid\\": \\"$AppSid\\",\\"AppKey\\": \\"$AppKey\\", \\"BaseUrl\\": \\"$apiUrl\\"}" > Settings/servercreds.json'
21+
22+
sh 'git show -s HEAD > gitMessage'
23+
def commitMessage = readFile('gitMessage').trim()
24+
echo commitMessage
25+
needToBuild = params.ignoreCiSkip || !commitMessage.contains('[ci skip]')
26+
sh 'git clean -fdx'
27+
28+
if (needToBuild) {
29+
withCredentials([usernamePassword(credentialsId: '6839cbe8-39fa-40c0-86ce-90706f0bae5d', passwordVariable: 'AppKey', usernameVariable: 'AppSid')]) {
30+
sh 'mkdir -p Settings'
31+
sh 'echo "{\\"AppSid\\": \\"$AppSid\\",\\"AppKey\\": \\"$AppKey\\", \\"BaseUrl\\": \\"$apiUrl\\"}" > Settings/servercreds.json'
32+
}
1633
}
1734
}
1835

19-
docker.image('swift:5.0').inside{
20-
stage('build'){
21-
sh "swift build"
22-
}
23-
24-
stage('tests'){
25-
try{
26-
sh "chmod +x ./Scripts/runTests.sh"
27-
sh "./Scripts/runTests.sh"
28-
} finally{
29-
junit 'tests.xml'
36+
if (needToBuild) {
37+
docker.image('swift:5.0').inside{
38+
stage('build'){
39+
sh "swift build"
3040
}
31-
}
3241

33-
stage('clean-compiled'){
34-
sh "rm -rf %s"
35-
}
36-
}
42+
stage('tests'){
43+
try{
44+
sh "chmod +x ./Scripts/runTests.sh"
45+
sh "./Scripts/runTests.sh"
46+
} finally{
47+
junit 'tests.xml'
48+
}
49+
}
50+
51+
stage('clean-compiled'){
52+
sh "rm -rf %s"
53+
}
54+
}
55+
}
3756
} finally {
3857
deleteDir()
3958
}

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Aspose.Words Cloud SDK for Swift
22
This repository contains Aspose.Words Cloud SDK for Swift source code. This SDK allows you to work with Aspose.Words Cloud REST APIs in your Swift applications quickly and easily, with zero initial cost.
33

4-
[Aspose.Words Cloud](https://products.aspose.cloud/words/family "Aspose.Words Cloud")
5-
[API Reference](https://apireference.aspose.cloud/words/)
4+
[Aspose.Words Cloud](https://products.aspose.cloud/words/family "Aspose.Words for Cloud")
5+
[API Reference](https://apireference.aspose.cloud/words/)
66

77
## Key Features
88
* Conversion between various document-related formats (20+ formats supported), including PDF<->Word conversion
@@ -26,7 +26,7 @@ Add link to this repository as dependency to your Package.swift:
2626

2727
dependencies: [
2828
// Dependencies declare other packages that this package depends on.
29-
.package(url: "https://github.com/aspose-words-cloud/aspose-words-cloud-swift", from: "20.6"),
29+
.package(url: "https://github.com/aspose-words-cloud/aspose-words-cloud-swift", from: "20.7"),
3030
],
3131
targets: [
3232
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
@@ -61,21 +61,21 @@ Please put your credentials into "Settings/servercreds.json" for run tests.
6161
- referenced packages (see [here](Package.swift) for more details)
6262

6363
## Licensing
64-
64+
6565
All Aspose.Words Cloud SDKs, helper scripts and templates are licensed under [MIT License](https://github.com/aspose-words-cloud/aspose-words-cloud-swift/blob/master/LICENSE).
6666

6767
## Contact Us
6868
Your feedback is very important to us. Please feel free to contact us using our [Support Forums](https://forum.aspose.cloud/c/words).
6969

7070
## Resources
71-
71+
7272
[Website](https://www.aspose.cloud/)
7373
[Product Home](https://products.aspose.cloud/words/family)
7474
[API Reference](https://apireference.aspose.cloud/words/)
7575
[Documentation](https://docs.aspose.cloud/display/wordscloud/Home)
7676
[Blog](https://blog.aspose.cloud/category/words/)
77-
77+
7878
## Other languages
7979
We generate our SDKs in different languages so you may check if yours is available in our [list](https://github.com/aspose-words-cloud).
80-
80+
8181
If you don't find your language in the list, feel free to request it from us, or use raw REST API requests as you can find it [here](https://products.aspose.cloud/words/curl).

Sources/AsposeWordsCloud/Api/ApiInvoker.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1111
* copies of the Software, and to permit persons to whom the Software is
1212
* furnished to do so, subject to the following conditions:
13-
*
13+
*
1414
* The above copyright notice and this permission notice shall be included in all
1515
* copies or substantial portions of the Software.
16-
*
16+
*
1717
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1818
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1919
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -31,45 +31,45 @@ import Foundation
3131
public class ApiInvoker {
3232
// An object containing the configuration for executing API requests
3333
private let configuration : Configuration;
34-
34+
3535
// Cached value of oauth2 authorization tokeт.
3636
// It is filled after the first call to the API.
3737
// Mutex is used to synchronize updates in a multi-threaded environment.
3838
private let mutex : NSLock;
3939
private var accessTokenCache : String?;
40-
40+
4141
// Maximum size of printing body content in debug mode
4242
private let maxDebugPrintingContentSize = 1024 * 1024; // 1Mb
43-
43+
4444
// Status codes for HTTP request
4545
private let httpStatusCodeOK = 200;
4646
private let httpStatusCodeBadRequest = 400;
4747
private let httpStatusCodeUnauthorized = 401;
4848
private let httpStatusCodeTimeout = 408;
49-
49+
5050
// Initialize ApiInvoker object with specific configuration
5151
public init(configuration : Configuration) {
5252
self.configuration = configuration;
5353
self.mutex = NSLock();
5454
self.accessTokenCache = nil;
5555
}
56-
56+
5757
// Internal class for represent API response
5858
private class InvokeResponse {
5959
public var data : Data?;
6060
public var errorCode : Int;
6161
public var errorMessage : String?;
62-
62+
6363
public init(errorCode : Int) {
6464
self.errorCode = errorCode;
6565
}
6666
}
67-
67+
6868
// Internal struct for represent oauth2 authorization response
6969
private struct AccessTokenResult : Decodable {
7070
public var access_token : String?;
7171
}
72-
72+
7373
// Invoke request to the API with the specified set of arguments and execute callback after the request is completed
7474
public func invoke(
7575
url: URL,
@@ -90,7 +90,7 @@ public class ApiInvoker {
9090
request.setValue(value, forHTTPHeaderField: key);
9191
}
9292
}
93-
93+
9494
// Process the request body
9595
if (body != nil) {
9696
request.httpBody = body;
@@ -110,7 +110,7 @@ public class ApiInvoker {
110110
formBody.append("\r\n".data(using: .utf8)!);
111111
}
112112
needsClrf = true;
113-
113+
114114
formBody.append("--\(boundaryPrefix)\r\nContent-Disposition: form-data; name=\"\(formParam.getName())\"\r\n\r\n".data(using: .utf8)!);
115115
formBody.append(formParam.getBody());
116116
}
@@ -120,12 +120,12 @@ public class ApiInvoker {
120120
request.setValue("multipart/form-data; boundary=\(boundaryPrefix)", forHTTPHeaderField: "Content-Type");
121121
}
122122
}
123-
123+
124124
// Set content length header
125125
if (request.httpBody != nil) {
126126
request.setValue(String(request.httpBody!.count), forHTTPHeaderField: "Content-Length");
127127
}
128-
128+
129129
// Request or get from cache authorization token
130130
invokeAuthToken(forceTokenRequest: false, callback: { accessToken, statusCode in
131131
if (statusCode == self.httpStatusCodeOK) {
@@ -165,18 +165,18 @@ public class ApiInvoker {
165165
}
166166
});
167167
}
168-
168+
169169
// Invokes prepared request to the API. Callback returns a response from the API call
170170
private func invokeRequest(urlRequest : inout URLRequest, accessToken : String?, callback : @escaping (_ response: InvokeResponse) -> ()) {
171171
// Set access token to request headers
172172
if (accessToken != nil) {
173173
urlRequest.setValue(accessToken!, forHTTPHeaderField: "Authorization");
174174
}
175-
175+
176176
// Set statistic headers
177177
urlRequest.setValue(self.configuration.getSdkName(), forHTTPHeaderField: "x-aspose-client");
178178
urlRequest.setValue(self.configuration.getSdkVersion(), forHTTPHeaderField: "x-aspose-client-version");
179-
179+
180180
// Print request when debug mode is enabled
181181
if (configuration.isDebugMode()) {
182182
print("REQUEST BEGIN");
@@ -217,7 +217,7 @@ public class ApiInvoker {
217217
else {
218218
invokeResponse.errorCode = self.httpStatusCodeBadRequest;
219219
}
220-
220+
221221
// Print response when debug mode is enabled
222222
if (self.configuration.isDebugMode()) {
223223
print("RESPONSE BEGIN");
@@ -242,12 +242,12 @@ public class ApiInvoker {
242242
}
243243
print("RESPONSE END");
244244
}
245-
245+
246246
callback(invokeResponse);
247247
});
248248
result.resume();
249249
}
250-
250+
251251
// Requests authorization token from server. After the first call, the token is cached and the cached value is used for future calls.
252252
private func invokeAuthToken(forceTokenRequest: Bool, callback : @escaping (_ accessToken: String?, _ statusCode: Int) -> ()) {
253253
var accessToken : String? = nil;
@@ -258,7 +258,7 @@ public class ApiInvoker {
258258
}
259259
mutex.unlock();
260260
}
261-
261+
262262
if (accessToken == nil) {
263263
let urlPath = URL(string: self.configuration.getBaseUrl())!.appendingPathComponent("connect/token");
264264
var request = URLRequest(url: urlPath);

0 commit comments

Comments
 (0)