Class: MotionProvisioning::Application
- Inherits:
-
Object
- Object
- MotionProvisioning::Application
- Defined in:
- lib/motion-provisioning/application.rb
Class Method Summary collapse
-
.find_or_create(bundle_id: nil, name: nil, mac: false) ⇒ Object
Finds or create app for the given bundle id and name.
Class Method Details
.find_or_create(bundle_id: nil, name: nil, mac: false) ⇒ Object
Finds or create app for the given bundle id and name
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/motion-provisioning/application.rb', line 4 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 |