Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.14.0 #131

Merged
merged 22 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ on:
jobs:
macos_build_and_test:
name: Build and test on latest macOS
runs-on: macos-latest
runs-on: macOS-latest

steps:
- name: Checkout
uses: actions/checkout@master

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

- name: Swift build for macOS
- name: Build for macOS
run: swift build -c release

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

ubuntu:
name: Build and test on latest Ubuntu
runs-on: ubuntu-latest
strategy:
matrix:
swift: [5.9, 5.6.3]
swift: [5.10, 5.6.3]

steps:
- name: Checkout
Expand Down
19 changes: 19 additions & 0 deletions Documentation/REST API.md
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,25 @@ uploadcare.deleteWebhook(forTargetUrl: url) { error in
}
```

## Document info ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion/operation/documentConvertInfo)) ##

The method allows you to determine the document format and possible conversion formats:

```swift
// Async:
let documentInfo = try await uploadcare.documentInfo("fileUUID")

// With a completion callback:
uploadcare.documentInfo("fileUUID") { result in
switch result {
case .failure(let error):
print(error)
case .success(let documentInfo):
print(documentInfo)
}
}
```

## Convert document ([API Reference](https://uploadcare.com/docs/transformations/document_conversion/#convert)) ##

You can convert multiple files with one request:
Expand Down
222 changes: 128 additions & 94 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,97 +1,131 @@
{
"object": {
"pins": [
{
"package": "async-http-client",
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
"state": {
"branch": null,
"revision": "78db67e5bf4a8543075787f228e8920097319281",
"version": "1.18.0"
}
},
{
"package": "swift-atomics",
"repositoryURL": "https://github.com/apple/swift-atomics.git",
"state": {
"branch": null,
"revision": "6c89474e62719ddcc1e9614989fff2f68208fe10",
"version": "1.1.0"
}
},
{
"package": "swift-collections",
"repositoryURL": "https://github.com/apple/swift-collections.git",
"state": {
"branch": null,
"revision": "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version": "1.0.4"
}
},
{
"package": "swift-crypto",
"repositoryURL": "https://github.com/apple/swift-crypto.git",
"state": {
"branch": null,
"revision": "60f13f60c4d093691934dc6cfdf5f508ada1f894",
"version": "2.6.0"
}
},
{
"package": "swift-log",
"repositoryURL": "https://github.com/apple/swift-log.git",
"state": {
"branch": null,
"revision": "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version": "1.5.3"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "cf281631ff10ec6111f2761052aa81896a83a007",
"version": "2.58.0"
}
},
{
"package": "swift-nio-extras",
"repositoryURL": "https://github.com/apple/swift-nio-extras.git",
"state": {
"branch": null,
"revision": "0e0d0aab665ff1a0659ce75ac003081f2b1c8997",
"version": "1.19.0"
}
},
{
"package": "swift-nio-http2",
"repositoryURL": "https://github.com/apple/swift-nio-http2.git",
"state": {
"branch": null,
"revision": "a8ccf13fa62775277a5d56844878c828bbb3be1a",
"version": "1.27.0"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
"state": {
"branch": null,
"revision": "320bd978cceb8e88c125dcbb774943a92f6286e9",
"version": "2.25.0"
}
},
{
"package": "swift-nio-transport-services",
"repositoryURL": "https://github.com/apple/swift-nio-transport-services.git",
"state": {
"branch": null,
"revision": "e7403c35ca6bb539a7ca353b91cc2d8ec0362d58",
"version": "1.19.0"
}
"pins" : [
{
"identity" : "async-http-client",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "a22083713ee90808d527d0baa290c2fb13ca3096",
"version" : "1.21.1"
}
]
},
"version": 1
},
{
"identity" : "swift-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-algorithms",
"state" : {
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
"version" : "1.2.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "bc1c29221f6dfeb0ebbfbc98eb95cd3d4967868e",
"version" : "3.4.0"
}
},
{
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "9bee2fdb79cc740081abd8ebd80738063d632286",
"version" : "1.1.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "359c461e5561d22c6334828806cc25d759ca7aa6",
"version" : "2.65.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "a3b640d7dc567225db7c94386a6e71aded1bfa63",
"version" : "1.22.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "c6afe04165c865faaa687b42c32ed76dfcc91076",
"version" : "1.31.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version" : "2.26.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "38ac8221dd20674682148d6451367f89c2652980",
"version" : "1.21.0"
}
},
{
"identity" : "swift-numerics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-numerics.git",
"state" : {
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "f9266c85189c2751589a50ea5aec72799797e471",
"version" : "1.3.0"
}
}
],
"version" : 2
}
10 changes: 8 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ let package = Package(
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Uploadcare",
dependencies: targetDependencies
dependencies: targetDependencies,
resources: [
.process("PrivacyInfo.xcprivacy")
]
),
.target(
name: "UploadcareWidget",
dependencies: ["Uploadcare"]
dependencies: ["Uploadcare"],
resources: [
.process("PrivacyInfo.xcprivacy")
]
),
.testTarget(
name: "UploadcareTests",
Expand Down
2 changes: 1 addition & 1 deletion Sources/Uploadcare/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal let RESTAPIHost = "api.uploadcare.com"
/// Library name
internal let libraryName = "UploadcareSwift"
/// Library version
internal let libraryVersion = "0.13.1"
internal let libraryVersion = "0.14.0"

/// API version
internal let APIVersion = "0.7"
6 changes: 6 additions & 0 deletions Sources/Uploadcare/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
57 changes: 57 additions & 0 deletions Sources/Uploadcare/Uploadcare.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,63 @@ extension Uploadcare {
}
}

#if !os(Linux)
/// The method allows you to determine the document format and possible conversion formats.
///
/// Example:
/// ```swift
/// uploadcare.documentInfo("fileUUID") { result in
/// switch result {
/// case .failure(let error):
/// print(error)
/// case .success(let documentInfo):
/// print(documentInfo)
/// }
/// }
/// ```
///
/// - Parameters:
/// - uuid: File uuid.
/// - completionHandler: Completion handler.
public func documentInfo(
_ uuid: String,
_ completionHandler: @escaping (Result<DocumentInfo, RESTAPIError>) -> Void
) {
let url = urlWithPath("/convert/document/\(uuid)/")
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .get)
requestManager.signRequest(&urlRequest)

requestManager.performRequest(urlRequest) { (result: Result<DocumentInfo, Error>) in
switch result {
case .failure(let error): completionHandler(.failure(RESTAPIError.fromError(error)))
case .success(let response): completionHandler(.success(response))
}
}
}
#endif

/// The method allows you to determine the document format and possible conversion formats.
///
/// Example:
/// ```swift
/// let documentInfo = try await uploadcare.documentInfo("fileUUID")
/// ```
/// - Parameter uuid: File uuid.
/// - Returns: Document format and possible conversion formats.
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public func documentInfo(_ uuid: String) async throws -> DocumentInfo {
let url = urlWithPath("/convert/document/\(uuid)/")
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .get)
requestManager.signRequest(&urlRequest)

do {
let response: DocumentInfo = try await requestManager.performRequest(urlRequest)
return response
} catch {
throw RESTAPIError.fromError(error)
}
makoni marked this conversation as resolved.
Show resolved Hide resolved
}

#if !os(Linux)
/// Uploadcare allows converting documents to the following target formats: DOC, DOCX, XLS, XLSX, ODT, ODS, RTF, TXT, PDF, JPG, PNG.
///
Expand Down
2 changes: 2 additions & 0 deletions Sources/Uploadcare/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ func getSwiftVersion() -> String {
swiftVersion = "6.1"
#elseif swift(>=6.0)
swiftVersion = "6.0"
#elseif swift(>=5.10)
swiftVersion = "5.10"
#elseif swift(>=5.9)
swiftVersion = "5.9"
#elseif swift(>=5.8)
Expand Down
Loading