Method: Spaceship::Client#team_id=
- Defined in:
- spaceship/lib/spaceship/client.rb
#team_id=(team_id) ⇒ Object
Set a new team ID which will be used from now on
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'spaceship/lib/spaceship/client.rb', line 143 def team_id=(team_id) # First, we verify the team actually exists, because otherwise iTC would return the # following confusing error message # # invalid content provider id available_teams = teams.collect do |team| { team_id: team["providerId"], public_team_id: team["publicProviderId"], team_name: team["name"] } end result = available_teams.find do |available_team| team_id.to_s == available_team[:team_id].to_s end unless result error_string = "Could not set team ID to '#{team_id}', only found the following available teams:\n\n#{available_teams.map { |team| "- #{team[:team_id]} (#{team[:team_name]})" }.join("\n")}\n" raise Tunes::Error.new, error_string end response = request(:post) do |req| req.url("https://appstoreconnect.apple.com/olympus/v1/session") req.body = { "provider": { "providerId": result[:team_id] } }.to_json req.headers['Content-Type'] = 'application/json' req.headers['X-Requested-With'] = 'olympus-ui' end handle_itc_response(response.body) # clear user_details_data cache, as session switch will have changed sessionToken attribute @_cached_user_details = nil @current_team_id = team_id end |