spaceship/lib/spaceship/test_flight/client.rb in fastlane-2.66.0 vs spaceship/lib/spaceship/test_flight/client.rb in fastlane-2.66.1

- old
+ new

@@ -82,15 +82,20 @@ ## # @!group Groups API ## + # Returns a list of available testing groups + # e.g. + # {"b6f65dbd-c845-4d91-bc39-0b661d608970" => "Boarding", + # "70402368-9deb-409f-9a26-bb3f215dfee3" => "Automatic"} def get_groups(app_id: nil) + return @cached_groups if @cached_groups assert_required_params(__method__, binding) - response = request(:get, "/testflight/v2/providers/#{team_id}/apps/#{app_id}/groups") - handle_response(response) + response = request(:get, "/testflight/v2/providers/#{provider_id}/apps/#{app_id}/groups") + @cached_groups = handle_response(response) end def add_group_to_build(app_id: nil, group_id: nil, build_id: nil) assert_required_params(__method__, binding) @@ -104,21 +109,10 @@ 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] @@ -126,19 +120,19 @@ 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_ids = get_groups(app_id: 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] + url = tester.url(app_id, provider_id, json_group_id)[:index_by_app] r = request(:get, url) testers += parse_response(r, 'data')['users'] end testers @@ -304,8 +298,13 @@ if binding.respond_to?(:local_variable_get) binding.local_variable_get(name) else binding.eval(name.to_s) end + end + + def provider_id + return team_id if self.provider.nil? + self.provider.provider_id end end end