lib/spaceship/tunes/tunes_client.rb in spaceship-0.34.1 vs lib/spaceship/tunes/tunes_client.rb in spaceship-0.34.2
- old
+ new
@@ -139,18 +139,24 @@
data.fetch('validationErrors', []).count == 0
logger.debug("Request was successful")
end
- handle_response_hash = lambda do |hash|
+ # We pass on the `current_language` so that the error message tells the user
+ # what language the error was caused in
+ handle_response_hash = lambda do |hash, current_language = nil|
errors = []
- if hash.kind_of? Hash
+ if hash.kind_of?(Hash)
+ current_language ||= hash["language"]
+
hash.each do |key, value|
- errors += handle_response_hash.call(value)
+ errors += handle_response_hash.call(value, current_language)
- if key == 'errorKeys' and value.kind_of? Array and value.count > 0
- errors += value
+ next unless key == 'errorKeys' and value.kind_of?(Array) and value.count > 0
+ # Prepend the error with the language so it's easier to understand for the user
+ errors += value.collect do |current_error_message|
+ current_language ? "[#{current_language}]: #{current_error_message}" : current_error_message
end
end
elsif hash.kind_of? Array
hash.each do |value|
errors += handle_response_hash.call(value)
@@ -813,9 +819,42 @@
update_tester_from_app!(tester, app_id, true)
end
def remove_tester_from_app!(tester, app_id)
update_tester_from_app!(tester, app_id, false)
+ end
+
+ #####################################################
+ # @!group Sandbox Testers
+ #####################################################
+ def sandbox_testers(tester_class)
+ url = tester_class.url[:index]
+ r = request(:get, url)
+ parse_response(r, 'data')
+ end
+
+ def create_sandbox_tester!(tester_class: nil, email: nil, password: nil, first_name: nil, last_name: nil, country: nil)
+ url = tester_class.url[:create]
+ r = request(:post) do |req|
+ req.url url
+ req.body = {
+ user: {
+ emailAddress: { value: email },
+ password: { value: password },
+ confirmPassword: { value: password },
+ firstName: { value: first_name },
+ lastName: { value: last_name },
+ storeFront: { value: country },
+ birthDay: { value: 1 },
+ birthMonth: { value: 1 },
+ secretQuestion: { value: 'secret_question' },
+ secretAnswer: { value: 'secret_answer' },
+ sandboxAccount: nil
+ }
+ }.to_json
+ req.headers['Content-Type'] = 'application/json'
+ end
+ parse_response(r, 'data')['user']
end
#####################################################
# @!group State History
#####################################################