Class: Pilot::TesterManager
Instance Attribute Summary
Attributes inherited from Manager
#config
Instance Method Summary
collapse
Methods inherited from Manager
#app, #fetch_app_id, #fetch_app_identifier, #fetch_app_platform, #login, #start
Instance Method Details
#add_tester(options) ⇒ Object
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
|
# File 'pilot/lib/pilot/tester_manager.rb', line 8
def add_tester(options)
start(options)
app = find_app(app_filter: config[:apple_id] || config[:app_identifier])
UI.user_error!("You must provide either a Apple ID for the app (with the `:apple_id` option) or app identifier (with the `:app_identifier` option)") unless app
groups_param = config[:groups]
UI.user_error!("You must provide 1 or more groups (with the `:groups` option)") unless groups_param
tester = find_app_tester(email: config[:email], app: app)
tester ||= create_tester(
email: config[:email],
first_name: config[:first_name],
last_name: config[:last_name],
app: app
)
begin
groups = Spaceship::TestFlight::Group.add_tester_to_groups!(tester: tester, app: app, groups: config[:groups])
group_names = groups.map(&:name).join(", ")
UI.success("Successfully added tester to group(s): #{group_names} in app: #{app.name}")
rescue => ex
UI.error("Could not add #{tester.email} to app: #{app.name}")
raise ex
end
end
|
#find_tester(options) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'pilot/lib/pilot/tester_manager.rb', line 34
def find_tester(options)
start(options)
app_filter = (config[:apple_id] || config[:app_identifier])
app = find_app(app_filter: app_filter)
tester = find_app_tester(email: config[:email], app: app)
UI.user_error!("Tester #{config[:email]} not found") unless tester
describe_tester(tester)
return tester
end
|
#list_testers(options) ⇒ Object
87
88
89
90
91
92
93
94
95
96
|
# File 'pilot/lib/pilot/tester_manager.rb', line 87
def list_testers(options)
start(options)
app_filter = (config[:apple_id] || config[:app_identifier])
if app_filter
list_testers_by_app(app_filter)
else
UI.user_error!("You must include an `app_identifier` to `list_testers`")
end
end
|
#remove_tester(options) ⇒ Object
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
84
85
|
# File 'pilot/lib/pilot/tester_manager.rb', line 47
def remove_tester(options)
start(options)
app_filter = (config[:apple_id] || config[:app_identifier])
app = find_app(app_filter: app_filter)
tester = find_app_tester(email: config[:email], app: app)
UI.user_error!("Tester #{config[:email]} not found") unless tester
unless app
tester.delete!
UI.success("Successfully removed tester #{tester.email} from Users and Roles")
return
end
begin
if config[:groups].nil?
test_flight_testers = Spaceship::TestFlight::Tester.search(app_id: app.apple_id, text: tester.email, is_email_exact_match: true)
if test_flight_testers.length > 1
UI.user_error!("Could not remove #{tester.email} from app: #{app.name}, reason: too many matches: #{test_flight_testers}")
elsif test_flight_testers.length == 0
UI.user_error!("Could not remove #{tester.email} from app: #{app.name}, reason: unable to find tester on app")
end
test_flight_tester = test_flight_testers.first
test_flight_tester.remove_from_app!(app_id: app.apple_id)
UI.success("Successfully removed tester, #{test_flight_tester.email}, from app: #{app.name}")
else
groups = Spaceship::TestFlight::Group.remove_tester_from_groups!(tester: tester, app: app, groups: config[:groups])
group_names = groups.map(&:name).join(", ")
UI.success("Successfully removed tester #{tester.email} from app #{app.name} in group(s) #{group_names}")
end
rescue => ex
UI.error("Could not remove #{tester.email} from app: #{ex}")
raise ex
end
end
|