class Supply::Client
Constants
- SCOPE
- SERVICE
Attributes
Editing something Reference to the entry we're currently editing. Might be nil if don't have one open
Package name of the currently edited element
Public Class Methods
@!group Login
Supply::AbstractGoogleServiceClient::service_account_authentication
# File supply/lib/supply/client.rb, line 112 def self.service_account_authentication(params: nil) if params[:json_key] || params[:json_key_data] super(params: params) elsif params[:key] && params[:issuer] require 'google/api_client/auth/key_utils' UI.important("This type of authentication is deprecated. Please consider using JSON authentication instead") key = Google::APIClient::KeyUtils.load_from_pkcs12(File.expand_path(params[:key]), 'notasecret') cred_json = { private_key: key.to_s, client_email: params[:issuer] } service_account_json = StringIO.new(JSON.dump(cred_json)) service_account_json else UI.user_error!("No authentication parameters were specified. These must be provided in order to authenticate with Google") end end
Public Instance Methods
Get a list of all AAB version codes - returns the list of version codes
# File supply/lib/supply/client.rb, line 214 def aab_version_codes ensure_active_edit! result = call_google_api { client.list_edit_bundles(current_package_name, current_edit.id) } return Array(result.bundles).map(&:version_code) end
Aborts the current edit deleting all pending changes
# File supply/lib/supply/client.rb, line 144 def abort_current_edit ensure_active_edit! call_google_api { client.delete_edit(current_package_name, current_edit.id) } self.current_edit = nil self.current_package_name = nil end
Get a list of all apk listings (changelogs) - returns the list
# File supply/lib/supply/client.rb, line 223 def apk_listings(apk_version_code) ensure_active_edit! result = call_google_api do client.list_apk_listings( current_package_name, current_edit.id, apk_version_code ) end return (result.listings || []).map do |row| ApkListing.new(row.recent_changes, row.language, apk_version_code) end end
Get a list of all APK version codes - returns the list of version codes
# File supply/lib/supply/client.rb, line 205 def apks_version_codes ensure_active_edit! result = call_google_api { client.list_apks(current_package_name, current_edit.id) } return Array(result.apks).map(&:version_code) end
Begin modifying a certain package
# File supply/lib/supply/client.rb, line 135 def begin_edit(package_name: nil) UI.user_error!("You currently have an active edit") if @current_edit self.current_edit = call_google_api { client.insert_edit(package_name) } self.current_package_name = package_name end
# File supply/lib/supply/client.rb, line 424 def clear_screenshots(image_type: nil, language: nil) ensure_active_edit! call_google_api do client.delete_all_images( current_package_name, current_edit.id, language, image_type ) end end
Commits the current edit saving all pending changes on Google Play
# File supply/lib/supply/client.rb, line 161 def commit_current_edit! ensure_active_edit! call_google_api { client.commit_edit(current_package_name, current_edit.id) } self.current_edit = nil self.current_package_name = nil end
@!group Screenshots
# File supply/lib/supply/client.rb, line 393 def fetch_images(image_type: nil, language: nil) ensure_active_edit! result = call_google_api do client.list_images( current_package_name, current_edit.id, language, image_type ) end (result.images || []).map(&:url) end
Returns the listing for the given language filled with the current values if it already exists
# File supply/lib/supply/client.rb, line 187 def listing_for_language(language) ensure_active_edit! begin result = client.get_listing( current_package_name, current_edit.id, language ) return Listing.new(self, language, result) rescue Google::Apis::ClientError => e return Listing.new(self, language) if e.status_code == 404 # create a new empty listing raise end end
Get a list of all languages - returns the list make sure to have an active edit
# File supply/lib/supply/client.rb, line 176 def listings ensure_active_edit! result = call_google_api { client.list_listings(current_package_name, current_edit.id) } return result.listings.map do |row| Listing.new(self, row.language, row) end end
Get list of version codes for track
# File supply/lib/supply/client.rb, line 337 def track_version_codes(track) ensure_active_edit! begin result = client.get_track( current_package_name, current_edit.id, track ) return result.version_codes || [] rescue Google::Apis::ClientError => e return [] if e.status_code == 404 && e.to_s.include?("trackEmpty") raise end end
# File supply/lib/supply/client.rb, line 353 def update_apk_listing_for_language(apk_listing) ensure_active_edit! apk_listing_object = Androidpublisher::ApkListing.new({ language: apk_listing.language, recent_changes: apk_listing.recent_changes }) call_google_api do client.update_apk_listing( current_package_name, current_edit.id, apk_listing.apk_version_code, apk_listing.language, apk_listing_object ) end end
Updates or creates the listing for the specified language
# File supply/lib/supply/client.rb, line 244 def update_listing_for_language(language: nil, title: nil, short_description: nil, full_description: nil, video: nil) ensure_active_edit! listing = Androidpublisher::Listing.new({ language: language, title: title, full_description: full_description, short_description: short_description, video: video }) call_google_api do client.update_listing( current_package_name, current_edit.id, language, listing ) end end
# File supply/lib/supply/client.rb, line 372 def update_obb(apk_version_code, expansion_file_type, references_version, file_size) ensure_active_edit! call_google_api do client.update_expansion_file( current_package_name, current_edit.id, apk_version_code, expansion_file_type, Google::Apis::AndroidpublisherV2::ExpansionFile.new( references_version: references_version, file_size: file_size ) ) end end
Updates the track for the provided version code(s)
# File supply/lib/supply/client.rb, line 310 def update_track(track, rollout, apk_version_code) ensure_active_edit! track_version_codes = apk_version_code.kind_of?(Array) ? apk_version_code : [apk_version_code] # This change happend on 2018-04-24 # rollout cannot be sent on any other track besides "rollout" # https://github.com/fastlane/fastlane/issues/12372 rollout = nil unless track == "rollout" track_body = Androidpublisher::Track.new({ track: track, user_fraction: rollout, version_codes: track_version_codes }) call_google_api do client.update_track( current_package_name, current_edit.id, track, track_body ) end end
# File supply/lib/supply/client.rb, line 265 def upload_apk(path_to_apk) ensure_active_edit! result_upload = call_google_api do client.upload_apk( current_package_name, current_edit.id, upload_source: path_to_apk ) end return result_upload.version_code end
# File supply/lib/supply/client.rb, line 294 def upload_bundle(path_to_aab) ensure_active_edit! result_upload = call_google_api do client.upload_edit_bundle( current_package_name, self.current_edit.id, upload_source: path_to_aab, content_type: "application/octet-stream" ) end return result_upload.version_code end
@param image_type (e.g. phoneScreenshots, sevenInchScreenshots, …)
# File supply/lib/supply/client.rb, line 409 def upload_image(image_path: nil, image_type: nil, language: nil) ensure_active_edit! call_google_api do client.upload_image( current_package_name, current_edit.id, language, image_type, upload_source: image_path, content_type: 'image/*' ) end end
# File supply/lib/supply/client.rb, line 279 def upload_mapping(path_to_mapping, apk_version_code) ensure_active_edit! call_google_api do client.upload_edit_deobfuscationfile( current_package_name, current_edit.id, apk_version_code, "proguard", upload_source: path_to_mapping, content_type: "application/octet-stream" ) end end
# File supply/lib/supply/client.rb, line 437 def upload_obb(obb_file_path: nil, apk_version_code: nil, expansion_file_type: nil) ensure_active_edit! call_google_api do client.upload_expansion_file( current_package_name, current_edit.id, apk_version_code, expansion_file_type, upload_source: obb_file_path, content_type: 'application/octet-stream' ) end end
Validates the current edit - does not change data on Google Play
# File supply/lib/supply/client.rb, line 154 def validate_current_edit! ensure_active_edit! call_google_api { client.validate_edit(current_package_name, current_edit.id) } end
Private Instance Methods
# File supply/lib/supply/client.rb, line 454 def ensure_active_edit! UI.user_error!("You need to have an active edit, make sure to call `begin_edit`") unless @current_edit end