aboutsummaryrefslogtreecommitdiff
path: root/2.2/get_ticket.rb
blob: 932bac14270de013633195053cd790497a20f707 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env ruby

require 'net/http'
require 'uri'
require 'json'
require 'io/console'

uri = URI.parse("http://localhost:4567/ticket")

header = {'Content-Type': 'text/json'}

print "Username: "; un = gets.strip
print "Password: "; pw = STDIN.noecho(&:gets).strip; puts
print "Service: "; s = gets.strip

login = {
  "username": un,
  "password": pw,
  "service": s
}

http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = login.to_json

response = http.request(request)
puts response.body