Class: Spaceship::Tunes::AppVersion
- Defined in:
- lib/spaceship/tunes/app_version.rb
Overview
Represents an editable version of an iTunes Connect Application This can either be the live or the edit version retrieved via the app rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#app_status ⇒ Spaceship::Tunes::AppStatus
readonly
What’s the current status of this app e.g.
-
#app_type ⇒ String
The appType number of this version.
-
#application ⇒ Spaceship::Tunes::Application
A reference to the application this version is for.
- #can_beta_test ⇒ Bool
- #can_prepare_for_upload ⇒ Bool
- #can_reject_version ⇒ Bool
- #can_send_version_live ⇒ Bool
-
#copyright ⇒ String
The copyright information of this app.
-
#description ⇒ Hash
readonly
A hash representing the description in all languages.
-
#is_live ⇒ Bool
Is that the version that’s currently available in the App Store?.
-
#keywords ⇒ Hash
readonly
A hash representing the keywords in all languages.
-
#languages ⇒ Array
Raw access the all available languages.
-
#large_app_icon ⇒ Spaceship::Tunes::AppImage
The structure containing information about the large app icon (1024x1024).
-
#marketing_url ⇒ Hash
readonly
A hash representing the marketing url in all languages.
-
#raw_status ⇒ String
App Status (e.g. ‘readyForSale’).
-
#release_notes ⇒ Hash
readonly
The changelog.
-
#release_on_approval ⇒ Object
These methods takes care of properly parsing values that are not returned in the right format, e.g.
-
#review_demo_password ⇒ String
App Review Information Demo Account Password.
-
#review_demo_user ⇒ String
App Review Information Demo Account User Name.
-
#review_email ⇒ String
App Review Information Email Address.
-
#review_first_name ⇒ String
App Review Information.
-
#review_last_name ⇒ String
App Review Information Last Name.
-
#review_notes ⇒ String
App Review Information Notes.
-
#review_phone_number ⇒ String
App Review Information Phone Number.
-
#screenshots ⇒ Hash
readonly
Represents the screenshots of this app version (read-only).
-
#support_url ⇒ Hash
readonly
A hash representing the support url in all languages.
-
#supports_apple_watch ⇒ Bool
Does the binary contain a watch binary?.
-
#trailers ⇒ Hash
readonly
Represents the trailers of this app version (read-only).
-
#transit_app_file ⇒ Spaceship::Tunes::TransitAppFile
GeoJson.
-
#version ⇒ String
The version number of this version.
-
#version_id ⇒ Integer
A unqiue ID for this version generated by iTunes Connect.
-
#watch_app_icon ⇒ Spaceship::Tunes::AppImage
The structure containing information about the large watch icon (1024x1024).
Attributes inherited from Base
Class Method Summary collapse
-
.factory(attrs) ⇒ Object
Create a new object based on a hash.
- .find(application, app_id, is_live) ⇒ Object
Instance Method Summary collapse
-
#candidate_builds ⇒ Object
Returns an array of all builds that can be sent to review.
-
#create_languages(languages) ⇒ Object
Call this method to make sure the given languages are available for this app You should call this method before accessing the name, description and other localized values This will create the new language if it’s not available yet and do nothing if everything’s there Important: Due to a bug you have to fetch the ‘edit_version` again, as it doesn’t get refreshed immediately.
-
#is_live? ⇒ Bool
rubocop:disable Style/PredicateName.
-
#save! ⇒ Object
Push all changes that were made back to iTunes Connect.
-
#select_build(build) ⇒ Object
Select a build to be submitted for Review.
-
#setup ⇒ Object
Private methods.
-
#unfold_languages ⇒ Object
Prefill name, keywords, etc…
-
#update_rating(hash) ⇒ Object
Set the age restriction rating Call it like this: v.update_rating({ ‘CARTOON_FANTASY_VIOLENCE’ => 0, ‘MATURE_SUGGESTIVE’ => 2, ‘UNRESTRICTED_WEB_ACCESS’ => 0, ‘GAMBLING_CONTESTS’ => 0 }).
-
#upload_geojson!(geojson_path) ⇒ Object
Uploads or removes the transit app file.
-
#upload_large_icon!(icon_path) ⇒ Object
Uploads or removes the large icon.
-
#upload_screenshot!(screenshot_path, sort_order, language, device) ⇒ Object
Uploads or removes a screenshot.
-
#upload_trailer!(trailer_path, language, device, timestamp = "05.00", preview_image_path = nil) ⇒ Object
Uploads, removes a trailer video or change its preview image.
-
#upload_watch_icon!(icon_path) ⇒ Object
Uploads or removes the watch icon.
-
#url ⇒ String
An URL to this specific resource.
Methods inherited from TunesBase
Methods inherited from Base
attr_accessor, attr_mapping, #attributes, attributes, #initialize, #inspect, mapping_module, method_missing, set_client, #to_s
Constructor Details
This class inherits a constructor from Spaceship::Base
Instance Attribute Details
#app_status ⇒ Spaceship::Tunes::AppStatus (readonly)
Returns What’s the current status of this app e.g. Waiting for Review, Ready for Sale, …
22 23 24 |
# File 'lib/spaceship/tunes/app_version.rb', line 22 def app_status @app_status end |
#app_type ⇒ String
Returns The appType number of this version.
18 19 20 |
# File 'lib/spaceship/tunes/app_version.rb', line 18 def app_type @app_type end |
#application ⇒ Spaceship::Tunes::Application
Returns A reference to the application this version is for.
9 10 11 |
# File 'lib/spaceship/tunes/app_version.rb', line 9 def application @application end |
#can_beta_test ⇒ Bool
43 44 45 |
# File 'lib/spaceship/tunes/app_version.rb', line 43 def can_beta_test @can_beta_test end |
#can_prepare_for_upload ⇒ Bool
34 35 36 |
# File 'lib/spaceship/tunes/app_version.rb', line 34 def can_prepare_for_upload @can_prepare_for_upload end |
#can_reject_version ⇒ Bool
31 32 33 |
# File 'lib/spaceship/tunes/app_version.rb', line 31 def can_reject_version @can_reject_version end |
#can_send_version_live ⇒ Bool
37 38 39 |
# File 'lib/spaceship/tunes/app_version.rb', line 37 def can_send_version_live @can_send_version_live end |
#copyright ⇒ String
Returns The copyright information of this app.
15 16 17 |
# File 'lib/spaceship/tunes/app_version.rb', line 15 def copyright @copyright end |
#description ⇒ Hash (readonly)
Returns A hash representing the description in all languages.
98 99 100 |
# File 'lib/spaceship/tunes/app_version.rb', line 98 def description @description end |
#is_live ⇒ Bool
Returns Is that the version that’s currently available in the App Store?.
25 26 27 |
# File 'lib/spaceship/tunes/app_version.rb', line 25 def is_live @is_live end |
#keywords ⇒ Hash (readonly)
Returns A hash representing the keywords in all languages.
95 96 97 |
# File 'lib/spaceship/tunes/app_version.rb', line 95 def keywords @keywords end |
#languages ⇒ Array
Returns Raw access the all available languages. You shouldn’t use it probably.
92 93 94 |
# File 'lib/spaceship/tunes/app_version.rb', line 92 def languages @languages end |
#large_app_icon ⇒ Spaceship::Tunes::AppImage
Returns the structure containing information about the large app icon (1024x1024).
49 50 51 |
# File 'lib/spaceship/tunes/app_version.rb', line 49 def large_app_icon @large_app_icon end |
#marketing_url ⇒ Hash (readonly)
Returns A hash representing the marketing url in all languages.
107 108 109 |
# File 'lib/spaceship/tunes/app_version.rb', line 107 def marketing_url @marketing_url end |
#raw_status ⇒ String
Returns App Status (e.g. ‘readyForSale’). You should use ‘app_status` instead.
28 29 30 |
# File 'lib/spaceship/tunes/app_version.rb', line 28 def raw_status @raw_status end |
#release_notes ⇒ Hash (readonly)
Returns The changelog.
101 102 103 |
# File 'lib/spaceship/tunes/app_version.rb', line 101 def release_notes @release_notes end |
#release_on_approval ⇒ Object
These methods takes care of properly parsing values that are not returned in the right format, e.g. boolean as string
40 41 42 |
# File 'lib/spaceship/tunes/app_version.rb', line 40 def release_on_approval @release_on_approval end |
#review_demo_password ⇒ String
Returns App Review Information Demo Account Password.
82 83 84 |
# File 'lib/spaceship/tunes/app_version.rb', line 82 def review_demo_password @review_demo_password end |
#review_demo_user ⇒ String
Returns App Review Information Demo Account User Name.
79 80 81 |
# File 'lib/spaceship/tunes/app_version.rb', line 79 def review_demo_user @review_demo_user end |
#review_email ⇒ String
Returns App Review Information Email Address.
76 77 78 |
# File 'lib/spaceship/tunes/app_version.rb', line 76 def review_email @review_email end |
#review_first_name ⇒ String
App Review Information
67 68 69 |
# File 'lib/spaceship/tunes/app_version.rb', line 67 def review_first_name @review_first_name end |
#review_last_name ⇒ String
Returns App Review Information Last Name.
70 71 72 |
# File 'lib/spaceship/tunes/app_version.rb', line 70 def review_last_name @review_last_name end |
#review_notes ⇒ String
Returns App Review Information Notes.
85 86 87 |
# File 'lib/spaceship/tunes/app_version.rb', line 85 def review_notes @review_notes end |
#review_phone_number ⇒ String
Returns App Review Information Phone Number.
73 74 75 |
# File 'lib/spaceship/tunes/app_version.rb', line 73 def review_phone_number @review_phone_number end |
#screenshots ⇒ Hash (readonly)
Returns Represents the screenshots of this app version (read-only).
110 111 112 |
# File 'lib/spaceship/tunes/app_version.rb', line 110 def screenshots @screenshots end |
#support_url ⇒ Hash (readonly)
Returns A hash representing the support url in all languages.
104 105 106 |
# File 'lib/spaceship/tunes/app_version.rb', line 104 def support_url @support_url end |
#supports_apple_watch ⇒ Bool
Returns Does the binary contain a watch binary?.
46 47 48 |
# File 'lib/spaceship/tunes/app_version.rb', line 46 def supports_apple_watch @supports_apple_watch end |
#trailers ⇒ Hash (readonly)
Returns Represents the trailers of this app version (read-only).
113 114 115 |
# File 'lib/spaceship/tunes/app_version.rb', line 113 def trailers @trailers end |
#transit_app_file ⇒ Spaceship::Tunes::TransitAppFile
GeoJson
61 62 63 |
# File 'lib/spaceship/tunes/app_version.rb', line 61 def transit_app_file @transit_app_file end |
#version ⇒ String
Returns The version number of this version.
12 13 14 |
# File 'lib/spaceship/tunes/app_version.rb', line 12 def version @version end |
#version_id ⇒ Integer
Returns a unqiue ID for this version generated by iTunes Connect.
55 56 57 |
# File 'lib/spaceship/tunes/app_version.rb', line 55 def version_id @version_id end |
#watch_app_icon ⇒ Spaceship::Tunes::AppImage
Returns the structure containing information about the large watch icon (1024x1024).
52 53 54 |
# File 'lib/spaceship/tunes/app_version.rb', line 52 def watch_app_icon @watch_app_icon end |
Class Method Details
.factory(attrs) ⇒ Object
Create a new object based on a hash. This is used to create a new object based on the server response.
147 148 149 150 151 152 |
# File 'lib/spaceship/tunes/app_version.rb', line 147 def factory(attrs) obj = self.new(attrs) obj.unfold_languages return obj end |
.find(application, app_id, is_live) ⇒ Object
157 158 159 160 161 162 163 164 |
# File 'lib/spaceship/tunes/app_version.rb', line 157 def find(application, app_id, is_live) attrs = client.app_version(app_id, is_live) return nil unless attrs attrs.merge!(application: application) attrs.merge!(is_live: is_live) return self.factory(attrs) end |
Instance Method Details
#candidate_builds ⇒ Object
Returns an array of all builds that can be sent to review
200 201 202 203 204 205 206 207 208 |
# File 'lib/spaceship/tunes/app_version.rb', line 200 def candidate_builds res = client.candidate_builds(self.application.apple_id, self.version_id) builds = [] res.each do |attrs| next unless attrs["type"] == "BUILD" # I don't know if it can be something else. builds << Tunes::Build.factory(attrs) end return builds end |
#create_languages(languages) ⇒ Object
Call this method to make sure the given languages are available for this app You should call this method before accessing the name, description and other localized values This will create the new language if it’s not available yet and do nothing if everything’s there Important: Due to a bug you have to fetch the ‘edit_version` again, as it doesn’t get refreshed immediately
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/spaceship/tunes/app_version.rb', line 178 def create_languages(languages) languages = [languages] if languages.kind_of?(String) raise "Please pass an array" unless languages.kind_of? Array copy_from = self.languages.find { |a| a['language'] == 'en-US' } || self.languages.first languages.each do |language| # First, see if it's already available found = self.languages.find do |local| local['language'] == language end next if found new_language = copy_from.clone new_language['language'] = language self.languages << new_language end nil end |
#is_live? ⇒ Bool
rubocop:disable Style/PredicateName
169 170 171 |
# File 'lib/spaceship/tunes/app_version.rb', line 169 def is_live? is_live end |
#save! ⇒ Object
Push all changes that were made back to iTunes Connect
264 265 266 |
# File 'lib/spaceship/tunes/app_version.rb', line 264 def save! client.update_app_version!(application.apple_id, self.version_id, raw_data) end |
#select_build(build) ⇒ Object
Select a build to be submitted for Review. You have to pass a build you got from - candidate_builds Don’t forget to call save! after calling this method
213 214 215 216 217 218 |
# File 'lib/spaceship/tunes/app_version.rb', line 213 def select_build(build) raw_data.set(['preReleaseBuildVersionString', 'value'], build.build_version) raw_data.set(['preReleaseBuildTrainVersionString'], build.train_version) raw_data.set(['preReleaseBuildUploadDate'], build.upload_date) true end |
#setup ⇒ Object
Private methods
276 277 278 279 280 281 282 283 284 285 |
# File 'lib/spaceship/tunes/app_version.rb', line 276 def setup # Properly parse the AppStatus status = raw_data['status'] @app_status = Tunes::AppStatus.get_from_string(status) setup_large_app_icon setup_watch_app_icon setup_transit_app_file setup_screenshots setup_trailers end |
#unfold_languages ⇒ Object
Prefill name, keywords, etc…
434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/spaceship/tunes/app_version.rb', line 434 def unfold_languages { keywords: :keywords, description: :description, supportURL: :support_url, marketingURL: :marketing_url, releaseNotes: :release_notes }.each do |json, attribute| instance_variable_set("@#{attribute}".to_sym, LanguageItem.new(json, languages)) end end |
#update_rating(hash) ⇒ Object
Set the age restriction rating Call it like this: v.update_rating(
'CARTOON_FANTASY_VIOLENCE' => 0,
'MATURE_SUGGESTIVE' => 2,
'UNRESTRICTED_WEB_ACCESS' => 0,
'GAMBLING_CONTESTS' => 0
)
Available Values github.com/KrauseFx/deliver/blob/master/Reference.md
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/spaceship/tunes/app_version.rb', line 231 def (hash) raise "Must be a hash" unless hash.kind_of?(Hash) hash.each do |key, value| to_edit = self.raw_data['ratings']['nonBooleanDescriptors'].find do |current| current['name'].include?(key) end if to_edit to_set = "NONE" if value == 0 to_set = "INFREQUENT_MILD" if value == 1 to_set = "FREQUENT_INTENSE" if value == 2 raise "Invalid value '#{value}' for '#{key}', must be 0-2" unless to_set to_edit['level'] = "ITC.apps.ratings.level.#{to_set}" else # Maybe it's a boolean descriptor? to_edit = self.raw_data['ratings']['booleanDescriptors'].find do |current| current['name'].include?(key) end if to_edit to_set = "NO" to_set = "YES" if value.to_i > 0 to_edit['level'] = "ITC.apps.ratings.level.#{to_set}" else raise "Could not find option '#{key}' in the list of available options" end end end true end |
#upload_geojson!(geojson_path) ⇒ Object
Uploads or removes the transit app file
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/spaceship/tunes/app_version.rb', line 315 def upload_geojson!(geojson_path) unless geojson_path raw_data["transitAppFile"]["value"] = nil @transit_app_file = nil return end upload_file = UploadFile.from_path geojson_path geojson_data = client.upload_geojson(self, upload_file) @transit_app_file = Tunes::TransitAppFile.factory({}) if @transit_app_file.nil? @transit_app_file .url = nil # response.headers['Location'] @transit_app_file.asset_token = geojson_data["token"] @transit_app_file.name = upload_file.file_name @transit_app_file.time_stamp = Time.now.to_i * 1000 # works without but... end |
#upload_large_icon!(icon_path) ⇒ Object
Uploads or removes the large icon
289 290 291 292 293 294 295 296 297 298 |
# File 'lib/spaceship/tunes/app_version.rb', line 289 def upload_large_icon!(icon_path) unless icon_path @large_app_icon.reset! return end upload_image = UploadFile.from_path icon_path image_data = client.upload_large_icon(self, upload_image) @large_app_icon.reset!({ asset_token: image_data['token'], original_file_name: upload_image.file_name }) end |
#upload_screenshot!(screenshot_path, sort_order, language, device) ⇒ Object
Uploads or removes a screenshot
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/spaceship/tunes/app_version.rb', line 336 def upload_screenshot!(screenshot_path, sort_order, language, device) raise "sort_order must be positive" unless sort_order > 0 raise "sort_order must not be > 5" if sort_order > 5 # this will also check both language and device parameters device_lang_screenshots = screenshots_data_for_language_and_device(language, device)["value"] existing_sort_orders = device_lang_screenshots.map { |s| s["value"]["sortOrder"] } if screenshot_path # adding / replacing upload_file = UploadFile.from_path screenshot_path screenshot_data = client.upload_screenshot(self, upload_file, device) new_screenshot = { "value" => { "assetToken" => screenshot_data["token"], "sortOrder" => sort_order, "url" => nil, "thumbNailUrl" => nil, "originalFileName" => upload_file.file_name } } if existing_sort_orders.include?(sort_order) # replace device_lang_screenshots[existing_sort_orders.index(sort_order)] = new_screenshot else # add device_lang_screenshots << new_screenshot end else # removing raise "cannot remove screenshot with non existing sort_order" unless existing_sort_orders.include?(sort_order) device_lang_screenshots.delete_at(existing_sort_orders.index(sort_order)) end setup_screenshots end |
#upload_trailer!(trailer_path, language, device, timestamp = "05.00", preview_image_path = nil) ⇒ Object
Uploads, removes a trailer video or change its preview image
A preview image for the video is required by ITC and is usually automatically extracted by your browser. This method will either automatically extract it from the video (using ‘ffmpeg) or allow you to specify it using preview_image_path
. If the preview image is specified, ffmpeg` will ot be used. The image resolution will be checked against expectations (which might be different from the trailer resolution.
It is recommended to extract the preview image using the spaceship related tools in order to ensure the appropriate format and resolution are used.
Note: if the video is already set, the trailer_path
is only used to grab the preview screenshot. Note: to extract its resolution and a screenshot preview, the ‘ffmpeg` tool will be used
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/spaceship/tunes/app_version.rb', line 386 def upload_trailer!(trailer_path, language, device, = "05.00", preview_image_path = nil) raise "No app trailer supported for iphone35" if device == 'iphone35' device_lang_trailer = trailer_data_for_language_and_device(language, device) if trailer_path # adding / replacing trailer / replacing preview raise "Invalid timestamp #{}" if ( =~ /^[0-9][0-9].[0-9][0-9]$/).nil? if preview_image_path check_preview_screenshot_resolution(preview_image_path, device) video_preview_path = preview_image_path else # IDEA: optimization, we could avoid fetching the screenshot if the timestamp hasn't changed video_preview_resolution = video_preview_resolution_for(device, trailer_path) video_preview_path = Utilities.grab_video_preview(trailer_path, , video_preview_resolution) end video_preview_file = UploadFile.from_path video_preview_path video_preview_data = client.upload_trailer_preview(self, video_preview_file) trailer = device_lang_trailer["value"] if trailer.nil? # add trailer upload_file = UploadFile.from_path trailer_path trailer_data = client.upload_trailer(self, upload_file) trailer_data = trailer_data['responses'][0] trailer = { "videoAssetToken" => trailer_data["token"], "descriptionXML" => trailer_data["descriptionDoc"], "contentType" => upload_file.content_type } device_lang_trailer["value"] = trailer end # add / update preview # different format required ts = "00:00:#{}" ts[8] = ':' trailer.merge!({ "pictureAssetToken" => video_preview_data["token"], "previewFrameTimeCode" => "#{ts}", "isPortrait" => Utilities.portrait?(video_preview_path) }) else # removing trailer raise "cannot remove non existing trailer" if device_lang_trailer["value"].nil? device_lang_trailer["value"] = nil end setup_trailers end |
#upload_watch_icon!(icon_path) ⇒ Object
Uploads or removes the watch icon
302 303 304 305 306 307 308 309 310 311 |
# File 'lib/spaceship/tunes/app_version.rb', line 302 def upload_watch_icon!(icon_path) unless icon_path @watch_app_icon.reset! return end upload_image = UploadFile.from_path icon_path image_data = client.upload_watch_icon(self, upload_image) @watch_app_icon.reset!({ asset_token: image_data["token"], original_file_name: upload_image.file_name }) end |
#url ⇒ String
Returns An URL to this specific resource. You can enter this URL into your browser.
269 270 271 272 273 |
# File 'lib/spaceship/tunes/app_version.rb', line 269 def url url = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/904332168/ios/versioninfo/" url += "deliverable" if self.is_live? return url end |