Class: Spaceship::Tunes::AppVersion

Inherits:
TunesBase show all
Defined in:
spaceship/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

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)



36
37
38
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 36

def app_status
  @app_status
end

#app_typeString



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

def app_type
  @app_type
end

#applicationSpaceship::Tunes::Application



20
21
22
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 20

def application
  @application
end

#auto_release_dateFixnum



62
63
64
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 62

def auto_release_date
  @auto_release_date
end

#build_versionString



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

def build_version
  @build_version
end

#can_beta_testBool



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

def can_beta_test
  @can_beta_test
end

#can_prepare_for_uploadBool



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

def can_prepare_for_upload
  @can_prepare_for_upload
end

#can_reject_versionBool



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

def can_reject_version
  @can_reject_version
end

#can_send_version_liveBool



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

def can_send_version_live
  @can_send_version_live
end


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

def copyright
  @copyright
end

#descriptionHash (readonly)



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

def description
  @description
end

#is_liveBool



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

def is_live
  @is_live
end

#keywordsHash (readonly)



167
168
169
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 167

def keywords
  @keywords
end

#languagesArray



164
165
166
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 164

def languages
  @languages
end

#large_app_iconSpaceship::Tunes::AppImage



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

def large_app_icon
  @large_app_icon
end

#marketing_urlHash (readonly)



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

def marketing_url
  @marketing_url
end

#phased_releaseHash (readonly)



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

def phased_release
  @phased_release
end

#platformString



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

def platform
  @platform
end

#promotional_textHash (readonly)



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

def promotional_text
  @promotional_text
end

#ratings_resetBool



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

def ratings_reset
  @ratings_reset
end

#raw_statusString



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

def raw_status
  @raw_status
end

#release_notesHash (readonly)



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

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



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

def release_on_approval
  @release_on_approval
end

#review_demo_passwordString



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

def review_demo_password
  @review_demo_password
end

#review_demo_userString



151
152
153
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 151

def review_demo_user
  @review_demo_user
end

#review_emailString



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

def review_email
  @review_email
end

#review_first_nameString

App Review Information



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

def review_first_name
  @review_first_name
end

#review_last_nameString



137
138
139
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 137

def review_last_name
  @review_last_name
end

#review_notesString



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

def review_notes
  @review_notes
end

#review_phone_numberString



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

def review_phone_number
  @review_phone_number
end

#review_user_neededBoolean (readonly)



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

def review_user_needed
  @review_user_needed
end

#screenshotsHash (readonly)



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

def screenshots
  @screenshots
end

#support_urlHash (readonly)



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

def support_url
  @support_url
end

#supports_apple_watchBool



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

def supports_apple_watch
  @supports_apple_watch
end

#trade_representative_address_line_1String



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

def trade_representative_address_line_1
  @trade_representative_address_line_1
end

#trade_representative_address_line_2String



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

def trade_representative_address_line_2
  @trade_representative_address_line_2
end

#trade_representative_address_line_3String



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

def trade_representative_address_line_3
  @trade_representative_address_line_3
end

#trade_representative_city_nameString



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

def trade_representative_city_name
  @trade_representative_city_name
end

#trade_representative_countryString



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

def trade_representative_country
  @trade_representative_country
end

#trade_representative_emailString



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

def trade_representative_email
  @trade_representative_email
end

#trade_representative_first_nameString



95
96
97
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 95

def trade_representative_first_name
  @trade_representative_first_name
end

#trade_representative_is_displayed_on_app_storeBoolean



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

def trade_representative_is_displayed_on_app_store
  @trade_representative_is_displayed_on_app_store
end

#trade_representative_last_nameString



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

def trade_representative_last_name
  @trade_representative_last_name
end

#trade_representative_phone_numberString



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

def trade_representative_phone_number
  @trade_representative_phone_number
end

#trade_representative_postal_codeString



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

def trade_representative_postal_code
  @trade_representative_postal_code
end

#trade_representative_stateString



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

def trade_representative_state
  @trade_representative_state
end

#trade_representative_trade_nameString

Trade Representative Contact Information



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

def trade_representative_trade_name
  @trade_representative_trade_name
end

#trailersHash (readonly)



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

def trailers
  @trailers
end

#transit_app_fileSpaceship::Tunes::TransitAppFile

GeoJson



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

def transit_app_file
  @transit_app_file
end

#versionString



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

def version
  @version
end

#version_idInteger



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

def version_id
  @version_id
end

#watch_app_iconSpaceship::Tunes::AppImage



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

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.



266
267
268
269
270
271
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 266

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

  return obj
end

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



276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 276

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



337
338
339
340
341
342
343
344
345
346
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 337

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



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 305

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



326
327
328
329
330
331
332
333
334
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 326

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 iTunes Connect to validate the uploaded image



427
428
429
430
431
432
433
434
435
436
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 427

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



630
631
632
633
634
635
636
637
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 630

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

#is_live?Bool



293
294
295
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 293

def is_live?
  is_live
end

#reject!Object



649
650
651
652
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 649

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

#release!Object



623
624
625
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 623

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

#save!Object

Push all changes that were made back to iTunes Connect



402
403
404
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 402

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



351
352
353
354
355
356
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 351

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



414
415
416
417
418
419
420
421
422
423
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 414

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

  setup_large_app_icon
  setup_watch_app_icon
  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}


206
207
208
209
210
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 206

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

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

#unfold_languagesObject

Prefill name, keywords, etc…



610
611
612
613
614
615
616
617
618
619
620
621
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 610

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



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
396
397
398
399
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 369

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



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 466

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



440
441
442
443
444
445
446
447
448
449
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 440

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_screenshot!(screenshot_path, sort_order, language, device, is_messages) ⇒ Object

Uploads or removes a screenshot



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 488

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 iTunes 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



553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
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
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 553

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)
      video_preview_path = Utilities.grab_video_preview(trailer_path, timestamp, video_preview_resolution)
    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



453
454
455
456
457
458
459
460
461
462
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 453

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



407
408
409
410
411
# File 'spaceship/lib/spaceship/tunes/app_version.rb', line 407

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