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
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
82
83
84
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 82
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
33
34
35
36
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 33
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
43
44
45
46
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 43
def self.default_external_group(app_id: nil)
groups = self.all(app_id: app_id)
groups.find(&:default_external_group?)
end
|
.filter_groups(app_id: nil, &block) ⇒ Object
48
49
50
51
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 48
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
38
39
40
41
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 38
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
53
54
55
56
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 53
def self.internal_group(app_id: nil)
groups = self.all(app_id: app_id)
groups.find(&:internal_group?)
end
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 102
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
86
87
88
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 86
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
98
99
100
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 98
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 63
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
90
91
92
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 90
def default_external_group?
is_default_external_group
end
|
#internal_group? ⇒ Boolean
94
95
96
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 94
def internal_group?
is_internal_group
end
|
#remove_tester!(tester) ⇒ Object
78
79
80
|
# File 'spaceship/lib/spaceship/test_flight/group.rb', line 78
def remove_tester!(tester)
client.delete_tester_from_group(group_id: self.id, tester_id: tester.tester_id, app_id: self.app_id)
end
|