-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathRemoveTesterOperation.swift
More file actions
42 lines (33 loc) · 1.33 KB
/
RemoveTesterOperation.swift
File metadata and controls
42 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2020 Itty Bitty Apps Pty Ltd
import AppStoreConnect_Swift_SDK
import Combine
import Foundation
struct RemoveTesterOperation: APIOperation {
struct Options {
enum RemoveStrategy {
case removeTestersFromGroup(testerIds: [String], groupId: String)
case removeTesterFromGroups(testerId: String, groupIds: [String])
case removeTesterFromApps(testerId: String, appIds: [String])
}
let removeStrategy: RemoveStrategy
}
private let options: Options
var endpoint: APIEndpoint<Void> {
switch options.removeStrategy {
case .removeTesterFromGroups(let testerId, let groupIds):
return APIEndpoint.remove(betaTesterWithId: testerId, fromBetaGroupsWithIds: groupIds)
case .removeTestersFromGroup(let testerIds, let groupId):
return APIEndpoint.remove(betaTestersWithIds: testerIds, fromBetaGroupWithId: groupId)
case .removeTesterFromApps(let testerId, let appIds):
return APIEndpoint.remove(accessOfBetaTesterWithId: testerId, toAppsWithIds: appIds)
}
}
init(options: Options) {
self.options = options
}
func execute(with requestor: EndpointRequestor) -> AnyPublisher<Void, Error> {
requestor
.request(endpoint)
.eraseToAnyPublisher()
}
}