project_btorretta 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/project_btorretta.rb +29 -34
- metadata +1 -1
data/project_btorretta.rb
CHANGED
@@ -1,34 +1,29 @@
|
|
1
|
-
require 'net/https'
|
2
|
-
class Servicedesk
|
3
|
-
# This is just meant to take in a ticket from a user prompt and pass back the status
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#note at the moment, its specific to the my environment, so I'll have to make it general as a gem. To use it as your own, you'd want to stub in your api and u/p
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
class ServiceDesk2 <Servicedesk
|
32
|
-
n= Servicedesk.new
|
33
|
-
n.lets_ask
|
34
|
-
end
|
1
|
+
require 'net/https'
|
2
|
+
class Servicedesk
|
3
|
+
# This is just meant to take in a ticket from a user prompt and pass back the status
|
4
|
+
# Example: input 671148 at the command prompt
|
5
|
+
# Arguments: this doesn't have a CLI mode, so only thing to be passed is a ticket number
|
6
|
+
#following guidelines at http://guides.rubygems.org/make-your-own-gem/#documenting-code
|
7
|
+
#note at the moment, its specific to the my environment, so I'll have to make it general as a gem. To use it as your own, you'd want to stub in your api and u/p. I really should have used rspec mocks to fake an api with data in it.
|
8
|
+
|
9
|
+
attr_accessor :ticket
|
10
|
+
def initialize
|
11
|
+
@ticket = ticket
|
12
|
+
end
|
13
|
+
def lets_ask(*ticket)
|
14
|
+
i = puts "What is your ticket number?"
|
15
|
+
ticket = gets.chomp
|
16
|
+
ticket = ticket.to_i
|
17
|
+
site = Net::HTTP.new(yourapihere.com", 443)
|
18
|
+
site.use_ssl = true
|
19
|
+
response = site.get2("/v1/incident/IUAT#{ticket}.yaml", 'Authorization' =>'Basic ' + ["user:password"].pack('m').strip)
|
20
|
+
puts response.body
|
21
|
+
if response.body.match("error") then raise SyntaxError.new('Please enter your Incident number without letters, for example 671148') end
|
22
|
+
end
|
23
|
+
#n= Servicedesk.new
|
24
|
+
#n.lets_ask
|
25
|
+
end
|
26
|
+
class ServiceDesk2 <Servicedesk
|
27
|
+
n= Servicedesk.new
|
28
|
+
n.lets_ask
|
29
|
+
end
|