zendesk_apps_tools 1.35.6 → 1.35.7

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: a16ff81f2c559975ffe14851772b7ad58d7f267d
4
- data.tar.gz: 4fc8871cdf0c0f1b93c3758b528ee19bbb408adc
3
+ metadata.gz: 5ba8180c50299cbb9a0a0962b5daff06397e1af3
4
+ data.tar.gz: ae6b706f7df25ce52d1a8c0fedde3797d7aa6f58
5
5
  SHA512:
6
- metadata.gz: b788e2e60e376a44be8f6381a128760d555af0b2be885f77877d4fe7a6b84ca38b72bad030ab10d611c7360df1b72fd8041f35124a20e5f8221d249db929e76a
7
- data.tar.gz: 3703cf757451fff4a303841b70cbacde79cb1a49c120157562e0f1bb1a07f930daccc8bf80bdb76e3545fa69b2c4ec4f86cb34f13078ff4c01ada8b8fb290c6a
6
+ metadata.gz: 33c85b0dbddc5c5f9f6add771f0944b81b4200fa732b7c5d43fdd8befda4558f510fff0d4169f6ef1abd1d1c375e9fb57496d93912be54698bb2a8d84e172ff6
7
+ data.tar.gz: c9749875486bbf63c2182e4802720a72f840b914f4733531ace48c2a22ad1ecbe89b8ba376fe7e6f463d8c737994b3a4fb3f1e3b3accbe8a30c3e1c8b4d434a7
@@ -5,7 +5,7 @@
5
5
  <script type="text/javascript" src="https://assets.zendesk.com/apps/sdk/2.0/zaf_sdk.js"></script>
6
6
  <script>
7
7
  // Initialise the Zendesk JavaScript API client
8
- // https://developer.zendesk.com/apps/docs/agent/zaf_v2
8
+ // https://developer.zendesk.com/apps/docs/apps-v2
9
9
  var client = ZAFClient.init();
10
10
  client.invoke('resize', { width: '100%', height: '400px' });
11
11
  </script>
@@ -63,6 +63,13 @@ module ZendeskAppsTools
63
63
  password
64
64
  end
65
65
 
66
+ def json_or_die(value)
67
+ require 'json'
68
+ JSON.parse(value)
69
+ rescue JSON::ParserError
70
+ say_error_and_exit value
71
+ end
72
+
66
73
  private
67
74
 
68
75
  def error_if_unattended(prompt)
@@ -30,9 +30,9 @@ module ZendeskAppsTools
30
30
  payload = { uploaded_data: Faraday::UploadIO.new(package_path, 'application/zip') }
31
31
 
32
32
  response = connection.post('/api/v2/apps/uploads.json', payload)
33
- JSON.parse(response.body)['id']
33
+ json_or_die(response.body)['id']
34
34
 
35
- rescue Faraday::Error::ClientError, JSON::ParserError => e
35
+ rescue Faraday::Error::ClientError => e
36
36
  say_error_and_exit e.message
37
37
  end
38
38
 
@@ -44,7 +44,7 @@ module ZendeskAppsTools
44
44
 
45
45
  all_apps = connection.get('/api/v2/apps.json').body
46
46
 
47
- app_json = JSON.parse(all_apps)['apps'].find { |app| app['name'] == name }
47
+ app_json = json_or_die(all_apps)['apps'].find { |app| app['name'] == name }
48
48
  say_error_and_exit('The app was not found. Please verify your credentials, subdomain, and app name are correct.') unless app_json
49
49
  app_id = app_json['id']
50
50
 
@@ -56,7 +56,7 @@ module ZendeskAppsTools
56
56
 
57
57
  def check_status(response)
58
58
  job = response.body
59
- job_response = JSON.parse(job)
59
+ job_response = json_or_die(job)
60
60
  say_error_and_exit job_response['error'] if job_response['error']
61
61
 
62
62
  job_id = job_response['job_id']
@@ -68,7 +68,7 @@ module ZendeskAppsTools
68
68
 
69
69
  loop do
70
70
  response = connection.get("/api/v2/apps/job_statuses/#{job_id}")
71
- info = JSON.parse(response.body)
71
+ info = json_or_die(response.body)
72
72
  status = info['status']
73
73
  message = info['message']
74
74
  app_id = info['app_id']
@@ -84,7 +84,7 @@ module ZendeskAppsTools
84
84
  Thread.new do
85
85
  say("Fetching #{locale['locale']}")
86
86
  json = Faraday.get("#{locale['url']}?include=translations&packages=app_#{app_package}").body
87
- JSON.parse(json)['locale']
87
+ json_or_die(json)['locale']
88
88
  end
89
89
  end
90
90
 
@@ -170,7 +170,7 @@ module ZendeskAppsTools
170
170
  require 'faraday'
171
171
  locale_response = Faraday.get(LOCALE_ENDPOINT)
172
172
 
173
- return JSON.parse(locale_response.body)['locales'] if locale_response.status == 200
173
+ return json_or_die(locale_response.body)['locales'] if locale_response.status == 200
174
174
  if locale_response.status == 401
175
175
  say_error_and_exit 'Authentication failed'
176
176
  else
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ZendeskAppsTools
3
- VERSION = '1.35.6'
3
+ VERSION = '1.35.7'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_apps_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.35.6
4
+ version: 1.35.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-10-25 00:00:00.000000000 Z
14
+ date: 2016-10-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor