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.12.0 #114

Merged
merged 336 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
336 commits
Select commit Hold shift + click to select a range
74fa4dc
allow setting signature from external source
ivantse Jul 20, 2022
bddd7c8
Merge branch 'develop' into direct-upload-signature
makoni Jul 21, 2022
a9b7bf3
Merge pull request #93 from ivantse/direct-upload-signature
makoni Jul 21, 2022
abf5ae9
lib version bump
makoni Jul 21, 2022
0787c27
Update README.md
makoni Jul 21, 2022
7d280a1
Update Upload API.md
makoni Jul 21, 2022
3354328
formatting
makoni Jul 21, 2022
5bd3bc0
Update Upload API.md
makoni Jul 22, 2022
bd72778
custom uploadSignature can be provided for methods:
makoni Jul 25, 2022
f988557
custom uploadSignature can be provided for main uploadFile method tha…
makoni Jul 25, 2022
f4242fd
custom uploadSignature can be provided for upload method of UploadedF…
makoni Jul 25, 2022
e6992c5
increase timeout for video conversion integration test
makoni Jul 25, 2022
22a83b8
documentation updated
makoni Jul 25, 2022
8e4af0d
Update Sources/Uploadcare/Uploadcare.swift
makoni Jul 26, 2022
c6ee9f4
Update README.md
makoni Jul 26, 2022
8c11cae
Update Documentation/Upload API.md
makoni Jul 26, 2022
f7c5472
Update README.md
makoni Aug 9, 2022
bfd73c8
Update README.md
makoni Aug 9, 2022
9927a58
Update README.md
makoni Aug 9, 2022
fffdff1
Update Upload API.md
makoni Aug 9, 2022
da207fa
Update README.md
makoni Aug 9, 2022
ae06db5
Update README.md
makoni Aug 9, 2022
4b95735
Update Upload API.md
makoni Aug 9, 2022
e56e82f
Update REST API.md
makoni Aug 9, 2022
4c1b7a2
Merge branch 'master' into develop
makoni Aug 9, 2022
0726209
Update Documentation/REST API.md
makoni Aug 10, 2022
c5a8aad
Update Documentation/REST API.md
makoni Aug 10, 2022
f9d8ed9
Update Documentation/Upload API.md
makoni Aug 10, 2022
3650c20
Update Documentation/Upload API.md
makoni Aug 10, 2022
0c58100
Update README.md
makoni Aug 10, 2022
ceff24e
Update README.md
makoni Aug 10, 2022
07479f4
Merge branch 'master' into develop
makoni Aug 16, 2022
d86cb76
fixed when storing behavour param was missing for direct upload request
makoni Aug 16, 2022
8ac7ace
version bump
makoni Aug 16, 2022
9f8f188
Merge branch 'master' into develop
makoni Aug 23, 2022
c3da982
removed deprecated files for tests
makoni Sep 5, 2022
f178f2a
Swift version 5.1 -> 5.6
makoni Sep 5, 2022
810d1df
removed unused allTests property in tests
makoni Sep 5, 2022
b912354
refactoring
makoni Sep 5, 2022
72f90bf
refactoring
makoni Sep 5, 2022
4b9c139
refactoring
makoni Sep 5, 2022
c21e7ad
bumped api version to 0.7
makoni Sep 5, 2022
ccdc3a6
- removed sorting by size for getting list of files method
makoni Sep 5, 2022
19aa149
removed rekognitionInfo from File model
makoni Sep 5, 2022
f42bcbd
removed imageInfo from File model
makoni Sep 5, 2022
186eeed
removed videoInfo from File model
makoni Sep 5, 2022
e637fd4
warning
makoni Sep 5, 2022
09985ed
metadata added to File model
makoni Sep 12, 2022
fb6c668
docs
makoni Sep 12, 2022
a9e7523
order
makoni Sep 12, 2022
78cbad1
Improvements for handling responses in RequestManager
makoni Sep 12, 2022
ff24d45
Added methods for REST API to get/update/delete File metadata
makoni Sep 12, 2022
55f6987
store group method is not available for REST API anymore
makoni Sep 12, 2022
d210ca2
use keyDecodingStrategy for decoders
makoni Sep 12, 2022
30b40fa
Revert "use keyDecodingStrategy for decoders"
makoni Sep 12, 2022
7076d44
added contentInfo property to File data model
makoni Sep 12, 2022
5ceff24
delete group method added for REST API
makoni Sep 14, 2022
1a933ef
models updated
makoni Sep 14, 2022
136c92e
added FileInfoQuery to set request query to include appdata
makoni Sep 14, 2022
73f7016
new models for AppData added
makoni Sep 14, 2022
f0214ed
refactoring
makoni Sep 14, 2022
59c4dd4
appData field added for File model
makoni Sep 15, 2022
14310e7
refactoring
makoni Sep 15, 2022
b45d4c5
execute AWS recognition method added
makoni Sep 15, 2022
18f09f6
added method to check aws recognition status
makoni Sep 15, 2022
022f34b
integration tests for aws recognition execution and and status check
makoni Sep 15, 2022
8a63957
Added execution of ClamAV addon, checking it’s status and integration…
makoni Sep 15, 2022
1c0d4a0
RemoveBGAddonExecutionParams model added
makoni Sep 15, 2022
c6167a8
remove.bg addon execution and status + refactoring
makoni Sep 15, 2022
047b762
integration tests for remove.bg addon methods
makoni Sep 15, 2022
04d03f1
Merge branch 'master' into develop
makoni Oct 12, 2022
0dc4f74
done field added to UploadedFile model
makoni Oct 12, 2022
1cf7a3f
added contentInfo file to UploadedFile model
makoni Oct 12, 2022
1cc6636
added metadata property to UploadedFile model
makoni Oct 12, 2022
80adbc3
bump lib version
makoni Oct 12, 2022
02b5b16
metadata can be provided for upload from url method
makoni Oct 12, 2022
c14e7d8
metadata can be provided for direct upload method
makoni Oct 12, 2022
2d16003
metadata can be provided for multipart uploads
makoni Oct 12, 2022
8197f6b
set swift version 5.5
makoni Oct 12, 2022
3ed9efc
demo app fixed
makoni Oct 12, 2022
c514531
updated project for carthage
makoni Oct 12, 2022
b3ec9f5
more swift versions
makoni Oct 12, 2022
b32d9a9
podfile updated
makoni Oct 13, 2022
406be8a
warning removed
makoni Oct 18, 2022
f343cdc
set lib version 0.9.0
makoni Oct 18, 2022
83190e9
metadata param for main upload method
makoni Oct 18, 2022
cd59fd0
pass metadata from UploadedFile when calling upload
makoni Oct 18, 2022
cd09620
added integratin test for multipart uploading if only public key prov…
makoni Oct 18, 2022
3ab3c9d
Update README.md
makoni Oct 18, 2022
76c57fc
Update REST API.md
makoni Oct 18, 2022
1e62f53
Update REST API.md
makoni Oct 18, 2022
18b589e
Update REST API.md
makoni Oct 18, 2022
ab48192
Update REST API.md
makoni Oct 18, 2022
662d9eb
Update Upload API.md
makoni Oct 18, 2022
4d73b41
Update README.md
makoni Oct 18, 2022
7504991
Update test.yml
makoni Oct 18, 2022
acb195a
Update REST API.md
makoni Oct 18, 2022
3f98be3
Update REST API.md
makoni Oct 19, 2022
5659131
Update Upload API.md
makoni Oct 19, 2022
eeb3a8f
Update REST API.md
makoni Oct 19, 2022
8a3dcfc
Update REST API.md
makoni Oct 19, 2022
b3fec25
couple links updated
makoni Oct 20, 2022
e28c4ef
test updated
makoni Nov 22, 2022
2daefa2
fixed parsing of UploadedFile model
makoni Nov 22, 2022
f86406b
added new integration test to upload a video file and check that pars…
makoni Nov 22, 2022
fea5153
version bump
makoni Nov 22, 2022
95b03ba
Merge branch 'master' into develop
makoni Nov 22, 2022
9b2fe63
spaces
makoni Nov 22, 2022
9170188
Merge branch 'master' into develop
makoni Jun 1, 2023
e602667
cleanup
makoni Jun 1, 2023
905df46
async tests file
makoni Jun 1, 2023
967a1e4
async version of getProjectInfo and test
makoni Jun 1, 2023
fbbf756
formatting
makoni Jun 1, 2023
e00700a
async getListOfWebhooks and test
makoni Jun 1, 2023
aad40ed
async performRequest
makoni Jun 1, 2023
2b207e2
async webhooks methods
makoni Jun 1, 2023
da1c847
refactoring
makoni Jun 1, 2023
784f384
refactoring
makoni Jun 1, 2023
5c208bc
async listOfGroups and groupInfo + tests
makoni Jun 2, 2023
44532a0
async list of files and tests
makoni Jun 2, 2023
93de08c
one more test
makoni Jun 2, 2023
8f46266
async pagination for list of files
makoni Jun 2, 2023
b1d472b
async fileinfo and test
makoni Jun 2, 2023
89c219e
error handling
makoni Jun 2, 2023
57c8f6f
refactoring
makoni Jun 2, 2023
b3815f7
refactoring
makoni Jun 2, 2023
4669a7c
async groups list and pagination + tests
makoni Jun 2, 2023
461947c
Equatable conformance
makoni Jun 2, 2023
45de91b
Equatable for Group and check results in test
makoni Jun 2, 2023
6fff213
async getAuthenticatedUrlFromUrl and test
makoni Jun 2, 2023
de2858b
UploadAPIIntegrationAsyncTests
makoni Jun 20, 2023
b7be718
async directUploadInForeground and test
makoni Jun 20, 2023
0db53c6
async deleteFile and test
makoni Jun 20, 2023
0f62932
async deleteFiles and test
makoni Jun 20, 2023
5ee9f7b
async storeFile and test
makoni Jun 20, 2023
7ab3fd8
async storeFiles and test
makoni Jun 20, 2023
24244e0
async copyFileToLocalStorage and test
makoni Jun 20, 2023
6170710
async copyFileToRemoteStorage and test
makoni Jun 20, 2023
5cd06d5
async convertDocuments, convertDocumentsWithSettings, documentConvers…
makoni Jun 20, 2023
0f2b830
async convertVideosWithSettings, convertVideos, videoConversionJobSta…
makoni Jun 21, 2023
6f4268d
makoni Jun 21, 2023
ca6f32e
async methods for metadata and test
makoni Jun 21, 2023
f3566bb
Async methods for AWS recognition and test
makoni Jun 21, 2023
1acb58d
Async methods for Clamav addon and test
makoni Jun 21, 2023
0112ae4
async methods for Remove.bg addon and tests
makoni Jun 21, 2023
5733db9
async deleteGroup method
makoni Jun 21, 2023
dc705bd
refactoring
makoni Jun 21, 2023
163cf89
async methods for upload from url and it’s status and test
makoni Jun 22, 2023
de619ba
warning fixed
makoni Jun 22, 2023
b6de372
async fileInfo and test
makoni Jun 22, 2023
05ee7af
updated unsplash link
makoni Jun 22, 2023
43badd0
tests refactoring
makoni Jun 22, 2023
30a372c
async multipart upload and test
makoni Jun 22, 2023
4047af3
test improved
makoni Jul 31, 2023
0b5d7f9
uploadSignature param for directUploadInForeground
makoni Jul 31, 2023
a65ebb3
async uploadFile method in Uploadcare class + test
makoni Jul 31, 2023
cbcc684
docs
makoni Jul 31, 2023
2fce855
async upload method for UploadedFile class and test
makoni Jul 31, 2023
57e6a14
test updated
makoni Jul 31, 2023
b0262ce
async methods to create groups + tests
makoni Jul 31, 2023
d91f589
tests renames
makoni Jul 31, 2023
441dc03
cleanup
makoni Jul 31, 2023
3b13fe0
tests annotation
makoni Jul 31, 2023
dab2fea
fixed build for tvOS
makoni Jul 31, 2023
dd32571
annotation
makoni Jul 31, 2023
8fa66eb
fixed build for watchOS
makoni Jul 31, 2023
cde06c8
tests are available for watchOS too
makoni Jul 31, 2023
9389b5c
makoni Jul 31, 2023
b37dbb3
documentation updated
makoni Aug 1, 2023
309a1ce
docs
makoni Aug 1, 2023
9a1843c
docs
makoni Aug 1, 2023
86f3d6c
docs
makoni Aug 1, 2023
38f6ce5
docs
makoni Aug 1, 2023
795e52c
docs
makoni Aug 1, 2023
a1a59ef
spaces
makoni Aug 2, 2023
c61b8c4
docs
makoni Aug 2, 2023
298736c
docs
makoni Aug 2, 2023
9f4cd71
docs
makoni Aug 2, 2023
7a3832b
docs
makoni Aug 2, 2023
ea6f5d2
docs
makoni Aug 2, 2023
34e95a6
docs
makoni Aug 2, 2023
8304b78
docs
makoni Aug 2, 2023
cd95a11
docs
makoni Aug 2, 2023
0f027ff
readme
makoni Aug 2, 2023
5816565
update semf
makoni Aug 2, 2023
e0552a9
demo app refactoring
makoni Aug 2, 2023
9731163
async
makoni Aug 2, 2023
1d273e7
refactoring
makoni Aug 2, 2023
745c7e7
more async methods
makoni Aug 2, 2023
a852d88
dead link
makoni Aug 2, 2023
bf16dae
more async
makoni Aug 2, 2023
1de345c
widget updated to fix a warning
makoni Aug 6, 2023
7014f04
use new AsyncImage in widget
makoni Aug 6, 2023
b80f0b9
warning fixed
makoni Aug 6, 2023
6d71fa5
cleanup
makoni Aug 6, 2023
1e1912e
async files load in demo app
makoni Aug 6, 2023
221d1c6
discardableResult
makoni Aug 6, 2023
cd85a86
async file delete in demo
makoni Aug 6, 2023
5e60514
demo app project updated
makoni Aug 6, 2023
bd8cb55
readme updated
makoni Aug 6, 2023
3107693
docs updated
makoni Aug 6, 2023
3b20d77
docs updated
makoni Aug 6, 2023
b64734b
test updated
makoni Aug 8, 2023
670ecab
docs with examples
makoni Aug 8, 2023
06d6d1a
docs
makoni Aug 8, 2023
8189107
docs
makoni Aug 8, 2023
f42f209
docs
makoni Aug 8, 2023
c720273
docs
makoni Aug 8, 2023
21c5049
REST API docs
makoni Aug 14, 2023
61b321e
docs
makoni Aug 14, 2023
02ebd8e
docs
makoni Aug 14, 2023
7b310b5
couple fixes
makoni Aug 14, 2023
5f9ca75
uploadAndWaitForCompletion method and test added
makoni Aug 14, 2023
041f978
docs
makoni Aug 14, 2023
44f793d
bump lib version
makoni Aug 14, 2023
3da6d25
podspec updated
makoni Aug 14, 2023
d4f4947
updated carthage project
makoni Aug 14, 2023
bc42ee0
Update README.md
makoni Aug 14, 2023
b3ae4f3
bump version to 0.10.0
makoni Aug 15, 2023
2ea95d9
podspec updated
makoni Aug 15, 2023
cfe19f3
Update test.yml
makoni Aug 15, 2023
f35f1df
Merge branch 'master' into develop
makoni Aug 15, 2023
89276bd
Merge branch 'master' into develop
makoni Aug 31, 2023
6d56b53
Linux support (#111)
makoni Sep 1, 2023
3729d12
version bump
makoni Sep 5, 2023
94285b3
Merge branch 'master' into develop
makoni Sep 22, 2023
f899dba
swift-crypto 3.0.0
makoni Sep 22, 2023
98c0879
marked audio property of ContentInfo as required
makoni Oct 2, 2023
5c35def
removed deprecated methods
makoni Oct 2, 2023
33fc0d7
Webhook model is updated
makoni Oct 2, 2023
022e631
version property updated for Webhook model
makoni Oct 2, 2023
69575c0
event param for create and update webhook methods
makoni Oct 2, 2023
faf8f8e
one more test
makoni Oct 2, 2023
b41b4ef
docs updated
makoni Oct 2, 2023
b9bc133
added saveInGroup param for convertDocuments methods
makoni Oct 2, 2023
a3b187f
fixed Carthage project
makoni Oct 2, 2023
499e209
added testing with Swift 5.9 on Ubuntu
makoni Oct 2, 2023
b9e5326
version bump
makoni Oct 2, 2023
05750c9
sources list updated in widget
makoni Oct 2, 2023
f78e242
menu UI fixed
makoni Oct 2, 2023
858b2b8
tests updated
makoni Oct 3, 2023
3d92a24
widget refactoring
makoni Oct 3, 2023
237bf08
widget cookie fix
makoni Oct 3, 2023
244ac19
async getSourceChunk
makoni Oct 3, 2023
cb053f5
async loadMore
makoni Oct 3, 2023
ca2e924
async uploadFileFromPath
makoni Oct 3, 2023
2b72e39
smaller list of sources
makoni Oct 3, 2023
fd32812
run tests on Ubuntu for minimum and maximum supported Swift versions …
makoni Oct 3, 2023
02aab02
formatting
makoni Oct 3, 2023
78ddb08
added back OneDrive external source for widget
makoni Oct 3, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
swift: [5.8.1, 5.7.3, 5.6.3]
swift: [5.9, 5.6.3]

steps:
- name: Checkout
Expand Down
57 changes: 33 additions & 24 deletions Demo/Demo/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ struct MainView: View {
@State private var messageText: String = ""

@State var isUploading: Bool = false


private let sources: [SocialSource] = [
SocialSource(source: .facebook),
SocialSource(source: .gdrive),
SocialSource(source: .gphotos),
SocialSource(source: .dropbox),
SocialSource(source: .instagram),
SocialSource(source: .onedrive)
]

var body: some View {
NavigationView {
ZStack {
Expand All @@ -42,34 +51,13 @@ struct MainView: View {
.navigationBarTitle(Text("Uploadcare demo"), displayMode: .automatic)
.sheet(isPresented: self.$widgetVisible, content: {
NavigationView {
SelectSourceView(publicKey: publicKey)
SelectSourceView(publicKey: publicKey, sources: sources)
.navigationBarItems(trailing: Button("Close") {
self.widgetVisible = false
})
.environmentObject(api)
}
})

.actionSheet(isPresented: $isShowingAddFilesAlert, content: {
ActionSheet(
title: Text("Select source"),
message: Text(""),
buttons: [
.default(Text("Photos"), action: {
self.pickerType = .photos
self.isShowingSheetWithPicker.toggle()
}),
.default(Text("Files"), action: {
self.pickerType = .files
self.isShowingSheetWithPicker.toggle()
}),
.default(Text("External Sources"), action: {
self.widgetVisible = true
}),
.cancel()
]
)
})
.sheet(isPresented: $isShowingSheetWithPicker) {
if self.pickerType == .photos {
ImagePicker(sourceType: .photoLibrary) { (imageUrl) in
Expand Down Expand Up @@ -144,7 +132,28 @@ struct MainView: View {
self.filesListStore.uploadcare = self.api.uploadcare
}
self.isShowingAddFilesAlert.toggle()
}.buttonStyle(NeumorphicButtonStyle(bgColor: Color.gray.opacity(0.05)))
}
.buttonStyle(NeumorphicButtonStyle(bgColor: Color.gray.opacity(0.05)))
.actionSheet(isPresented: $isShowingAddFilesAlert, content: {
ActionSheet(
title: Text("Select source"),
message: Text(""),
buttons: [
.default(Text("Photos"), action: {
self.pickerType = .photos
self.isShowingSheetWithPicker.toggle()
}),
.default(Text("Files"), action: {
self.pickerType = .files
self.isShowingSheetWithPicker.toggle()
}),
.default(Text("External Sources"), action: {
self.widgetVisible = true
}),
.cancel()
]
)
})
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Documentation/REST API.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,10 @@ Create and subscribe to a webhook. You can use webhooks to receive notifications
let url = URL(string: "https://yourwebhook.com")!

// Async:
let webhook = try await uploadcare.createWebhook(targetUrl: url, isActive: true, signingSecret: "someSigningSecret")
let webhook = try await uploadcare.createWebhook(targetUrl: url, event: .fileUploaded, isActive: true, signingSecret: "someSigningSecret")

// With a completion callback:
uploadcare.createWebhook(targetUrl: url, isActive: true, signingSecret: "someSigningSecret") { result in
uploadcare.createWebhook(targetUrl: url, event: .fileUploaded, isActive: true, signingSecret: "someSigningSecret") { result in
switch result {
case .failure(let error):
print(error)
Expand All @@ -537,10 +537,10 @@ let url = URL(string: "https://yourwebhook.com")!
let webhookId = 100

// Async:
let webhook = try await uploadcare.updateWebhook(id: webhookId, targetUrl: url, isActive: false, signingSecret: "someNewSigningSecret")
let webhook = try await uploadcare.updateWebhook(id: webhookId, targetUrl: url, event: .fileInfoUpdated, isActive: false, signingSecret: "someNewSigningSecret")

// With a completion callback:
uploadcare.updateWebhook(id: webhookId, targetUrl: url, isActive: true, signingSecret: "someNewSigningSecret") { result in
uploadcare.updateWebhook(id: webhookId, targetUrl: url, event: .fileInfoUpdated, isActive: true, signingSecret: "someNewSigningSecret") { result in
switch result {
case .failure(let error):
print(error)
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
#if os(Linux)
let dependencies: [PackageDescription.Package.Dependency] = [
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.18.0"),
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "3.0.0")
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0")
]
let targetDependencies: [PackageDescription.Target.Dependency] = [
.product(name: "AsyncHTTPClient", package: "async-http-client"),
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.11.0"
internal let libraryVersion = "0.12.0"

/// API version
internal let APIVersion = "0.7"
59 changes: 39 additions & 20 deletions Sources/Uploadcare/Uploadcare.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1545,10 +1545,10 @@ extension Uploadcare {
}
}

private func createWebhookRequestBody(targetUrl: URL, isActive: Bool, signingSecret: String? = nil) throws -> Data {
private func createWebhookRequestBody(targetUrl: URL, event: Webhook.Event, isActive: Bool, signingSecret: String? = nil) throws -> Data {
var bodyDictionary = [
"target_url": targetUrl.absoluteString,
"event": "file.uploaded", // Presently, we only support the file.uploaded event.
"event": event.rawValue,
"is_active": "\(isActive)"
]

Expand All @@ -1564,7 +1564,7 @@ extension Uploadcare {
/// Example:
/// ```swift
/// let url = URL(string: "https://yourwebhook.com")!
/// uploadcare.createWebhook(targetUrl: url, isActive: true, signingSecret: "someSigningSecret") { result in
/// uploadcare.createWebhook(targetUrl: url, event: .fileUploaded, isActive: true, signingSecret: "someSigningSecret") { result in
/// switch result {
/// case .failure(let error):
/// print(error)
Expand All @@ -1576,15 +1576,16 @@ extension Uploadcare {
///
/// - Parameters:
/// - targetUrl: An URL that is triggered by an event, for example, a file upload. A target URL MUST be unique for each project — event type combination.
/// - event: An event you subscribe to.
/// - isActive: Marks a subscription as either active or not, defaults to true, otherwise false.
/// - signingSecret: Optional secret that, if set, will be used to calculate signatures for the webhook payloads.
/// - completionHandler: Completion handler.
#if !os(Linux)
public func createWebhook(targetUrl: URL, isActive: Bool, signingSecret: String? = nil, _ completionHandler: @escaping (Result<Webhook, RESTAPIError>) -> Void) {
public func createWebhook(targetUrl: URL, event: Webhook.Event = .fileUploaded, isActive: Bool, signingSecret: String? = nil, _ completionHandler: @escaping (Result<Webhook, RESTAPIError>) -> Void) {
let url = urlWithPath("/webhooks/")
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .post)
do {
urlRequest.httpBody = try createWebhookRequestBody(targetUrl: targetUrl, isActive: isActive, signingSecret: signingSecret)
urlRequest.httpBody = try createWebhookRequestBody(targetUrl: targetUrl, event: event, isActive: isActive, signingSecret: signingSecret)
} catch let error {
DLog(error.localizedDescription)
}
Expand Down Expand Up @@ -1614,14 +1615,15 @@ extension Uploadcare {
///
/// - Parameters:
/// - targetUrl: An URL that is triggered by an event, for example, a file upload. A target URL MUST be unique for each project — event type combination.
/// - event: An event you subscribe to.
/// - isActive: Marks a subscription as either active or not, defaults to true, otherwise false.
/// - signingSecret: Optional secret that, if set, will be used to calculate signatures for the webhook payloads
/// - Returns: Created webhook.
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public func createWebhook(targetUrl: URL, isActive: Bool, signingSecret: String? = nil) async throws -> Webhook {
public func createWebhook(targetUrl: URL, event: Webhook.Event = .fileUploaded, isActive: Bool, signingSecret: String? = nil) async throws -> Webhook {
let url = urlWithPath("/webhooks/")
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .post)
urlRequest.httpBody = try createWebhookRequestBody(targetUrl: targetUrl, isActive: isActive, signingSecret: signingSecret)
urlRequest.httpBody = try createWebhookRequestBody(targetUrl: targetUrl, event: event, isActive: isActive, signingSecret: signingSecret)
requestManager.signRequest(&urlRequest)

do {
Expand All @@ -1638,7 +1640,7 @@ extension Uploadcare {
/// ```swift
/// let url = URL(string: "https://yourwebhook.com")!
/// let webhookId = 100
/// uploadcare.updateWebhook(id: webhookId, targetUrl: url, isActive: true, signingSecret: "someNewSigningSecret") { result in
/// uploadcare.updateWebhook(id: webhookId, targetUrl: url, event: .fileInfoUpdated, isActive: true, signingSecret: "someNewSigningSecret") { result in
/// switch result {
/// case .failure(let error):
/// print(error)
Expand All @@ -1651,15 +1653,16 @@ extension Uploadcare {
/// - Parameters:
/// - id: Webhook ID.
/// - targetUrl: Where webhook data will be posted.
/// - event: An event you subscribe to.
/// - isActive: Marks a subscription as either active or not.
/// - signingSecret: Optional secret that, if set, will be used to calculate signatures for the webhook payloads.
/// - completionHandler: Completion handler.
#if !os(Linux)
public func updateWebhook(id: Int, targetUrl: URL, isActive: Bool, signingSecret: String? = nil, _ completionHandler: @escaping (Result<Webhook, RESTAPIError>) -> Void) {
public func updateWebhook(id: Int, targetUrl: URL, event: Webhook.Event = .fileUploaded, isActive: Bool, signingSecret: String? = nil, _ completionHandler: @escaping (Result<Webhook, RESTAPIError>) -> Void) {
let url = urlWithPath("/webhooks/\(id)/")
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .put)
do {
urlRequest.httpBody = try createWebhookRequestBody(targetUrl: targetUrl, isActive: isActive, signingSecret: signingSecret)
urlRequest.httpBody = try createWebhookRequestBody(targetUrl: targetUrl, event: event, isActive: isActive, signingSecret: signingSecret)
} catch let error {
DLog(error.localizedDescription)
}
Expand All @@ -1683,6 +1686,7 @@ extension Uploadcare {
/// let webhook = try await uploadcare.updateWebhook(
/// id: webhookId,
/// targetUrl: url,
/// event: .fileInfoUpdated,
/// isActive: false,
/// signingSecret: "someNewSigningSecret"
/// )
Expand All @@ -1691,14 +1695,15 @@ extension Uploadcare {
/// - Parameters:
/// - id: Webhook ID
/// - targetUrl: Where webhook data will be posted.
/// - event: An event you subscribe to.
/// - isActive: Marks a subscription as either active or not.
/// - signingSecret: Optional secret that, if set, will be used to calculate signatures for the webhook payloads.
/// - Returns: Updated webhook.
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public func updateWebhook(id: Int, targetUrl: URL, isActive: Bool, signingSecret: String? = nil) async throws -> Webhook {
public func updateWebhook(id: Int, targetUrl: URL, event: Webhook.Event = .fileUploaded, isActive: Bool, signingSecret: String? = nil) async throws -> Webhook {
let url = urlWithPath("/webhooks/\(id)/")
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .put)
urlRequest.httpBody = try createWebhookRequestBody(targetUrl: targetUrl, isActive: isActive, signingSecret: signingSecret)
urlRequest.httpBody = try createWebhookRequestBody(targetUrl: targetUrl, event: event, isActive: isActive, signingSecret: signingSecret)
requestManager.signRequest(&urlRequest)

do {
Expand Down Expand Up @@ -1794,15 +1799,21 @@ extension Uploadcare {
public func convertDocuments(
_ paths: [String],
store: StoringBehavior? = nil,
saveInGroup: Bool? = nil,
_ completionHandler: @escaping (Result<ConvertDocumentsResponse, RESTAPIError>) -> Void
) {
let url = urlWithPath("/convert/document/")
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .post)

let storeValue = store == StoringBehavior.auto ? .store : store
var saveInGroupValue: String? = nil
if let saveInGroup {
saveInGroupValue = saveInGroup ? "true" : "false"
}
let requestData = ConvertRequestData(
paths: paths,
store: storeValue?.rawValue ?? StoringBehavior.store.rawValue
store: storeValue?.rawValue ?? StoringBehavior.store.rawValue,
saveInGroup: saveInGroupValue
)

urlRequest.httpBody = try? JSONEncoder().encode(requestData)
Expand Down Expand Up @@ -1832,14 +1843,19 @@ extension Uploadcare {
/// - store: A flag indicating if we should store your outputs.
/// - Returns: Operation response.
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public func convertDocuments(_ paths: [String], store: StoringBehavior? = nil) async throws -> ConvertDocumentsResponse {
public func convertDocuments(_ paths: [String], store: StoringBehavior? = nil, saveInGroup: Bool? = nil) async throws -> ConvertDocumentsResponse {
let url = urlWithPath("/convert/document/")
var urlRequest = requestManager.makeUrlRequest(fromURL: url, method: .post)

let storeValue = store == StoringBehavior.auto ? .store : store
var saveInGroupValue: String? = nil
if let saveInGroup {
saveInGroupValue = saveInGroup ? "true" : "false"
}
let requestData = ConvertRequestData(
paths: paths,
store: storeValue?.rawValue ?? StoringBehavior.store.rawValue
store: storeValue?.rawValue ?? StoringBehavior.store.rawValue,
saveInGroup: saveInGroupValue
)

urlRequest.httpBody = try? JSONEncoder().encode(requestData)
Expand Down Expand Up @@ -1881,11 +1897,12 @@ extension Uploadcare {
public func convertDocumentsWithSettings(
_ tasks: [DocumentConversionJobSettings],
store: StoringBehavior? = nil,
saveInGroup: Bool? = nil,
_ completionHandler: @escaping (Result<ConvertDocumentsResponse, RESTAPIError>) -> Void
) {
var paths = [String]()
tasks.forEach({ paths.append($0.stringValue) })
convertDocuments(paths, store: store, completionHandler)
convertDocuments(paths, store: store, saveInGroup: saveInGroup, completionHandler)
}
#endif

Expand Down Expand Up @@ -1914,10 +1931,10 @@ extension Uploadcare {
/// - store: A flag indicating if we should store your outputs.
/// - Returns: Operation response.
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public func convertDocumentsWithSettings(_ tasks: [DocumentConversionJobSettings], store: StoringBehavior? = nil) async throws -> ConvertDocumentsResponse {
public func convertDocumentsWithSettings(_ tasks: [DocumentConversionJobSettings], store: StoringBehavior? = nil, saveInGroup: Bool? = nil) async throws -> ConvertDocumentsResponse {
var paths = [String]()
tasks.forEach({ paths.append($0.stringValue) })
return try await convertDocuments(paths, store: store)
return try await convertDocuments(paths, store: store, saveInGroup: saveInGroup)
}

/// Document conversion job status.
Expand Down Expand Up @@ -2096,7 +2113,8 @@ extension Uploadcare {
let storeValue = store == StoringBehavior.auto ? .store : store
let requestData = ConvertRequestData(
paths: paths,
store: storeValue?.rawValue ?? StoringBehavior.store.rawValue
store: storeValue?.rawValue ?? StoringBehavior.store.rawValue,
saveInGroup: nil
)

urlRequest.httpBody = try? JSONEncoder().encode(requestData)
Expand Down Expand Up @@ -2136,7 +2154,8 @@ extension Uploadcare {
let storeValue = store == StoringBehavior.auto ? .store : store
let requestData = ConvertRequestData(
paths: paths,
store: storeValue?.rawValue ?? StoringBehavior.store.rawValue
store: storeValue?.rawValue ?? StoringBehavior.store.rawValue,
saveInGroup: nil
)

urlRequest.httpBody = try? JSONEncoder().encode(requestData)
Expand Down
Loading