12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/uvcli/cli.rb', line 12
def login
puts %{To login to your UserVoice account we'll need your domain, key and secret.
The domain is the part in front of your uservoice.com domain, e.g. dangercove.uservoice.com.
To create a key and secret login to your UserVoice account, head over to Settings, then Integrations and click Add API Key... Only enter a name and make sure TRUSTED is not checked.
}
puts "Domain:"
STDOUT.flush
domain = STDIN.gets.chomp
puts "Key:"
STDOUT.flush
key = STDIN.gets.chomp
puts "Secret:"
STDOUT.flush
secret = STDIN.gets.chomp
puts "\nLogging in..."
client = UserVoice::Client.new(domain, key, secret)
begin
client.get("/api/v1/tickets.json")
puts @@settings.add_site?(domain, key, secret) ? "Site saved" : "Something went wrong"
rescue OAuth::Unauthorized
rescue UserVoice::Unauthorized
puts "Failed to login"
end
end
|