-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathBetaTester.swift
More file actions
83 lines (70 loc) · 2.29 KB
/
Copy pathBetaTester.swift
File metadata and controls
83 lines (70 loc) · 2.29 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2020 Itty Bitty Apps Pty Ltd
import AppStoreConnect_Swift_SDK
import Combine
import Foundation
import FileSystem
import struct Model.BetaTester
import SwiftyTextTable
extension BetaTester {
init(_ output: GetBetaTesterOperation.Output) {
let attributes = output.betaTester.attributes
let relationships = output.betaTester.relationships
// Find tester related beta groups and apps in included data
let betaGroupsNames = relationships?.betaGroups?.data?
.compactMap { group -> [AppStoreConnect_Swift_SDK.BetaGroup]? in
output.betaGroups?.filter { $0.id == group.id }
}
.flatMap { $0.compactMap { $0.attributes?.name } }
let appsBundleIds = relationships?.apps?.data?
.compactMap { app -> [AppStoreConnect_Swift_SDK.App]? in
output.apps?.filter { app.id == $0.id }
}
.flatMap { $0.compactMap { $0.attributes?.bundleId } }
self.init(
email: attributes?.email,
firstName: attributes?.firstName,
lastName: attributes?.lastName,
inviteType: attributes?.inviteType?.rawValue,
betaGroups: betaGroupsNames,
apps: appsBundleIds
)
}
}
extension BetaTester: ResultRenderable, TableInfoProvider {
static func tableColumns() -> [TextTableColumn] {
return [
TextTableColumn(header: "Email"),
TextTableColumn(header: "First Name"),
TextTableColumn(header: "Last Name"),
TextTableColumn(header: "Invite Type"),
TextTableColumn(header: "Beta Groups"),
TextTableColumn(header: "Apps"),
]
}
var tableRow: [CustomStringConvertible] {
return [
email ?? "",
firstName ?? "",
lastName ?? "",
inviteType ?? "",
betaGroups?.joined(separator: ", ") ?? [],
apps?.joined(separator: ", ") ?? [],
]
}
}
extension FileSystem.BetaTester: SyncResourceProcessable {
var syncResultText: String {
email
}
var compareIdentity: String {
email
}
}
extension String: SyncResourceProcessable {
var syncResultText: String {
self
}
var compareIdentity: String {
self
}
}