Class: Spaceship::TestFlight::Group
- Inherits:
-
Base
- Object
- Base
- Base
- Spaceship::TestFlight::Group
show all
- Defined in:
- spaceship/lib/spaceship/test_flight/group.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#client, #raw_data
Class Method Summary
collapse
-
.add_tester_to_groups!(tester: nil, app: nil, groups: nil) ⇒ Object
-
.all(app_id: nil) ⇒ Object
-
.create!(app_id: nil, group_name: nil) ⇒ Object
-
.default_external_group(app_id: nil) ⇒ Object
-
.delete!(app_id: nil, group_name: nil) ⇒ Object
-
.filter_groups(app_id: nil, &block) ⇒ Object
-
.find(app_id: nil, group_name: nil) ⇒ Object
-
.internal_group(app_id: nil) ⇒ Object
-
.perform_for_groups_in_app(app: nil, groups: nil, &block) ⇒ Object
-
.remove_tester_from_groups!(tester: nil, app: nil, groups: nil) ⇒ Object
Instance Method Summary
collapse
Methods inherited from Base
client, inherited, #to_json
Methods inherited from Base
attr_accessor, attr_mapping, attributes, #attributes, factory, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
13
14
15
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 13
def app_id
@app_id
end
|
#created ⇒ Object
Returns the value of attribute created.
11
12
13
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 11
def created
@created
end
|
#id ⇒ Object
Returns the value of attribute id.
5
6
7
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 5
def id
@id
end
|
#is_active ⇒ Object
Returns the value of attribute is_active.
10
11
12
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 10
def is_active
@is_active
end
|
#is_default_external_group ⇒ Object
Returns the value of attribute is_default_external_group.
7
8
9
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 7
def is_default_external_group
@is_default_external_group
end
|
#is_internal_group ⇒ Object
Returns the value of attribute is_internal_group.
8
9
10
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 8
def is_internal_group
@is_internal_group
end
|
#name ⇒ Object
Returns the value of attribute name.
6
7
8
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 6
def name
@name
end
|
#provider_id ⇒ Object
Returns the value of attribute provider_id.
9
10
11
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 9
def provider_id
@provider_id
end
|
Class Method Details
.add_tester_to_groups!(tester: nil, app: nil, groups: nil) ⇒ Object
87
88
89
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 87
def self.add_tester_to_groups!(tester: nil, app: nil, groups: nil)
self.perform_for_groups_in_app(app: app, groups: groups) { |group| group.add_tester!(tester) }
end
|
.all(app_id: nil) ⇒ Object
38
39
40
41
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 38
def self.all(app_id: nil)
groups = client.get_groups(app_id: app_id)
groups.map { |g| self.new(g) }
end
|
.create!(app_id: nil, group_name: nil) ⇒ Object
26
27
28
29
30
31
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 26
def self.create!(app_id: nil, group_name: nil)
group = self.find(app_id: app_id, group_name: group_name)
return group unless group.nil?
data = client.create_group_for_app(app_id: app_id, group_name: group_name)
self.new(data)
end
|
.default_external_group(app_id: nil) ⇒ Object
48
49
50
51
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 48
def self.default_external_group(app_id: nil)
groups = self.all(app_id: app_id)
groups.find(&:default_external_group?)
end
|
.delete!(app_id: nil, group_name: nil) ⇒ Object
33
34
35
36
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 33
def self.delete!(app_id: nil, group_name: nil)
group = self.find(app_id: app_id, group_name: group_name)
client.delete_group_for_app(app_id: app_id, group_id: group.id)
end
|
.filter_groups(app_id: nil, &block) ⇒ Object
53
54
55
56
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 53
def self.filter_groups(app_id: nil, &block)
groups = self.all(app_id: app_id)
groups.select(&block)
end
|
.find(app_id: nil, group_name: nil) ⇒ Object
43
44
45
46
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 43
def self.find(app_id: nil, group_name: nil)
groups = self.all(app_id: app_id)
groups.find { |g| g.name == group_name }
end
|
.internal_group(app_id: nil) ⇒ Object
58
59
60
61
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 58
def self.internal_group(app_id: nil)
groups = self.all(app_id: app_id)
groups.find(&:internal_group?)
end
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 107
def self.perform_for_groups_in_app(app: nil, groups: nil, &block)
if groups.nil?
default_external_group = app.default_external_group
if default_external_group.nil?
raise "The app #{app.name} does not have a default external group. Please make sure to pass group names to the `:groups` option."
end
test_flight_groups = [default_external_group]
else
test_flight_groups = self.filter_groups(app_id: app.apple_id) do |group|
groups.include?(group.name)
end
raise "There are no groups available matching the names passed to the `:groups` option." if test_flight_groups.empty?
end
test_flight_groups.each(&block)
end
|
.remove_tester_from_groups!(tester: nil, app: nil, groups: nil) ⇒ Object
91
92
93
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 91
def self.remove_tester_from_groups!(tester: nil, app: nil, groups: nil)
self.perform_for_groups_in_app(app: app, groups: groups) { |group| group.remove_tester!(tester) }
end
|
Instance Method Details
#active? ⇒ Boolean
103
104
105
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 103
def active?
is_active
end
|
#add_tester!(tester) ⇒ Object
First we need to add the tester to the app It’s ok if the tester already exists, we just have to do this… don’t ask This will enable testing for the tester for a given app, as just creating the tester on an account-level is not enough to add the tester to a group. If this isn’t done the next request would fail. This is a bug we reported to the iTunes Connect team, as it also happens on the iTunes Connect UI on 18. April 2017
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 68
def add_tester!(tester)
client.create_app_level_tester(app_id: self.app_id,
first_name: tester.first_name,
last_name: tester.last_name,
email: tester.email)
client.post_tester_to_group(group_id: self.id,
email: tester.email,
first_name: tester.first_name,
last_name: tester.last_name,
app_id: self.app_id)
end
|
#default_external_group? ⇒ Boolean
95
96
97
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 95
def default_external_group?
is_default_external_group
end
|
#internal_group? ⇒ Boolean
99
100
101
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 99
def internal_group?
is_internal_group
end
|
#remove_tester!(tester) ⇒ Object
83
84
85
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 83
def remove_tester!(tester)
client.delete_tester_from_group(group_id: self.id, tester_id: tester.tester_id, app_id: self.app_id)
end
|