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
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 keywords 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 keywords 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.
-
#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…
-
#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)
21 22 23 |
# File 'lib/spaceship/tunes/app_version.rb', line 21 def app_status @app_status end |
#app_type ⇒ String
17 18 19 |
# File 'lib/spaceship/tunes/app_version.rb', line 17 def app_type @app_type end |
#application ⇒ Spaceship::Tunes::Application
8 9 10 |
# File 'lib/spaceship/tunes/app_version.rb', line 8 def application @application end |
#can_beta_test ⇒ Bool
42 43 44 |
# File 'lib/spaceship/tunes/app_version.rb', line 42 def can_beta_test @can_beta_test end |
#can_prepare_for_upload ⇒ Bool
33 34 35 |
# File 'lib/spaceship/tunes/app_version.rb', line 33 def can_prepare_for_upload @can_prepare_for_upload end |
#can_reject_version ⇒ Bool
30 31 32 |
# File 'lib/spaceship/tunes/app_version.rb', line 30 def can_reject_version @can_reject_version end |
#can_send_version_live ⇒ Bool
36 37 38 |
# File 'lib/spaceship/tunes/app_version.rb', line 36 def can_send_version_live @can_send_version_live end |
#copyright ⇒ String
14 15 16 |
# File 'lib/spaceship/tunes/app_version.rb', line 14 def copyright @copyright end |
#description ⇒ Hash (readonly)
97 98 99 |
# File 'lib/spaceship/tunes/app_version.rb', line 97 def description @description end |
#is_live ⇒ Bool
24 25 26 |
# File 'lib/spaceship/tunes/app_version.rb', line 24 def is_live @is_live end |
#keywords ⇒ Hash (readonly)
94 95 96 |
# File 'lib/spaceship/tunes/app_version.rb', line 94 def keywords @keywords end |
#languages ⇒ Array
91 92 93 |
# File 'lib/spaceship/tunes/app_version.rb', line 91 def languages @languages end |
#large_app_icon ⇒ Spaceship::Tunes::AppImage
48 49 50 |
# File 'lib/spaceship/tunes/app_version.rb', line 48 def large_app_icon @large_app_icon end |
#marketing_url ⇒ Hash (readonly)
106 107 108 |
# File 'lib/spaceship/tunes/app_version.rb', line 106 def marketing_url @marketing_url end |
#raw_status ⇒ String
27 28 29 |
# File 'lib/spaceship/tunes/app_version.rb', line 27 def raw_status @raw_status end |
#release_notes ⇒ Hash (readonly)
100 101 102 |
# File 'lib/spaceship/tunes/app_version.rb', line 100 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
39 40 41 |
# File 'lib/spaceship/tunes/app_version.rb', line 39 def release_on_approval @release_on_approval end |
#review_demo_password ⇒ String
81 82 83 |
# File 'lib/spaceship/tunes/app_version.rb', line 81 def review_demo_password @review_demo_password end |
#review_demo_user ⇒ String
78 79 80 |
# File 'lib/spaceship/tunes/app_version.rb', line 78 def review_demo_user @review_demo_user end |
#review_email ⇒ String
75 76 77 |
# File 'lib/spaceship/tunes/app_version.rb', line 75 def review_email @review_email end |
#review_first_name ⇒ String
App Review Information
66 67 68 |
# File 'lib/spaceship/tunes/app_version.rb', line 66 def review_first_name @review_first_name end |
#review_last_name ⇒ String
69 70 71 |
# File 'lib/spaceship/tunes/app_version.rb', line 69 def review_last_name @review_last_name end |
#review_notes ⇒ String
84 85 86 |
# File 'lib/spaceship/tunes/app_version.rb', line 84 def review_notes @review_notes end |
#review_phone_number ⇒ String
72 73 74 |
# File 'lib/spaceship/tunes/app_version.rb', line 72 def review_phone_number @review_phone_number end |
#screenshots ⇒ Hash (readonly)
109 110 111 |
# File 'lib/spaceship/tunes/app_version.rb', line 109 def screenshots @screenshots end |
#support_url ⇒ Hash (readonly)
103 104 105 |
# File 'lib/spaceship/tunes/app_version.rb', line 103 def support_url @support_url end |
#supports_apple_watch ⇒ Bool
45 46 47 |
# File 'lib/spaceship/tunes/app_version.rb', line 45 def supports_apple_watch @supports_apple_watch end |
#trailers ⇒ Hash (readonly)
112 113 114 |
# File 'lib/spaceship/tunes/app_version.rb', line 112 def trailers @trailers end |
#transit_app_file ⇒ Spaceship::Tunes::TransitAppFile
GeoJson
60 61 62 |
# File 'lib/spaceship/tunes/app_version.rb', line 60 def transit_app_file @transit_app_file end |
#version ⇒ String
11 12 13 |
# File 'lib/spaceship/tunes/app_version.rb', line 11 def version @version end |
#version_id ⇒ Integer
54 55 56 |
# File 'lib/spaceship/tunes/app_version.rb', line 54 def version_id @version_id end |
#watch_app_icon ⇒ Spaceship::Tunes::AppImage
51 52 53 |
# File 'lib/spaceship/tunes/app_version.rb', line 51 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.
146 147 148 149 150 151 |
# File 'lib/spaceship/tunes/app_version.rb', line 146 def factory(attrs) obj = self.new(attrs) obj.unfold_languages return obj end |
.find(application, app_id, is_live) ⇒ Object
156 157 158 159 160 161 162 163 |
# File 'lib/spaceship/tunes/app_version.rb', line 156 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
207 208 209 210 211 212 213 214 215 |
# File 'lib/spaceship/tunes/app_version.rb', line 207 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 |
#is_live? ⇒ Bool
rubocop:disable Style/PredicateName
168 169 170 |
# File 'lib/spaceship/tunes/app_version.rb', line 168 def is_live? is_live end |
#save! ⇒ Object
Push all changes that were made back to iTunes Connect
228 229 230 |
# File 'lib/spaceship/tunes/app_version.rb', line 228 def save! client.update_app_version!(application.apple_id, is_live?, 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
220 221 222 223 224 225 |
# File 'lib/spaceship/tunes/app_version.rb', line 220 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
240 241 242 243 244 245 246 247 248 249 |
# File 'lib/spaceship/tunes/app_version.rb', line 240 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…
398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/spaceship/tunes/app_version.rb', line 398 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 |
#upload_geojson!(geojson_path) ⇒ Object
Uploads or removes the transit app file
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/spaceship/tunes/app_version.rb', line 279 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
253 254 255 256 257 258 259 260 261 262 |
# File 'lib/spaceship/tunes/app_version.rb', line 253 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
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/spaceship/tunes/app_version.rb', line 300 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
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/spaceship/tunes/app_version.rb', line 350 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
266 267 268 269 270 271 272 273 274 275 |
# File 'lib/spaceship/tunes/app_version.rb', line 266 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
233 234 235 236 237 |
# File 'lib/spaceship/tunes/app_version.rb', line 233 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 |