zend 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06d8a9f8dfc7a58be94400d7f2895ae4414b6c82
4
- data.tar.gz: 510f86a5312ce14fc1aabfc679061dc24cdb1ebb
3
+ metadata.gz: 4c1178446585c5f606205714915228b0fe248fcc
4
+ data.tar.gz: 97b9a0116551f9e79c7f1a5ed510b4c6b32703f7
5
5
  SHA512:
6
- metadata.gz: 503627f9466251962d5999cebc51452592036c556cb204cb3027015b1d59b69bfd9c76b6a55fb368d646e1214eefef01906f350b7806abee03d72a659b1ca20e
7
- data.tar.gz: 7a14d6722f3878d64960822113b2e291c002c0b302d273119d698b917808ebc6faf2d4f065a19a0626811ddbaa3905af9b26f114251f8a294643c81c64e23ac0
6
+ metadata.gz: fa7f07b87d15c27a2ffda1aa08217b5660fd504df39fedb0961d3fcabe99ade287fcc39f2a72a58a4ed4fd7ea20d9324e90267aaf821166a013701be6c7c06c0
7
+ data.tar.gz: 34b63cc227da84131d496aac3e6e6090799ad5c3f7ff4b894f967dfd36d8e624eb37cf6f26defe3cf5ba1de288506de4a3cf9389e0e843917184413149e5e5af
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 0.1.1 (September 7, 2013)
2
+
3
+ Bugfixes:
4
+
5
+ - show correct help message for `zend show`
6
+ - remove stored credentials on failed authentication
7
+
8
+ Features:
9
+
10
+ - use Zendesk user passwords instead of API token which are only
11
+ available to admins
12
+ - allow 3 authentication retries before exiting command
13
+
1
14
  ## 0.1.0 (September 7, 2013)
2
15
 
3
16
  Features:
data/lib/zend/auth.rb CHANGED
@@ -10,7 +10,7 @@ module Zend
10
10
  @api = ZendeskAPI::Client.new do |config|
11
11
  config.url = "https://#{domain}/api/v2"
12
12
  config.username = user
13
- config.token = password
13
+ config.password = password
14
14
  end
15
15
  unauthorized_callback(@api)
16
16
  end
@@ -47,9 +47,7 @@ module Zend
47
47
 
48
48
  def unauthorized_callback(api)
49
49
  api.insert_callback do |response|
50
- if response[:status] == 401
51
- Kernel.abort 'Incorrect Zendesk API authentication credentials'
52
- end
50
+ authentication_failed if response[:status] == 401
53
51
  end
54
52
  end
55
53
 
@@ -91,7 +89,7 @@ module Zend
91
89
  netrc.delete(domain)
92
90
  netrc.save
93
91
  end
94
- @email, @token = nil
92
+ @email, @password = nil
95
93
  end
96
94
 
97
95
  def read_credentials
@@ -115,9 +113,9 @@ module Zend
115
113
  say 'Enter your Zendesk credentials.' if ENV['ZEND_ACCOUNT']
116
114
 
117
115
  email = ask 'E-mail address: '
118
- token = ask_token 'Secret token (typing will be hidden): '
116
+ password = ask_secret 'Password (typing will be hidden): '
119
117
 
120
- [email, token]
118
+ [email, password]
121
119
  end
122
120
 
123
121
  def ask_for_and_save_credentials
@@ -128,11 +126,27 @@ module Zend
128
126
  @credentials
129
127
  end
130
128
 
131
- def ask_token(message)
129
+ def authentication_failed
130
+ say 'Authentication failed.'
131
+ if retry_login?
132
+ ask_for_and_save_credentials
133
+ else
134
+ delete_credentials
135
+ exit 1
136
+ end
137
+ end
138
+
139
+ def ask_secret(message)
132
140
  HighLine.new.ask(message) do |q|
133
141
  q.echo = false
134
142
  end
135
143
  end
144
+
145
+ def retry_login?
146
+ @login_attempts ||= 0
147
+ @login_attempts += 1
148
+ @login_attempts < 3
149
+ end
136
150
  end
137
151
  end
138
152
  end
data/lib/zend/cli.rb CHANGED
@@ -11,7 +11,7 @@ module Zend
11
11
  Zend::Auth.logout
12
12
  end
13
13
 
14
- desc 'ticket details', 'Get details of a Zendesk ticket'
14
+ desc 'show <ticket id>', 'Get details of a Zendesk ticket'
15
15
  def show(ticket_id)
16
16
  puts Zend::Command::Ticket.new(ticket_id).print
17
17
  end
data/lib/zend/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zend
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Mertz