Skip to content

Commit 723b0f0

Browse files
0.14.0 (#131)
* DocumentInfo model and its submodels added * Added new documentInfo method * Integration test for documentInfo method added * example usage * removed print * added documentInfo method implementation with completion handler * integration test for documentInfo method with completion handler added * added documentation for Document info methods * version bump * Privacy Manifest added * Fixed Carthage build. * include privacy manifest into iOS target * Update test.yml * swift 5.10 added to the list of versions * Update Tests/UploadcareTests/RESTAPIIntegrationTests.swift Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * no force unwrapping in test * test updated * added privacy manifest for widget * process privacy manifest as a resource * Update test.yml * Linux dependencies updated * Update Sources/Uploadcare/Utils.swift Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent ce7a27e commit 723b0f0

14 files changed

+403
-105
lines changed

.github/workflows/test.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ on:
99
jobs:
1010
macos_build_and_test:
1111
name: Build and test on latest macOS
12-
runs-on: macos-latest
12+
runs-on: macOS-latest
1313

1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@master
1717

18-
- name: Swift build for iOS
19-
run: swift build -c release -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios13.0-simulator"
18+
- name: Build for iOS
19+
run: xcodebuild -scheme Uploadcare -destination "generic/platform=iOS"
2020

21-
- name: Swift build for macOS
21+
- name: Build for macOS
2222
run: swift build -c release
2323

24-
- name: Swift test
24+
- name: Test
2525
run: UPLOADCARE_PUBLIC_KEY="${{ secrets.UPLOADCARE_PUBLIC_KEY }}" UPLOADCARE_SECRET_KEY="${{ secrets.UPLOADCARE_SECRET_KEY }}" swift test
2626

2727
ubuntu:
2828
name: Build and test on latest Ubuntu
2929
runs-on: ubuntu-latest
3030
strategy:
3131
matrix:
32-
swift: [5.9, 5.6.3]
32+
swift: [5.10, 5.6.3]
3333

3434
steps:
3535
- name: Checkout

Documentation/REST API.md

+19
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,25 @@ uploadcare.deleteWebhook(forTargetUrl: url) { error in
568568
}
569569
```
570570

571+
## Document info ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion/operation/documentConvertInfo)) ##
572+
573+
The method allows you to determine the document format and possible conversion formats:
574+
575+
```swift
576+
// Async:
577+
let documentInfo = try await uploadcare.documentInfo("fileUUID")
578+
579+
// With a completion callback:
580+
uploadcare.documentInfo("fileUUID") { result in
581+
switch result {
582+
case .failure(let error):
583+
print(error)
584+
case .success(let documentInfo):
585+
print(documentInfo)
586+
}
587+
}
588+
```
589+
571590
## Convert document ([API Reference](https://uploadcare.com/docs/transformations/document_conversion/#convert)) ##
572591

573592
You can convert multiple files with one request:

Package.resolved

+128-94
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,131 @@
11
{
2-
"object": {
3-
"pins": [
4-
{
5-
"package": "async-http-client",
6-
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
7-
"state": {
8-
"branch": null,
9-
"revision": "78db67e5bf4a8543075787f228e8920097319281",
10-
"version": "1.18.0"
11-
}
12-
},
13-
{
14-
"package": "swift-atomics",
15-
"repositoryURL": "https://github.com/apple/swift-atomics.git",
16-
"state": {
17-
"branch": null,
18-
"revision": "6c89474e62719ddcc1e9614989fff2f68208fe10",
19-
"version": "1.1.0"
20-
}
21-
},
22-
{
23-
"package": "swift-collections",
24-
"repositoryURL": "https://github.com/apple/swift-collections.git",
25-
"state": {
26-
"branch": null,
27-
"revision": "937e904258d22af6e447a0b72c0bc67583ef64a2",
28-
"version": "1.0.4"
29-
}
30-
},
31-
{
32-
"package": "swift-crypto",
33-
"repositoryURL": "https://github.com/apple/swift-crypto.git",
34-
"state": {
35-
"branch": null,
36-
"revision": "60f13f60c4d093691934dc6cfdf5f508ada1f894",
37-
"version": "2.6.0"
38-
}
39-
},
40-
{
41-
"package": "swift-log",
42-
"repositoryURL": "https://github.com/apple/swift-log.git",
43-
"state": {
44-
"branch": null,
45-
"revision": "532d8b529501fb73a2455b179e0bbb6d49b652ed",
46-
"version": "1.5.3"
47-
}
48-
},
49-
{
50-
"package": "swift-nio",
51-
"repositoryURL": "https://github.com/apple/swift-nio.git",
52-
"state": {
53-
"branch": null,
54-
"revision": "cf281631ff10ec6111f2761052aa81896a83a007",
55-
"version": "2.58.0"
56-
}
57-
},
58-
{
59-
"package": "swift-nio-extras",
60-
"repositoryURL": "https://github.com/apple/swift-nio-extras.git",
61-
"state": {
62-
"branch": null,
63-
"revision": "0e0d0aab665ff1a0659ce75ac003081f2b1c8997",
64-
"version": "1.19.0"
65-
}
66-
},
67-
{
68-
"package": "swift-nio-http2",
69-
"repositoryURL": "https://github.com/apple/swift-nio-http2.git",
70-
"state": {
71-
"branch": null,
72-
"revision": "a8ccf13fa62775277a5d56844878c828bbb3be1a",
73-
"version": "1.27.0"
74-
}
75-
},
76-
{
77-
"package": "swift-nio-ssl",
78-
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
79-
"state": {
80-
"branch": null,
81-
"revision": "320bd978cceb8e88c125dcbb774943a92f6286e9",
82-
"version": "2.25.0"
83-
}
84-
},
85-
{
86-
"package": "swift-nio-transport-services",
87-
"repositoryURL": "https://github.com/apple/swift-nio-transport-services.git",
88-
"state": {
89-
"branch": null,
90-
"revision": "e7403c35ca6bb539a7ca353b91cc2d8ec0362d58",
91-
"version": "1.19.0"
92-
}
2+
"pins" : [
3+
{
4+
"identity" : "async-http-client",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/swift-server/async-http-client.git",
7+
"state" : {
8+
"revision" : "a22083713ee90808d527d0baa290c2fb13ca3096",
9+
"version" : "1.21.1"
9310
}
94-
]
95-
},
96-
"version": 1
11+
},
12+
{
13+
"identity" : "swift-algorithms",
14+
"kind" : "remoteSourceControl",
15+
"location" : "https://github.com/apple/swift-algorithms",
16+
"state" : {
17+
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
18+
"version" : "1.2.0"
19+
}
20+
},
21+
{
22+
"identity" : "swift-atomics",
23+
"kind" : "remoteSourceControl",
24+
"location" : "https://github.com/apple/swift-atomics.git",
25+
"state" : {
26+
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
27+
"version" : "1.2.0"
28+
}
29+
},
30+
{
31+
"identity" : "swift-collections",
32+
"kind" : "remoteSourceControl",
33+
"location" : "https://github.com/apple/swift-collections.git",
34+
"state" : {
35+
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
36+
"version" : "1.1.0"
37+
}
38+
},
39+
{
40+
"identity" : "swift-crypto",
41+
"kind" : "remoteSourceControl",
42+
"location" : "https://github.com/apple/swift-crypto.git",
43+
"state" : {
44+
"revision" : "bc1c29221f6dfeb0ebbfbc98eb95cd3d4967868e",
45+
"version" : "3.4.0"
46+
}
47+
},
48+
{
49+
"identity" : "swift-http-types",
50+
"kind" : "remoteSourceControl",
51+
"location" : "https://github.com/apple/swift-http-types",
52+
"state" : {
53+
"revision" : "9bee2fdb79cc740081abd8ebd80738063d632286",
54+
"version" : "1.1.0"
55+
}
56+
},
57+
{
58+
"identity" : "swift-log",
59+
"kind" : "remoteSourceControl",
60+
"location" : "https://github.com/apple/swift-log.git",
61+
"state" : {
62+
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
63+
"version" : "1.5.4"
64+
}
65+
},
66+
{
67+
"identity" : "swift-nio",
68+
"kind" : "remoteSourceControl",
69+
"location" : "https://github.com/apple/swift-nio.git",
70+
"state" : {
71+
"revision" : "359c461e5561d22c6334828806cc25d759ca7aa6",
72+
"version" : "2.65.0"
73+
}
74+
},
75+
{
76+
"identity" : "swift-nio-extras",
77+
"kind" : "remoteSourceControl",
78+
"location" : "https://github.com/apple/swift-nio-extras.git",
79+
"state" : {
80+
"revision" : "a3b640d7dc567225db7c94386a6e71aded1bfa63",
81+
"version" : "1.22.0"
82+
}
83+
},
84+
{
85+
"identity" : "swift-nio-http2",
86+
"kind" : "remoteSourceControl",
87+
"location" : "https://github.com/apple/swift-nio-http2.git",
88+
"state" : {
89+
"revision" : "c6afe04165c865faaa687b42c32ed76dfcc91076",
90+
"version" : "1.31.0"
91+
}
92+
},
93+
{
94+
"identity" : "swift-nio-ssl",
95+
"kind" : "remoteSourceControl",
96+
"location" : "https://github.com/apple/swift-nio-ssl.git",
97+
"state" : {
98+
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
99+
"version" : "2.26.0"
100+
}
101+
},
102+
{
103+
"identity" : "swift-nio-transport-services",
104+
"kind" : "remoteSourceControl",
105+
"location" : "https://github.com/apple/swift-nio-transport-services.git",
106+
"state" : {
107+
"revision" : "38ac8221dd20674682148d6451367f89c2652980",
108+
"version" : "1.21.0"
109+
}
110+
},
111+
{
112+
"identity" : "swift-numerics",
113+
"kind" : "remoteSourceControl",
114+
"location" : "https://github.com/apple/swift-numerics.git",
115+
"state" : {
116+
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
117+
"version" : "1.0.2"
118+
}
119+
},
120+
{
121+
"identity" : "swift-system",
122+
"kind" : "remoteSourceControl",
123+
"location" : "https://github.com/apple/swift-system.git",
124+
"state" : {
125+
"revision" : "f9266c85189c2751589a50ea5aec72799797e471",
126+
"version" : "1.3.0"
127+
}
128+
}
129+
],
130+
"version" : 2
97131
}

Package.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@ let package = Package(
3939
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
4040
.target(
4141
name: "Uploadcare",
42-
dependencies: targetDependencies
42+
dependencies: targetDependencies,
43+
resources: [
44+
.process("PrivacyInfo.xcprivacy")
45+
]
4346
),
4447
.target(
4548
name: "UploadcareWidget",
46-
dependencies: ["Uploadcare"]
49+
dependencies: ["Uploadcare"],
50+
resources: [
51+
.process("PrivacyInfo.xcprivacy")
52+
]
4753
),
4854
.testTarget(
4955
name: "UploadcareTests",

Sources/Uploadcare/Constants.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal let RESTAPIHost = "api.uploadcare.com"
1919
/// Library name
2020
internal let libraryName = "UploadcareSwift"
2121
/// Library version
22-
internal let libraryVersion = "0.13.1"
22+
internal let libraryVersion = "0.14.0"
2323

2424
/// API version
2525
internal let APIVersion = "0.7"
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
</dict>
6+
</plist>

Sources/Uploadcare/Uploadcare.swift

+57
Original file line numberDiff line numberDiff line change
@@ -1775,6 +1775,63 @@ extension Uploadcare {
17751775
}
17761776
}
17771777

1778+
#if !os(Linux)
1779+
/// The method allows you to determine the document format and possible conversion formats.
1780+
///
1781+
/// Example:
1782+
/// ```swift
1783+
/// uploadcare.documentInfo("fileUUID") { result in
1784+
/// switch result {
1785+
/// case .failure(let error):
1786+
/// print(error)
1787+
/// case .success(let documentInfo):
1788+
/// print(documentInfo)
1789+
/// }
1790+
/// }
1791+
/// ```
1792+
///
1793+
/// - Parameters:
1794+
/// - uuid: File uuid.
1795+
/// - completionHandler: Completion handler.
1796+
public func documentInfo(
1797+
_ uuid: String,
1798+
_ completionHandler: @escaping (Result<DocumentInfo, RESTAPIError>) -> Void
1799+
) {
1800+
let url = urlWithPath("/convert/document/\(uuid)/")
1801+
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .get)
1802+
requestManager.signRequest(&urlRequest)
1803+
1804+
requestManager.performRequest(urlRequest) { (result: Result<DocumentInfo, Error>) in
1805+
switch result {
1806+
case .failure(let error): completionHandler(.failure(RESTAPIError.fromError(error)))
1807+
case .success(let response): completionHandler(.success(response))
1808+
}
1809+
}
1810+
}
1811+
#endif
1812+
1813+
/// The method allows you to determine the document format and possible conversion formats.
1814+
///
1815+
/// Example:
1816+
/// ```swift
1817+
/// let documentInfo = try await uploadcare.documentInfo("fileUUID")
1818+
/// ```
1819+
/// - Parameter uuid: File uuid.
1820+
/// - Returns: Document format and possible conversion formats.
1821+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
1822+
public func documentInfo(_ uuid: String) async throws -> DocumentInfo {
1823+
let url = urlWithPath("/convert/document/\(uuid)/")
1824+
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .get)
1825+
requestManager.signRequest(&urlRequest)
1826+
1827+
do {
1828+
let response: DocumentInfo = try await requestManager.performRequest(urlRequest)
1829+
return response
1830+
} catch {
1831+
throw RESTAPIError.fromError(error)
1832+
}
1833+
}
1834+
17781835
#if !os(Linux)
17791836
/// Uploadcare allows converting documents to the following target formats: DOC, DOCX, XLS, XLSX, ODT, ODS, RTF, TXT, PDF, JPG, PNG.
17801837
///

Sources/Uploadcare/Utils.swift

+2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ func getSwiftVersion() -> String {
202202
swiftVersion = "6.1"
203203
#elseif swift(>=6.0)
204204
swiftVersion = "6.0"
205+
#elseif swift(>=5.10)
206+
swiftVersion = "5.10"
205207
#elseif swift(>=5.9)
206208
swiftVersion = "5.9"
207209
#elseif swift(>=5.8)

0 commit comments

Comments
 (0)