Class: Spaceship::Tunes::AppVersion

Inherits:
TunesBase show all
Defined in:
spaceship/lib/spaceship/tunes/app_version.rb

Overview

Represents an editable version of an App Store Connect Application This can either be the live or the edit version retrieved via the app rubocop:disable Metrics/ClassLength

Promo codes collapse

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

Promo codes collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TunesBase

client

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_statusSpaceship::Tunes::AppStatus (readonly)

Returns What's the current status of this app e.g. Waiting for Review, Ready for Sale, …

Returns:


38
39
40
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 38

def app_status
  @app_status
end

#app_typeString

Returns The appType number of this version.

Returns:

  • (String)

    The appType number of this version


34
35
36
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 34

def app_type
  @app_type
end

#applicationSpaceship::Tunes::Application

Returns A reference to the application this version is for.

Returns:


22
23
24
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 22

def application
  @application
end

#auto_release_dateFixnum

Returns Milliseconds for releasing in GMT (e.g. 1480435200000 = Tue, 29 Nov 2016 16:00:00 GMT). Use nil to unset. Setting this will supercede the release_on_approval field, so this field must be nil for release_on_approval to be used.

Returns:

  • (Fixnum)

    Milliseconds for releasing in GMT (e.g. 1480435200000 = Tue, 29 Nov 2016 16:00:00 GMT). Use nil to unset. Setting this will supercede the release_on_approval field, so this field must be nil for release_on_approval to be used.


64
65
66
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 64

def auto_release_date
  @auto_release_date
end

#build_versionString

Returns Build Version.

Returns:


47
48
49
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 47

def build_version
  @build_version
end

#can_beta_testBool

Returns:

  • (Bool)

70
71
72
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 70

def can_beta_test
  @can_beta_test
end

#can_prepare_for_uploadBool

Returns:

  • (Bool)

53
54
55
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 53

def can_prepare_for_upload
  @can_prepare_for_upload
end

#can_reject_versionBool

Returns:

  • (Bool)

50
51
52
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 50

def can_reject_version
  @can_reject_version
end

#can_send_version_liveBool

Returns:

  • (Bool)

56
57
58
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 56

def can_send_version_live
  @can_send_version_live
end

Returns The copyright information of this app.

Returns:

  • (String)

    The copyright information of this app


31
32
33
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 31

def copyright
  @copyright
end

#descriptionHash (readonly)

Returns A hash representing the description in all languages.

Returns:

  • (Hash)

    A hash representing the description in all languages


178
179
180
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 178

def description
  @description
end

#in_app_purchasesHash (readonly)

Returns A hash representing all in-app purchases that can get submitted with this version.

Returns:

  • (Hash)

    A hash representing all in-app purchases that can get submitted with this version


196
197
198
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 196

def in_app_purchases
  @in_app_purchases
end

#is_liveBool

Returns Is that the version that's currently available in the App Store?.

Returns:

  • (Bool)

    Is that the version that's currently available in the App Store?


41
42
43
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 41

def is_live
  @is_live
end

#keywordsHash (readonly)

Returns A hash representing the keywords in all languages.

Returns:

  • (Hash)

    A hash representing the keywords in all languages


172
173
174
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 172

def keywords
  @keywords
end

#languagesArray

Returns Raw access the all available languages. You shouldn't use it probably.

Returns:

  • (Array)

    Raw access the all available languages. You shouldn't use it probably


169
170
171
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 169

def languages
  @languages
end

#large_app_iconSpaceship::Tunes::AppImage

Returns the structure containing information about the large app icon (1024x1024).

Returns:


76
77
78
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 76

def large_app_icon
  @large_app_icon
end

#marketing_urlHash (readonly)

Returns A hash representing the marketing url in all languages.

Returns:

  • (Hash)

    A hash representing the marketing url in all languages


187
188
189
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 187

def marketing_url
  @marketing_url
end

#phased_releaseHash (readonly)

Returns Represents the phased_release hash (read-only) For now, please use the `toggle_phased_release` method and call `.save!` as the API will probably change in the future.

Returns:

  • (Hash)

    Represents the phased_release hash (read-only) For now, please use the `toggle_phased_release` method and call `.save!` as the API will probably change in the future


201
202
203
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 201

def phased_release
  @phased_release
end

#platformString

Returns The platform value of this version.

Returns:

  • (String)

    The platform value of this version.


25
26
27
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 25

def platform
  @platform
end

#promotional_textHash (readonly)

Returns A hash representing the promotionalText in all languages.

Returns:

  • (Hash)

    A hash representing the promotionalText in all languages


175
176
177
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 175

def promotional_text
  @promotional_text
end

#ratings_resetBool

Returns Should the rating of the app be reset?.

Returns:

  • (Bool)

    Should the rating of the app be reset?


67
68
69
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 67

def ratings_reset
  @ratings_reset
end

#raw_statusString

Returns App Status (e.g. 'readyForSale'). You should use `app_status` instead.

Returns:

  • (String)

    App Status (e.g. 'readyForSale'). You should use `app_status` instead


44
45
46
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 44

def raw_status
  @raw_status
end

#release_notesHash (readonly)

Returns The changelog.

Returns:

  • (Hash)

    The changelog


181
182
183
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 181

def release_notes
  @release_notes
end

#release_on_approvalObject

These methods takes care of properly parsing values that are not returned in the right format, e.g. boolean as string


59
60
61
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 59

def release_on_approval
  @release_on_approval
end

#review_attachment_fileSpaceship::Tunes::AppReviewAttachment

Returns the structure containing information about the review attachment file.

Returns:


85
86
87
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 85

def review_attachment_file
  @review_attachment_file
end

#review_demo_passwordString

Returns App Review Information Demo Account Password.

Returns:

  • (String)

    App Review Information Demo Account Password


159
160
161
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 159

def review_demo_password
  @review_demo_password
end

#review_demo_userString

Returns App Review Information Demo Account User Name.

Returns:

  • (String)

    App Review Information Demo Account User Name


156
157
158
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 156

def review_demo_user
  @review_demo_user
end

#review_emailString

Returns App Review Information Email Address.

Returns:

  • (String)

    App Review Information Email Address


148
149
150
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 148

def review_email
  @review_email
end

#review_first_nameString

App Review Information

Returns:

  • (String)

    App Review Information First Name


139
140
141
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 139

def review_first_name
  @review_first_name
end

#review_last_nameString

Returns App Review Information Last Name.

Returns:

  • (String)

    App Review Information Last Name


142
143
144
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 142

def review_last_name
  @review_last_name
end

#review_notesString

Returns App Review Information Notes.

Returns:

  • (String)

    App Review Information Notes


162
163
164
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 162

def review_notes
  @review_notes
end

#review_phone_numberString

Returns App Review Information Phone Number.

Returns:

  • (String)

    App Review Information Phone Number


145
146
147
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 145

def review_phone_number
  @review_phone_number
end

#review_user_neededBoolean (readonly)

Returns The checkbox that indiciates if a demo account is needed. Is set automatically depending on if a user and pass are set.

Returns:

  • (Boolean)

    The checkbox that indiciates if a demo account is needed. Is set automatically depending on if a user and pass are set


153
154
155
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 153

def review_user_needed
  @review_user_needed
end

#screenshotsHash (readonly)

Returns Represents the screenshots of this app version (read-only).

Returns:

  • (Hash)

    Represents the screenshots of this app version (read-only)


190
191
192
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 190

def screenshots
  @screenshots
end

#support_urlHash (readonly)

Returns A hash representing the support url in all languages.

Returns:

  • (Hash)

    A hash representing the support url in all languages


184
185
186
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 184

def support_url
  @support_url
end

#supports_apple_watchBool

Returns Does the binary contain a watch binary?.

Returns:

  • (Bool)

    Does the binary contain a watch binary?


73
74
75
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 73

def supports_apple_watch
  @supports_apple_watch
end

#trade_representative_address_line_1String

Returns Trade Representative Contact Information Address Line 1.

Returns:

  • (String)

    Trade Representative Contact Information Address Line 1


106
107
108
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 106

def trade_representative_address_line_1
  @trade_representative_address_line_1
end

#trade_representative_address_line_2String

Returns Trade Representative Contact Information Address Line 2.

Returns:

  • (String)

    Trade Representative Contact Information Address Line 2


109
110
111
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 109

def trade_representative_address_line_2
  @trade_representative_address_line_2
end

#trade_representative_address_line_3String

Returns Trade Representative Contact Information Address Line 3.

Returns:

  • (String)

    Trade Representative Contact Information Address Line 3


112
113
114
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 112

def trade_representative_address_line_3
  @trade_representative_address_line_3
end

#trade_representative_city_nameString

Returns Trade Representative Contact Information City Name.

Returns:

  • (String)

    Trade Representative Contact Information City Name


115
116
117
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 115

def trade_representative_city_name
  @trade_representative_city_name
end

#trade_representative_countryString

Returns Trade Representative Contact Information Country.

Returns:

  • (String)

    Trade Representative Contact Information Country


121
122
123
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 121

def trade_representative_country
  @trade_representative_country
end

#trade_representative_emailString

Returns Trade Representative Contact Information Email Address.

Returns:

  • (String)

    Trade Representative Contact Information Email Address


130
131
132
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 130

def trade_representative_email
  @trade_representative_email
end

#trade_representative_first_nameString

Returns Trade Representative Contact Information First Name.

Returns:

  • (String)

    Trade Representative Contact Information First Name


100
101
102
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 100

def trade_representative_first_name
  @trade_representative_first_name
end

#trade_representative_is_displayed_on_app_storeBoolean

Returns Display Trade Representative Contact Information on the Korean App Store or not.

Returns:

  • (Boolean)

    Display Trade Representative Contact Information on the Korean App Store or not


133
134
135
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 133

def trade_representative_is_displayed_on_app_store
  @trade_representative_is_displayed_on_app_store
end

#trade_representative_last_nameString

Returns Trade Representative Contact Information Last Name.

Returns:

  • (String)

    Trade Representative Contact Information Last Name


103
104
105
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 103

def trade_representative_last_name
  @trade_representative_last_name
end

#trade_representative_phone_numberString

Returns Trade Representative Contact Information Phone Number.

Returns:

  • (String)

    Trade Representative Contact Information Phone Number


127
128
129
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 127

def trade_representative_phone_number
  @trade_representative_phone_number
end

#trade_representative_postal_codeString

Returns Trade Representative Contact Information Postal Code.

Returns:

  • (String)

    Trade Representative Contact Information Postal Code


124
125
126
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 124

def trade_representative_postal_code
  @trade_representative_postal_code
end

#trade_representative_stateString

Returns Trade Representative Contact Information State.

Returns:

  • (String)

    Trade Representative Contact Information State


118
119
120
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 118

def trade_representative_state
  @trade_representative_state
end

#trade_representative_trade_nameString

Trade Representative Contact Information

Returns:

  • (String)

    Trade Representative Contact Information Trade Name. This attribute isn't editable


97
98
99
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 97

def trade_representative_trade_name
  @trade_representative_trade_name
end

#trailersHash (readonly)

Returns Represents the trailers of this app version (read-only).

Returns:

  • (Hash)

    Represents the trailers of this app version (read-only)


193
194
195
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 193

def trailers
  @trailers
end

#transit_app_fileSpaceship::Tunes::TransitAppFile

GeoJson

Returns:


91
92
93
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 91

def transit_app_file
  @transit_app_file
end

#versionString

Returns The version number of this version.

Returns:

  • (String)

    The version number of this version


28
29
30
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 28

def version
  @version
end

#version_idInteger

Returns a unqiue ID for this version generated by App Store Connect.

Returns:

  • (Integer)

    a unqiue ID for this version generated by App Store Connect


82
83
84
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 82

def version_id
  @version_id
end

#watch_app_iconSpaceship::Tunes::AppImage

Returns the structure containing information about the large watch icon (1024x1024).

Returns:


79
80
81
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 79

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.


275
276
277
278
279
280
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 275

def factory(attrs)
  obj = self.new(attrs)
  obj.unfold_languages

  return obj
end

.find(application, app_id, is_live, platform: nil) ⇒ Object

Parameters:


285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 285

def find(application, app_id, is_live, platform: nil)
  # we only support applications
  raise "We do not support BUNDLE types right now" if application.type == 'BUNDLE'

  # too bad the "id" field is empty, it forces us to make more requests to the server
  # these could also be cached
  attrs = client.app_version(app_id, is_live, platform: platform)
  return nil unless attrs

  attrs[:application] = application
  attrs[:is_live] = is_live

  return self.factory(attrs)
end

Instance Method Details

#candidate_buildsObject

Returns an array of all builds that can be sent to review


346
347
348
349
350
351
352
353
354
355
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 346

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.
    attrs[:apple_id] = self.application.apple_id
    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


314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 314

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

#current_build_numberObject


335
336
337
338
339
340
341
342
343
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 335

def current_build_number
  if self.is_live?
    build_version
  else
    if candidate_builds.length > 0
      candidate_builds.sort_by(&:upload_date).last.build_version
    end
  end
end

#generate_image_metadata(image_data, original_file_name) ⇒ Object

This method will generate the required keys/values for App Store Connect to validate the uploaded image


437
438
439
440
441
442
443
444
445
446
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 437

def (image_data, original_file_name)
  {
    assetToken: image_data["token"],
    originalFileName: original_file_name,
    size: image_data["length"],
    height: image_data["height"],
    width: image_data["width"],
    checksum: image_data["md5"]
  }
end

#generate_promocodes!(quantity) ⇒ Object


686
687
688
689
690
691
692
693
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 686

def generate_promocodes!(quantity)
  data = client.generate_app_version_promocodes!(
    app_id: self.application.apple_id,
    version_id: self.version_id,
    quantity: quantity
  )
  Tunes::AppVersionGeneratedPromocodes.factory(data)
end

#generate_review_attachment_file(review_attachment_data, review_attachment_file) ⇒ Object

This method will generate the required keys/values for App Store Connect to validate the review attachment file


450
451
452
453
454
455
456
457
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 450

def generate_review_attachment_file(review_attachment_data, review_attachment_file)
  {
    assetToken: review_attachment_data["token"],
    name: File.basename(review_attachment_file),
    fileType: Utilities.content_type(review_attachment_file),
    url: nil
  }
end

#is_live?Bool

Returns Is that version currently available in the App Store?.

Returns:

  • (Bool)

    Is that version currently available in the App Store?


302
303
304
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 302

def is_live?
  is_live
end

#reject!Object


705
706
707
708
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 705

def reject!
  raise 'Version not rejectable' unless can_reject_version
  client.reject!(self.application.apple_id, self.version_id)
end

#release!Object


675
676
677
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 675

def release!
  client.release!(self.application.apple_id, self.version_id)
end

#release_to_all_users!Object


679
680
681
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 679

def release_to_all_users!
  client.release_to_all_users!(self.application.apple_id, self.version_id)
end

#save!Object

Push all changes that were made back to App Store Connect


411
412
413
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 411

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


360
361
362
363
364
365
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 360

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

#setupObject

Private methods


423
424
425
426
427
428
429
430
431
432
433
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 423

def setup
  status = raw_data['status']
  @app_status = Tunes::AppStatus.get_from_string(status)

  setup_large_app_icon
  setup_watch_app_icon
  setup_review_attachment_file if supports_review_attachment_file?
  setup_transit_app_file if supports_app_transit?
  setup_screenshots
  setup_trailers
end

#toggle_phased_release(enabled: false) ⇒ Object

Currently phased_release doesn't seem to have all the features enabled

=> {"state"=>{"value"=>"NOT_STARTED", "isEditable"=>true, "isRequired"=>false, "errorKeys"=>nil},
   "startDate"=>nil,
   "lastPaused"=>nil,
   "pausedDuration"=>nil,
   "totalPauseDays"=>30,
   "currentDayNumber"=>nil,
   "dayPercentageMap"=>{"1"=>1, "2"=>2, "3"=>5, "4"=>10, "5"=>20, "6"=>50, "7"=>100},
   "isEnabled"=>true}

214
215
216
217
218
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 214

def toggle_phased_release(enabled: false)
  state = (enabled ? "INACTIVE" : "NOT_STARTED")

  self.phased_release["state"]["value"] = state
end

#unfold_languagesObject

Prefill name, keywords, etc…


662
663
664
665
666
667
668
669
670
671
672
673
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 662

def unfold_languages
  {
    keywords: :keywords,
    description: :description,
    supportUrl: :support_url,
    marketingUrl: :marketing_url,
    releaseNotes: :release_notes,
    promotionalText: :promotional_text
  }.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 docs.fastlane.tools/actions/deliver/#reference


378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 378

def update_rating(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

Parameters:

  • icon_path (String)

    : The path to the geojson file. Use nil to remove it


487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 487

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

Parameters:

  • icon_path (String)

    : The path to the icon. Use nil to remove it


461
462
463
464
465
466
467
468
469
470
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 461

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)

  raw_data["largeAppIcon"]["value"] = (image_data, upload_image.file_name)
end

#upload_review_attachment!(review_attachment_path) ⇒ Object

Uploads, app review attachments

while submitting for review, ITC allow developers to attach file.

Following list can be found at appstoreconnect.apple.com on iOS app edit version, above the attachment label/button there is a question mark if it is press the a dialog is shown which has the list.

File types allowed by Apple are: pdf, doc, docx, rtf, pages, xls, xlsx, numbers zip, rar, plist, crash, jpg, png, mp4 or avi.

Parameters:

  • review_attachment_path (String)

    : The path to the attachment file.


646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 646

def upload_review_attachment!(review_attachment_path)
  raise 'cannot upload review attachment for live edition.' if self.is_live?

  if !review_attachment_path || review_attachment_path.size < 1
    @review_attachment_file.reset!
    return
  end

  raise "cannot find file: #{review_attachment_path}." unless File.exist?(review_attachment_path)

  review_attachment_file = UploadFile.from_path(review_attachment_path)
  review_attachment_data = client.upload_app_review_attachment(self, review_attachment_file)
  raw_data["appReviewInfo"]["attachmentFiles"]["value"] = generate_review_attachment_file(review_attachment_data, review_attachment_path)
end

#upload_screenshot!(screenshot_path, sort_order, language, device, is_messages) ⇒ Object

Uploads or removes a screenshot

Parameters:

  • icon_path (String)

    : The path to the screenshot. Use nil to remove it

  • sort_order (Fixnum)

    : The sort_order, from 1 to 5

  • language (String)

    : The language for this screenshot

  • device (string)

    : The device for this screenshot

  • is_messages (Bool)

    : True if the screenshot is for iMessage


509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 509

def upload_screenshot!(screenshot_path, sort_order, language, device, is_messages)
  raise "sort_order must be higher than 0" unless sort_order > 0
  raise "sort_order must not be > 10" if sort_order > 10
  # this will also check both language and device parameters
  device_lang_screenshots = screenshots_data_for_language_and_device(language, device, is_messages)["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, is_messages)

    # Since October 2016 we also need to pass the size, height, width and checksum
    # otherwise App Store Connect validation will fail at a later point
    new_screenshot = {
      "value" => {
        "assetToken" => screenshot_data["token"],
        "sortOrder" => sort_order,
        "originalFileName" => upload_file.file_name,
        "size" => screenshot_data["length"],
        "height" => screenshot_data["height"],
        "width" => screenshot_data["width"],
        "checksum" => screenshot_data["md5"]
      }
    }

    # We disable "scaling" for this device type / language combination
    # We only set this, if we actually successfully uploaded a new screenshot
    # for this device / language combination
    # if this value is not set, iTC will fallback to another device type for screenshots
    language_details = raw_data_details.find { |d| d["language"] == language }["displayFamilies"]["value"]
    device_language_details = language_details.find { |display_family| display_family['name'] == device }
    scaled_key = is_messages ? "messagesScaled" : "scaled"
    device_language_details[scaled_key]["value"] = false

    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, sort_order, language, device, timestamp = "05.00", preview_image_path = nil) ⇒ Object

Uploads, removes a trailer video

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 not 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: to extract its resolution and a screenshot preview, the `ffmpeg` tool will be used

Parameters:

  • trailer_path (String)

    : The path to the trailer. Use nil to remove it

  • sort_order (Fixnum)

    : The sort_order, from 1 to 5

  • language (String)

    : The language for this screenshot

  • device (String)

    : The device for this screenshot

  • timestamp (String) (defaults to: "05.00")

    : The optional timestamp of the screenshot to grab

  • preview_image_path (String) (defaults to: nil)

    : The optional image path for the video preview


574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 574

def upload_trailer!(trailer_path, sort_order, language, device, timestamp = "05.00", preview_image_path = nil)
  raise "No app trailer supported for iphone35" if device == 'iphone35'
  raise "sort_order must be higher than 0" unless sort_order > 0
  raise "sort_order must not be > 3" if sort_order > 3

  device_lang_trailers = trailer_data_for_language_and_device(language, device)["value"]
  existing_sort_orders = device_lang_trailers.map { |s| s["value"]["sortPosition"] }

  if trailer_path # adding / replacing trailer
    raise "Invalid timestamp #{timestamp}" if (timestamp =~ /^[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)

      # Keep a reference of the video_preview here to avoid Ruby getting rid of the Tempfile in the meanwhile
      video_preview = Utilities.grab_video_preview(trailer_path, timestamp, video_preview_resolution)
      video_preview_path = video_preview.path
    end
    video_preview_file = UploadFile.from_path(video_preview_path)
    video_preview_data = client.upload_trailer_preview(self, video_preview_file, device)

    upload_file = UploadFile.from_path(trailer_path)
    trailer_data = client.upload_trailer(self, upload_file)

    ts = "00:00:#{timestamp}"
    ts[8] = ':'

    new_trailer = {
      "value" => {
        "videoAssetToken" => trailer_data["responses"][0]["token"],
        "descriptionXML" => trailer_data["responses"][0]["descriptionDoc"],
        "contentType" => upload_file.content_type,
        "sortPosition" => sort_order,
        "size" => video_preview_data["length"],
        "width" => video_preview_data["width"],
        "height" => video_preview_data["height"],
        "checksum" => video_preview_data["md5"],
        "pictureAssetToken" => video_preview_data["token"],
        "previewFrameTimeCode" => ts.to_s,
        "isPortrait" => Utilities.portrait?(video_preview_path)
      }
    }

    if existing_sort_orders.include?(sort_order) # replace
      device_lang_trailers[existing_sort_orders.index(sort_order)] = new_trailer
    else # add
      device_lang_trailers << new_trailer
    end
  else # removing trailer
    raise "cannot remove trailer with non existing sort_order" unless existing_sort_orders.include?(sort_order)
    device_lang_trailers.delete_at(existing_sort_orders.index(sort_order))
  end
  setup_trailers
end

#upload_watch_icon!(icon_path) ⇒ Object

Uploads or removes the watch icon

Parameters:

  • icon_path (String)

    : The path to the icon. Use nil to remove it


474
475
476
477
478
479
480
481
482
483
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 474

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)

  raw_data["watchAppIcon"]["value"] = (image_data, upload_image.file_name)
end

#urlString

Returns An URL to this specific resource. You can enter this URL into your browser.

Returns:

  • (String)

    An URL to this specific resource. You can enter this URL into your browser


416
417
418
419
420
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 416

def url
  url = "https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/#{application.apple_id}/#{self.platform}/versioninfo/"
  url += "deliverable" if self.is_live?
  return url
end