-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1237cb0
commit bedfb7a
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
Sources/OversizeAppStoreServices/Services/AppStoreVersionSubmissionsService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Copyright © 2024 Alexander Romanov | ||
// AppStoreVersionSubmissionsService.swift, created on 15.11.2024 | ||
// | ||
|
||
import AppStoreAPI | ||
import AppStoreConnect | ||
import Foundation | ||
import OversizeCore | ||
import OversizeModels | ||
|
||
public actor AppStoreVersionSubmissionsService { | ||
private let client: AppStoreConnectClient? | ||
|
||
public init() { | ||
do { | ||
client = try AppStoreConnectClient(authenticator: EnvAuthenticator()) | ||
} catch { | ||
client = nil | ||
} | ||
} | ||
|
||
public func postAppStoreVersionSubmission(appStoreVersionsId: String) async -> Result<String, AppError> { | ||
guard let client else { return .failure(.network(type: .unauthorized)) } | ||
|
||
let requestData: AppStoreVersionSubmissionCreateRequest.Data = .init( | ||
type: .appStoreVersionSubmissions, | ||
relationships: .init( | ||
appStoreVersion: .init( | ||
data: .init( | ||
type: .appStoreVersions, | ||
id: appStoreVersionsId | ||
) | ||
) | ||
) | ||
) | ||
|
||
let request = Resources.v1.appStoreVersionSubmissions.post(.init(data: requestData)) | ||
|
||
do { | ||
let data = try await client.send(request).data | ||
return .success(data.id) | ||
} catch { | ||
return .failure(.network(type: .noResponse)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters