Skip to content

Commit

Permalink
Add app submit
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Nov 15, 2024
1 parent 1237cb0 commit bedfb7a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sources/OversizeAppStoreServices/ServiceRegistering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ public extension Container {
var appCategoryService: Factory<AppCategoryService> {
self { AppCategoryService() }
}

var appStoreVersionSubmissionsService: Factory<AppStoreVersionSubmissionsService> {
self { AppStoreVersionSubmissionsService() }
}
}
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))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public actor BuildsService {
let data = try await client.send(request).data
return .success(.init(schema: data))
} catch {
return .failure(.network(type: .noResponse))
return .success(nil)
}
}

Expand Down

0 comments on commit bedfb7a

Please sign in to comment.