Class: Deliver::App

Inherits:
Object
  • Object
show all
Defined in:
lib/deliver/app.rb

Defined Under Namespace

Modules: AppStatus

Updating the App Metadata collapse

Instance Attribute Summary collapse

Interacting with iTunesConnect collapse

Updating the App Metadata collapse

Destructive/Constructive methods collapse

Instance Method Summary collapse

Constructor Details

#initialize(apple_id: nil, app_identifier: nil) ⇒ App

Returns a new instance of App.

Parameters:

  • apple_id (defaults to: nil)

    The Apple ID of the app you want to modify or update. This ID has usually 9 digits

  • app_identifier (defaults to: nil)

    If you don’t pass this, it will automatically be fetched from the Apple API which means it takes longer. If you can pass the app_identifier (e.g. com.facebook.Facebook) do it



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/deliver/app.rb', line 34

def initialize(apple_id: nil, app_identifier: nil)
  self.apple_id = (apple_id || '').to_s.gsub('id', '').to_i
  self.app_identifier = app_identifier
  
  if apple_id and not app_identifier
    # Fetch the app identifier based on the given Apple ID
    self.app_identifier = Deliver::ItunesSearchApi.fetch_bundle_identifier(apple_id)
  elsif app_identifier and not apple_id
    # Fetch the Apple ID based on the given app identifier
    begin
      self.apple_id = Deliver::ItunesSearchApi.fetch_by_identifier(app_identifier)['trackId']
    rescue
      unless Helper.is_test?
        Helper.log.info "Could not find Apple ID based on the app identifier in the US App Store. Maybe the app is not yet in the store?".yellow

        while ((self.apple_id || '').to_s.length == 0) || ((self.apple_id || 0).to_i == 0)
          self.apple_id = ask("\nApple ID of your app (e.g. 284882215): ")
        end
      else
        raise "Please pass a valid Apple ID using 'apple_id'".red
      end
    end
  end
end

Instance Attribute Details

#app_identifierObject

Returns the value of attribute app_identifier.



3
4
5
# File 'lib/deliver/app.rb', line 3

def app_identifier
  @app_identifier
end

#apple_idObject

Returns the value of attribute apple_id.



3
4
5
# File 'lib/deliver/app.rb', line 3

def apple_id
  @apple_id
end

#metadataDeliver::AppMetadata

Access to update the metadata of this app

The first time accessing this, will take some time, since it’s downloading the latest version from iTC.

Don’t forget to call #upload_metadata! once you are finished

Returns:



111
112
113
# File 'lib/deliver/app.rb', line 111

def 
  @metadata
end

Instance Method Details

#create_new_version!(version_number) ⇒ Object

This method creates a new version of your app using the iTunesConnect frontend. This will happen directly after calling this method. the new version that should be created

Parameters:

  • version_number (String)

    the version number as string for



137
138
139
# File 'lib/deliver/app.rb', line 137

def create_new_version!(version_number)
  itc.create_new_version!(self, version_number)
end

#get_app_statusObject

This method fetches the current app status from iTunesConnect. This method may take some time to execute, since it uses frontend scripting under the hood.

Returns:

  • the current App Status defined at AppStatus, like “Waiting For Review”



75
76
77
# File 'lib/deliver/app.rb', line 75

def get_app_status
  itc.get_app_status(self)
end

#get_live_versionObject

This method fetches the app version of the latest published version This method may take some time to execute, since it uses frontend scripting under the hood.

Returns:

  • the currently active app version, which in production



82
83
84
# File 'lib/deliver/app.rb', line 82

def get_live_version
  itc.get_live_version(self)
end

#get_metadata_directoryObject

Returns the path to the directy in which the itmsp files will be downloaded.

Returns:

  • the path to the directy in which the itmsp files will be downloaded



98
99
100
101
102
# File 'lib/deliver/app.rb', line 98

def 
  return @metadata_dir if @metadata_dir 
  return "./spec/fixtures/packages/" if Helper.is_test?
  return "./"
end

#itcObject

The iTC handler which is used to interact with the iTunesConnect backend



68
69
70
# File 'lib/deliver/app.rb', line 68

def itc
  @itc ||= Deliver::ItunesConnect.new
end

#metadata_downloaded?Boolean

Was the app metadata already downloaded?

Returns:

  • (Boolean)


116
117
118
# File 'lib/deliver/app.rb', line 116

def 
  @metadata != nil
end

#set_metadata_directory(dir) ⇒ Object

Use this method to change the default download location for the metadata packages



92
93
94
95
# File 'lib/deliver/app.rb', line 92

def (dir)
  raise "Can not change metadata directory after accessing metadata of an app" if @metadata
  @metadata_dir = dir
end

#to_sObject



59
60
61
# File 'lib/deliver/app.rb', line 59

def to_s
  "#{apple_id} - #{app_identifier}"
end

#upload_metadata!bool

This method has to be called, after modifying the values of .metadata. It will take care of uploading all changes to Apple. This method might take a few minutes to run

Returns:

  • (bool)

    true on success

Raises:



147
148
149
150
151
# File 'lib/deliver/app.rb', line 147

def upload_metadata!
  raise "You first have to modify the metadata using app.metadata.setDescription" unless @metadata
  
  self..upload!
end