Files
xtool-mirror/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swift
2024-11-17 03:09:06 -05:00

36 lines
1.2 KiB
Swift

//
// DeveloperServicesFetchProfileOperation.swift
// Supersign
//
// Created by Kabir Oberai on 13/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
import Superutils
public struct DeveloperServicesFetchProfileOperation: DeveloperServicesOperation {
public let context: SigningContext
public let appID: DeveloperServicesAppID
public init(context: SigningContext, appID: DeveloperServicesAppID) {
self.context = context
self.appID = appID
}
public func perform() async throws -> DeveloperServicesProfile {
let profiles = try await context.client.send(DeveloperServicesListProfilesRequest(
platform: context.platform, teamID: context.teamID
))
if let profile = profiles.first(where: { $0.appID.id == self.appID.id }) {
_ = try await context.client.send(DeveloperServicesDeleteProfileRequest(
platform: context.platform, teamID: context.teamID, profileID: profile.id
))
}
return try await context.client.send(DeveloperServicesGetProfileRequest(
platform: context.platform, teamID: context.teamID, appIDID: appID.id
))
}
}