zendesk_apps_tools 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,14 +2,13 @@ require 'faraday'
2
2
 
3
3
  module ZendeskAppsTools
4
4
  module Common
5
- def api_request(url, user, password, request = Faraday.new)
6
- request.basic_auth(user, password)
5
+ def api_request(url, request = Faraday.new)
7
6
  request.get(url)
8
7
  end
9
8
 
10
9
  def get_value_from_stdin(prompt, opts = {})
11
10
  options = {
12
- :valid_regex => opts[:allow_empty] ? /^\w*$/ : /\S+/,
11
+ :valid_regex => opts[:allow_empty] ? /^.*$/ : /\S+/,
13
12
  :error_msg => 'Invalid, try again:',
14
13
  :allow_empty => false
15
14
  }.merge(opts)
@@ -2,9 +2,9 @@ module ZendeskAppsTools
2
2
  class LocaleIdentifier
3
3
  attr_reader :language_id
4
4
 
5
- # Convert :"en-US-x-12" to 'en'
5
+ # Convert :"en-US-x-12" to 'en-US'
6
6
  def initialize(code)
7
- @language_id = code.sub(/-.*/, '')
7
+ @language_id = code.sub(/-x-.*/, '')
8
8
  end
9
9
  end
10
10
  end
@@ -10,7 +10,7 @@ module ZendeskAppsTools
10
10
  include ZendeskAppsTools::Common
11
11
 
12
12
  CHARACTERS_TO_ESCAPE = %w[ " ]
13
- LOCALE_ENDPOINT = "https://support.zendesk.com/api/v2/locales.json"
13
+ LOCALE_ENDPOINT = "https://support.zendesk.com/api/v2/locales/agent.json"
14
14
 
15
15
  desc 'create', 'Create Zendesk translation file from en.json'
16
16
  def create
@@ -29,21 +29,19 @@ module ZendeskAppsTools
29
29
  desc 'update', 'Update translation files from Zendesk'
30
30
  def update(request_builder = Faraday.new)
31
31
  app_package = get_value_from_stdin("What is the package name for this app? (without app_)", :valid_regex => /^[a-z_]+$/, :error_msg => "Invalid package name, try again:")
32
- user = get_value_from_stdin("What is your support.zendesk.com username?", :valid_regex => /^.+@.+\..+$/, :error_msg => "Invalid email, try again:")
33
- token = get_value_from_stdin("What is your support.zendesk.com API token?", :error_msg => "Invalid API token, try again:")
34
32
 
35
33
  user = "#{user}/token"
36
34
  key_prefix = "txt.apps.#{app_package}."
37
35
 
38
36
  say("Fetching translations...")
39
- locale_response = api_request(LOCALE_ENDPOINT, user, token, request_builder)
37
+ locale_response = api_request(LOCALE_ENDPOINT, request_builder)
40
38
 
41
39
  if locale_response.status == 200
42
40
  locales = JSON.parse(locale_response.body)["locales"]
43
41
 
44
42
  locales.each do |locale|
45
43
  locale_url = "#{locale["url"]}?include=translations&packages=app_#{app_package}"
46
- locale_response = api_request(locale_url, user, token, request_builder).body
44
+ locale_response = api_request(locale_url, request_builder).body
47
45
  translations = JSON.parse(locale_response)['locale']['translations']
48
46
 
49
47
  locale_name = ZendeskAppsTools::LocaleIdentifier.new(locale['locale']).language_id
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.4.0
4
+ version: 1.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-10-02 00:00:00.000000000 Z
15
+ date: 2013-10-26 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: thor
@@ -85,7 +85,7 @@ dependencies:
85
85
  requirements:
86
86
  - - ~>
87
87
  - !ruby/object:Gem::Version
88
- version: 1.5.0
88
+ version: 1.6.0
89
89
  type: :runtime
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ dependencies:
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: 1.5.0
96
+ version: 1.6.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: cucumber
99
99
  requirement: !ruby/object:Gem::Requirement