spaceship/lib/spaceship/test_flight/client.rb in fastlane-2.65.0.beta.20171117010003 vs spaceship/lib/spaceship/test_flight/client.rb in fastlane-2.65.0.beta.20171118010003
- old
+ new
@@ -22,14 +22,15 @@
# Returns an array of all available build trains (not the builds they include)
def get_build_trains(app_id: nil, platform: "ios")
assert_required_params(__method__, binding)
response = request(:get, "providers/#{team_id}/apps/#{app_id}/platforms/#{platform}/trains")
+
handle_response(response)
end
- def get_builds_for_train(app_id: nil, platform: "ios", train_version: nil, retry_count: 0)
+ def get_builds_for_train(app_id: nil, platform: "ios", train_version: nil, retry_count: 3)
assert_required_params(__method__, binding)
with_retry(retry_count) do
response = request(:get, "providers/#{team_id}/apps/#{app_id}/platforms/#{platform}/trains/#{train_version}/builds", nil, {}, true)
handle_response(response)
end
@@ -103,10 +104,48 @@
req.headers['Content-Type'] = 'application/json'
end
handle_response(response)
end
+ # Returns a list of available testing groups
+ # e.g.
+ # {"b6f65dbd-c845-4d91-bc39-0b661d608970" => "Boarding",
+ # "70402368-9deb-409f-9a26-bb3f215dfee3" => "Automatic"}
+ def groups(app_id)
+ return @cached_groups if @cached_groups
+
+ r = request(:get, "/testflight/v2/providers/#{self.provider.provider_id}/apps/#{app_id}/groups")
+ @cached_groups = parse_response(r, 'data')
+ end
+
+ #####################################################
+ # @!group Testers
+ #####################################################
+ def testers(tester)
+ url = tester.url[:index]
+ r = request(:get, url)
+ parse_response(r, 'data')['users']
+ end
+
+ def testers_by_app(tester, app_id, group_id: nil)
+ if group_id.nil?
+ group_ids = groups(app_id).map do |group|
+ group['id']
+ end
+ end
+ group_ids ||= [group_id]
+ testers = []
+
+ group_ids.each do |json_group_id|
+ url = tester.url(app_id, self.provider.provider_id, json_group_id)[:index_by_app]
+ r = request(:get, url)
+ testers += parse_response(r, 'data')['users']
+ end
+
+ testers
+ end
+
##
# @!group Testers API
##
def testers_for_app(app_id: nil)
@@ -162,22 +201,23 @@
req.headers['Content-Type'] = 'application/json'
end
handle_response(response)
end
- def put_tester_to_group(app_id: nil, tester_id: nil, group_id: nil)
+ def post_tester_to_group(app_id: nil, email: nil, first_name: nil, last_name: nil, group_id: nil)
assert_required_params(__method__, binding)
# Then we can add the tester to the group that allows the app to test
# This is easy enough, we already have all this data. We don't need any response from the previous request
- url = "providers/#{team_id}/apps/#{app_id}/groups/#{group_id}/testers/#{tester_id}"
- response = request(:put) do |req|
+ url = "providers/#{team_id}/apps/#{app_id}/groups/#{group_id}/testers"
+ response = request(:post) do |req|
req.url url
- req.body = {
- "groupId" => group_id,
- "testerId" => tester_id
- }.to_json
+ req.body = [{
+ "email" => email,
+ "firstName" => first_name,
+ "lastName" => last_name
+ }].to_json
req.headers['Content-Type'] = 'application/json'
end
handle_response(response)
end
@@ -226,9 +266,11 @@
unless response.body.kind_of?(Hash)
raise UnexpectedResponse, response.body
end
raise UnexpectedResponse, response.body['error'] if response.body['error']
+
+ raise UnexpectedResponse, "Temporary iTunes Connect error: #{response.body}" if response.body['statusCode'] == 'ERROR'
return response.body['data'] if response.body['data']
return response.body
end