Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spaceship] add get_beta_app_tester_detail #21933

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions spaceship/lib/spaceship/connect_api.rb
Expand Up @@ -26,6 +26,7 @@
require 'spaceship/connect_api/models/beta_app_review_submission'
require 'spaceship/connect_api/models/beta_feedback'
require 'spaceship/connect_api/models/beta_group'
require 'spaceship/connect_api/models/beta_app_tester_detail'
require 'spaceship/connect_api/models/beta_screenshot'
require 'spaceship/connect_api/models/beta_tester'
require 'spaceship/connect_api/models/beta_tester_metric'
Expand Down
5 changes: 5 additions & 0 deletions spaceship/lib/spaceship/connect_api/models/app.rb
Expand Up @@ -387,6 +387,11 @@ def get_beta_groups(client: nil, filter: {}, includes: nil, limit: nil, sort: ni
return resps.flat_map(&:to_models)
end

def get_beta_app_tester_detail
client ||= Spaceship::ConnectAPI
client.get_beta_app_tester_detail(app_id: id).to_models
end

def create_beta_group(client: nil, group_name: nil, is_internal_group: false, public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false, has_access_to_all_builds: nil)
client ||= Spaceship::ConnectAPI
resps = client.create_beta_group(
Expand Down
@@ -0,0 +1,30 @@
require_relative '../model'
module Spaceship
class ConnectAPI
class BetaAppTesterDetail
include Spaceship::ConnectAPI::Model

attr_accessor :max_internal_testers
attr_accessor :max_external_testers
attr_accessor :max_internal_groups
attr_accessor :max_external_groups
attr_accessor :current_internal_testers
attr_accessor :current_external_testers
attr_accessor :currentDeletedTesters

attr_mapping({
"maxInternalTesters" => "max_internal_testers",
"maxExternalTesters" => "max_external_testers",
"maxInternalGroups" => "max_internal_groups",
"maxExternalGroups" => "max_external_groups",
"currentInternalTesters" => "current_internal_testers",
"currentExternalTesters" => "current_external_testers",
"currentDeletedTesters" => "current_deleted_testers",
})

def self.type
return "betaAppTesterDetails"
end
end
end
end
4 changes: 4 additions & 0 deletions spaceship/lib/spaceship/connect_api/testflight/testflight.rb
Expand Up @@ -178,6 +178,10 @@ def get_beta_groups(filter: {}, includes: nil, limit: nil, sort: nil)
test_flight_request_client.get("betaGroups", params)
end

def get_beta_app_tester_detail(app_id:)
test_flight_request_client.get("apps/#{app_id}/betaAppTesterDetail", {})
end

def add_beta_groups_to_build(build_id: nil, beta_group_ids: [])
body = {
data: beta_group_ids.map do |id|
Expand Down
@@ -0,0 +1,21 @@
{
"data" : {
"type" : "betaAppTesterDetails",
"id" : "123456789",
"attributes" : {
"maxInternalTesters" : 100,
"maxExternalTesters" : 10000,
"maxInternalGroups" : 100,
"maxExternalGroups" : 200,
"currentInternalTesters" : 1,
"currentExternalTesters" : 9725,
"currentDeletedTesters" : 1680
},
"links" : {
"self" : "https://appstoreconnect.apple.com/iris/v1/betaAppTesterDetails/123456789"
}
},
"links" : {
"self" : "https://appstoreconnect.apple.com/iris/v1/apps/987654321/betaAppTesterDetail"
}
}
25 changes: 25 additions & 0 deletions spaceship/spec/connect_api/models/beta_app_tester_detail_spec.rb
@@ -0,0 +1,25 @@
describe Spaceship::ConnectAPI::BetaAppTesterDetail do
before { Spaceship::Tunes.login }

describe '#Spaceship::ConnectAPI' do
it '#get_beta_app_tester_detail' do
response = Spaceship::ConnectAPI.get_beta_app_tester_detail(app_id: "123456789")
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)

expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaAppTesterDetail)
end

model = response.first
expect(model.id).to eq("123456789")
expect(model.maxInternalTesters).to eq(100)
expect(model.maxExternalTesters).to eq(10_000)
expect(model.maxInternalGroups).to eq(100)
expect(model.maxExternalGroups).to eq(200)
expect(model.currentInternalTesters).to eq(1)
expect(model.currentExternalTesters).to eq(9725)
expect(model.currentDeletedTesters).to eq(1680)
end
end
end
14 changes: 14 additions & 0 deletions spaceship/spec/connect_api/testflight/testflight_client_spec.rb
Expand Up @@ -256,6 +256,20 @@ def test_request_body(url, body)
end
end

describe 'betaAppTesterDetail' do
context 'get_beta_app_tester_detail' do
let(:app_id) { "123456789" }
let(:path) { "apps/#{app_id}/betaAppTesterDetail" }

it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_app_tester_detail(app_id: app_id)
end
end
end

describe "betaBuildLocalizations" do
context 'get_beta_build_localizations' do
let(:path) { "betaBuildLocalizations" }
Expand Down
5 changes: 5 additions & 0 deletions spaceship/spec/connect_api/testflight/testflight_stubbing.rb
Expand Up @@ -43,6 +43,11 @@ def stub_beta_app_review_submissions
to_return(status: 200, body: read_fixture_file('beta_app_review_submissions.json'), headers: { 'Content-Type' => 'application/json' })
end

def stub_beta_app_tester_detail
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps/123456789/betaAppTesterDetail").
to_return(status: 200, body: read_fixture_file('beta_app_tester_detail.json'), headers: { 'Content-Type' => 'application/json' })
end

def stub_beta_build_localizations
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaBuildLocalizations").
to_return(status: 200, body: read_fixture_file('beta_build_localizations.json'), headers: { 'Content-Type' => 'application/json' })
Expand Down
1 change: 1 addition & 0 deletions spaceship/spec/spec_helper.rb
Expand Up @@ -79,6 +79,7 @@ def before_each_spaceship
ConnectAPIStubbing::TestFlight.stub_beta_app_localizations
ConnectAPIStubbing::TestFlight.stub_beta_app_review_details
ConnectAPIStubbing::TestFlight.stub_beta_app_review_submissions
ConnectAPIStubbing::TestFlight.stub_beta_app_tester_detail
ConnectAPIStubbing::TestFlight.stub_beta_build_localizations
ConnectAPIStubbing::TestFlight.stub_beta_build_metrics
ConnectAPIStubbing::TestFlight.stub_beta_feedbacks
Expand Down