class Spaceship::Tunes::BuildTrain

A build train is all builds for a given version number with different build numbers
Represents a build train of builds from iTunes Connect

def all(application, app_id)

Parameters:
  • app_id (String) -- The unique Apple ID of this app
  • application (Spaceship::Tunes::Application) -- The app this train is for
def all(application, app_id)
  trains = []
  trains += client.build_trains(app_id, 'internal')['trains']
  trains += client.build_trains(app_id, 'external')['trains']
  result = {}
  trains.each do |attrs|
    attrs.merge!(application: application)
    current = self.factory(attrs)
    result[current.version_string] = current
  end
  result
end

def factory(attrs)

This is used to create a new object based on the server response.
Create a new object based on a hash.
def factory(attrs)
  self.new(attrs)
end

def setup

Setup all the builds and processing builds
def setup
  super
  @builds = self.raw_data['builds'].collect do |attrs|
    attrs.merge!(build_train: self)
    Tunes::Build.factory(attrs)
  end
  @processing_builds = self.raw_data['buildsInProcessing'].collect do |attrs|
    attrs.merge!(build_train: self)
    Tunes::Build.factory(attrs)
  end
end

def update_testing_status!(new_value, testing_type)

Parameters:
  • internal (testing_type) -- or external
def update_testing_status!(new_value, testing_type)
  data = client.build_trains(self.application.apple_id, testing_type)
  data['trains'].each do |train|
    train["#{testing_type}Testing"]['value'] = false
    train["#{testing_type}Testing"]['value'] = new_value if train['versionString'] == version_string
  end
  result = client.update_build_trains!(application.apple_id, testing_type, data)
  self.internal_testing_enabled = new_value if testing_type == 'internal'
  self.external_testing_enabled = new_value if testing_type == 'external'
  result
end