spaceship 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf8ca41ac0b946d578d855c3a431cae89fb3f0f2
4
- data.tar.gz: 06a07235c238b5897db26524f4c7c08893f80bb9
3
+ metadata.gz: efa1b4e8b3db202da5e7986548e0dcea255001ee
4
+ data.tar.gz: 56647e6df8b7dba71255a2926f99877c67f6fc0d
5
5
  SHA512:
6
- metadata.gz: 4b911d4da0a67be7a23ced00ec77d7d27dcdf9750f6197519f46ae2493bf4b15e191c2a74d22ea42deb162035b322c2d0439a61765b83989c7fe0d1c0f579db5
7
- data.tar.gz: c2a748e0fb3bb4d7a6b648fc575d2709377aacbe58ea4ee4f68d08383095f8c280f6bc8421d311638758c465689e5e4266739733145c1bbb8637c8fedc60a23b
6
+ metadata.gz: f7726bf84f6a72ef2e2c166f81010496c044e4c7f24aca2aca660c180ebf872c85d230fcb4a504adf6776883c297826dba5671675668e015a424ec3a22f1a4e4
7
+ data.tar.gz: 448f9f093b28462f4ab451e5e0daa273a78b557b6c17aec50dcf738252267e7b47687b519322f765767714c7f2de32eef7a2ed0bc2e3bfa529431c62afb2c280
@@ -14,6 +14,8 @@ module Spaceship
14
14
  # @return (Boolean) Submitted for Review
15
15
  attr_accessor :submitted_for_review
16
16
 
17
+ # To pass from the user
18
+
17
19
  # @return (Boolean) Ad ID Info - Limits ads tracking
18
20
  attr_accessor :add_id_info_limits_tracking
19
21
 
@@ -66,7 +68,6 @@ module Spaceship
66
68
  attr_accessor :export_compliance_platform
67
69
 
68
70
  attr_mapping({
69
-
70
71
  # Ad ID Info Section
71
72
  'adIdInfo.limitsTracking.value' => :add_id_info_limits_tracking,
72
73
  'adIdInfo.servesAds.value' => :add_id_info_serves_ads,
@@ -2,6 +2,7 @@ module Spaceship
2
2
  module Tunes
3
3
  # Represents an editable version of an iTunes Connect Application
4
4
  # This can either be the live or the edit version retrieved via the app
5
+ # rubocop:disable Metrics/ClassLength
5
6
  class AppVersion < TunesBase
6
7
  # @return (Spaceship::Tunes::Application) A reference to the application
7
8
  # this version is for
@@ -173,35 +174,27 @@ module Spaceship
173
174
  # Call this method to make sure the given languages are available for this app
174
175
  # You should call this method before accessing the name, description and other localized values
175
176
  # This will create the new language if it's not available yet and do nothing if everything's there
176
- # def create_languages!(languages)
177
- # raise "Please pass an array" unless languages.kind_of?Array
178
-
179
- # copy_from = self.languages.first
180
- # languages.each do |language|
181
- # # First, see if it's already available
182
- # found = self.languages.find do |local|
183
- # local['language'] == language
184
- # end
185
-
186
- # unless found
187
- # new_language = copy_from.dup
188
- # new_language['language'] = language
189
- # [:description, :releaseNotes, :keywords].each do |key|
190
- # new_language[key.to_s]['value'] = nil
191
- # end
192
-
193
- # self.languages << new_language
194
- # unfold_languages
195
-
196
- # # Now we need to set a useless `pageLanguageValue` value because iTC says so, after adding a new version
197
- # self.languages.each do |current|
198
- # current['pageLanguageValue'] = current['language']
199
- # end
200
- # end
201
- # end
202
-
203
- # languages
204
- # end
177
+ # Important: Due to a bug you have to fetch the `edit_version` again, as it doesn't get refreshed immediately
178
+ def create_languages(languages)
179
+ languages = [languages] if languages.kind_of?(String)
180
+ raise "Please pass an array" unless languages.kind_of? Array
181
+
182
+ copy_from = self.languages.find { |a| a['language'] == 'en-US' } || self.languages.first
183
+
184
+ languages.each do |language|
185
+ # First, see if it's already available
186
+ found = self.languages.find do |local|
187
+ local['language'] == language
188
+ end
189
+ next if found
190
+
191
+ new_language = copy_from.clone
192
+ new_language['language'] = language
193
+
194
+ self.languages << new_language
195
+ end
196
+ nil
197
+ end
205
198
 
206
199
  # Returns an array of all builds that can be sent to review
207
200
  def candidate_builds
@@ -224,9 +217,52 @@ module Spaceship
224
217
  true
225
218
  end
226
219
 
220
+ # Set the age restriction rating
221
+ # Call it like this:
222
+ # v.update_rating({
223
+ # 'CARTOON_FANTASY_VIOLENCE' => 0,
224
+ # 'MATURE_SUGGESTIVE' => 2,
225
+ # 'UNRESTRICTED_WEB_ACCESS' => 0,
226
+ # 'GAMBLING_CONTESTS' => 0
227
+ # })
228
+ #
229
+ # Available Values
230
+ # https://github.com/KrauseFx/deliver/blob/master/Reference.md
231
+ def update_rating(hash)
232
+ raise "Must be a hash" unless hash.kind_of?(Hash)
233
+
234
+ hash.each do |key, value|
235
+ to_edit = self.raw_data['ratings']['nonBooleanDescriptors'].find do |current|
236
+ current['name'].include?(key)
237
+ end
238
+
239
+ if to_edit
240
+ to_set = "NONE" if value == 0
241
+ to_set = "INFREQUENT_MILD" if value == 1
242
+ to_set = "FREQUENT_INTENSE" if value == 2
243
+ raise "Invalid value '#{value}' for '#{key}', must be 0-2" unless to_set
244
+ to_edit['level'] = "ITC.apps.ratings.level.#{to_set}"
245
+ else
246
+ # Maybe it's a boolean descriptor?
247
+ to_edit = self.raw_data['ratings']['booleanDescriptors'].find do |current|
248
+ current['name'].include?(key)
249
+ end
250
+
251
+ if to_edit
252
+ to_set = "NO"
253
+ to_set = "YES" if value.to_i > 0
254
+ to_edit['level'] = "ITC.apps.ratings.level.#{to_set}"
255
+ else
256
+ raise "Could not find option '#{key}' in the list of available options"
257
+ end
258
+ end
259
+ end
260
+ true
261
+ end
262
+
227
263
  # Push all changes that were made back to iTunes Connect
228
264
  def save!
229
- client.update_app_version!(application.apple_id, is_live?, raw_data)
265
+ client.update_app_version!(application.apple_id, self.version_id, raw_data)
230
266
  end
231
267
 
232
268
  # @return (String) An URL to this specific resource. You can enter this URL into your browser
@@ -533,5 +569,6 @@ module Spaceship
533
569
  raw_data["details"]["value"]
534
570
  end
535
571
  end
572
+ # rubocop:enable Metrics/ClassLength
536
573
  end
537
574
  end
@@ -165,6 +165,25 @@ module Spaceship
165
165
  # Future: implemented -reload method
166
166
  end
167
167
 
168
+ # Will make sure the current edit_version matches the given version number
169
+ # This will either create a new version or change the version number
170
+ # from an existing version
171
+ # @return (Bool) Was something changed?
172
+ def ensure_version!(version_number)
173
+ if (e = edit_version)
174
+ if e.version.to_s != version_number.to_s
175
+ # Update an existing version
176
+ e.version = version_number
177
+ e.save!
178
+ return true
179
+ end
180
+ return false
181
+ else
182
+ create_version!(version_number)
183
+ return true
184
+ end
185
+ end
186
+
168
187
  # set the price tier. This method doesn't require `save` to be called
169
188
  def update_price_tier!(price_tier)
170
189
  client.update_price_tier!(self.apple_id, price_tier)
@@ -223,12 +223,17 @@ module Spaceship
223
223
 
224
224
  def create_version!(app_id, version_number)
225
225
  r = request(:post) do |req|
226
- req.url "ra/apps/version/create/#{app_id}"
227
- req.body = { version: version_number.to_s }.to_json
226
+ req.url "ra/apps/#{app_id}/platforms/ios/versions/create/"
227
+ req.body = {
228
+ version: {
229
+ value: version_number.to_s
230
+ }
231
+ }.to_json
228
232
  req.headers['Content-Type'] = 'application/json'
229
233
  end
230
234
 
231
- parse_response(r, 'data')
235
+ data = parse_response(r, 'data')
236
+ handle_itc_response(data)
232
237
  end
233
238
 
234
239
  def get_resolution_center(app_id)
@@ -257,13 +262,12 @@ module Spaceship
257
262
  parse_response(r, 'data')
258
263
  end
259
264
 
260
- def update_app_version!(app_id, is_live, data)
265
+ def update_app_version!(app_id, version_id, data)
261
266
  raise "app_id is required" unless app_id
262
-
263
- v_text = (is_live ? 'live' : nil)
267
+ raise "version_id is required" unless version_id.to_i > 0
264
268
 
265
269
  r = request(:post) do |req|
266
- req.url "ra/apps/version/save/#{app_id}?v=#{v_text}"
270
+ req.url "ra/apps/#{app_id}/platforms/ios/versions/#{version_id}"
267
271
  req.body = data.to_json
268
272
  req.headers['Content-Type'] = 'application/json'
269
273
  end
@@ -557,6 +561,13 @@ module Spaceship
557
561
  end
558
562
 
559
563
  handle_itc_response(r.body)
564
+
565
+ if r.body.fetch('messages').fetch('info').last == "Successful POST"
566
+ # success
567
+ else
568
+ raise "Something went wrong when submitting the app for review. Make sure to pass valid options to submit your app for review"
569
+ end
570
+
560
571
  parse_response(r, 'data')
561
572
  end
562
573
 
@@ -1,3 +1,3 @@
1
1
  module Spaceship
2
- VERSION = "0.9.1"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spaceship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-28 00:00:00.000000000 Z
12
+ date: 2015-09-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: credentials_manager