Sha256: 51fb93594d053dfa9c82ad95e7bf822e9b91acb0bead62b2d22705dab69d5a53

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

module MotionProvisioning
  class Application
    # Finds or create app for the given bundle id and name
    def self.find_or_create(bundle_id: nil, name: nil, mac: false)
      app = Spaceship::Portal::App.find(bundle_id, mac: mac)
      if app
        app = app.details if app.features.nil?
      else
        begin
          app = Spaceship::Portal::App.create!(bundle_id: bundle_id, name: name, mac: mac)
          app = app.details if app.features.nil?
        rescue Spaceship::Client::UnexpectedResponse => e
          if e.to_s.include?("is not a valid identifier")
            Utils.log("Error", "'#{bundle_id}' is not a valid identifier for an app. Please choose an identifier containing only alphanumeric characters, dots and asterisk")
            exit(1)
          elsif e.to_s.include?("is not available")
            Utils.log("Error", "'#{bundle_id}' has already been taken. Please enter a different string.")
            exit(1)
          else
            raise(e)
          end
        end
      end

      app
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
motion-provisioning-1.1.0 lib/motion-provisioning/application.rb
motion-provisioning-1.0.4 lib/motion-provisioning/application.rb
motion-provisioning-1.0.3 lib/motion-provisioning/application.rb
motion-provisioning-1.0.2 lib/motion-provisioning/application.rb
motion-provisioning-1.0.1 lib/motion-provisioning/application.rb
motion-provisioning-1.0.0 lib/motion-provisioning/application.rb
motion-provisioning-0.0.7 lib/motion-provisioning/application.rb
motion-provisioning-0.0.6 lib/motion-provisioning/application.rb
motion-provisioning-0.0.5 lib/motion-provisioning/application.rb
motion-provisioning-0.0.4 lib/motion-provisioning/application.rb