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] support fetching build_bundle_file_sizes for a BuildBundle #20860

Merged
merged 4 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
require 'spaceship/connect_api/models/build_delivery'
require 'spaceship/connect_api/models/build_beta_detail'
require 'spaceship/connect_api/models/build_bundle'
require 'spaceship/connect_api/models/build_bundle_file_sizes'
require 'spaceship/connect_api/models/custom_app_organization'
require 'spaceship/connect_api/models/custom_app_user'
require 'spaceship/connect_api/models/pre_release_version'
Expand Down
9 changes: 9 additions & 0 deletions spaceship/lib/spaceship/connect_api/models/build_bundle.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative '../model'
require_relative './build_bundle_file_sizes'
module Spaceship
class ConnectAPI
class BuildBundle
Expand Down Expand Up @@ -54,6 +55,14 @@ module BundleType
def self.type
return "buildBundles"
end

#
# API
#

def build_bundle_file_sizes(client: nil)
@build_bundle_file_sizes ||= BuildBundleFileSizes.all(client: client, build_bundle_id: id)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require_relative '../model'
module Spaceship
class ConnectAPI
class BuildBundleFileSizes
include Spaceship::ConnectAPI::Model

attr_accessor :device_model
attr_accessor :os_version
attr_accessor :download_bytes
attr_accessor :install_bytes

attr_mapping({
"deviceModel" => "device_model",
"osVersion" => "os_version",
"downloadBytes" => "download_bytes",
"installBytes" => "install_bytes"
})

def self.type
return "buildBundleFileSizes"
end

#
# API
#

def self.all(client: nil, build_bundle_id: nil, limit: 30)
client ||= Spaceship::ConnectAPI
resps = client.get_build_bundle_build_bundle_file_sizes(build_bundle_id: build_bundle_id).all_pages
resps.flat_map(&:to_models)
end
end
end
end
9 changes: 9 additions & 0 deletions spaceship/lib/spaceship/connect_api/testflight/testflight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,15 @@ def get_beta_tester_metrics(filter: {}, includes: nil, limit: nil, sort: nil)
test_flight_request_client.get("betaTesterMetrics", params)
end

#
# buildBundles
#

def get_build_bundle_build_bundle_file_sizes(build_bundle_id:, limit: nil)
params = test_flight_request_client.build_params(filter: nil, includes: nil, limit: limit, sort: nil, cursor: nil)
test_flight_request_client.get("buildBundles/#{build_bundle_id}/buildBundleFileSizes", params)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I in the right place? Is the TestFlight client the right place to implement this kind of thing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This client names are a little bit weird since App Store Connect API has changed a bit since this was create 🙈 But yup! This would be the correct place for this 💪

end

#
# builds
#
Expand Down