ebsco-discovery-service-api 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ebsco-discovery-service-api.rb +35 -7
- metadata +1 -1
@@ -42,7 +42,11 @@ module EDSApi
|
|
42
42
|
https = Net::HTTP.new(uri.hostname, uri.port)
|
43
43
|
https.use_ssl = true
|
44
44
|
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
45
|
-
|
45
|
+
begin
|
46
|
+
doc = JSON.parse(https.request(req).body)
|
47
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
48
|
+
about "No response from server"
|
49
|
+
end
|
46
50
|
if doc.has_key?('ErrorNumber')
|
47
51
|
abort "Bad response from server - error code #{result['ErrorNumber']}"
|
48
52
|
else
|
@@ -56,7 +60,11 @@ module EDSApi
|
|
56
60
|
https = Net::HTTP.new(uri.hostname, uri.port)
|
57
61
|
https.use_ssl = true
|
58
62
|
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
59
|
-
|
63
|
+
begin
|
64
|
+
doc = JSON.parse(https.request(req).body)
|
65
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
66
|
+
abort "No response from server"
|
67
|
+
end
|
60
68
|
@auth_token = doc['AuthToken']
|
61
69
|
end
|
62
70
|
# Create the session
|
@@ -70,7 +78,11 @@ module EDSApi
|
|
70
78
|
# return doc['SessionToken']
|
71
79
|
# }
|
72
80
|
Net::HTTP.start(uri.hostname, uri.port) { |http|
|
73
|
-
|
81
|
+
begin
|
82
|
+
return http.request(req).body
|
83
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
84
|
+
abort "No response from server"
|
85
|
+
end
|
74
86
|
}
|
75
87
|
end
|
76
88
|
# End the session
|
@@ -79,7 +91,11 @@ module EDSApi
|
|
79
91
|
req = Net::HTTP::Get.new(uri.request_uri)
|
80
92
|
req['x-authenticationToken'] = @auth_token
|
81
93
|
Net::HTTP.start(uri.hostname, uri.port) { |http|
|
82
|
-
|
94
|
+
begin
|
95
|
+
http.request(req)
|
96
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
97
|
+
abort "No response from server"
|
98
|
+
end
|
83
99
|
}
|
84
100
|
return true
|
85
101
|
end
|
@@ -92,7 +108,11 @@ module EDSApi
|
|
92
108
|
req['x-sessionToken'] = @session_token
|
93
109
|
req['Accept'] = 'application/json' #if format == :json
|
94
110
|
Net::HTTP.start(uri.hostname, uri.port) { |http|
|
95
|
-
|
111
|
+
begin
|
112
|
+
return http.request(req).body
|
113
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
114
|
+
abort "No response from server"
|
115
|
+
end
|
96
116
|
}
|
97
117
|
end
|
98
118
|
# Retrieve specific information
|
@@ -103,7 +123,11 @@ module EDSApi
|
|
103
123
|
req['x-sessionToken'] = @session_token
|
104
124
|
req['Accept'] = 'application/json' #if format == :json
|
105
125
|
Net::HTTP.start(uri.hostname, uri.port) { |http|
|
106
|
-
|
126
|
+
begin
|
127
|
+
return http.request(req).body
|
128
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
129
|
+
abort "No response from server"
|
130
|
+
end
|
107
131
|
}
|
108
132
|
end
|
109
133
|
# Info method
|
@@ -114,7 +138,11 @@ module EDSApi
|
|
114
138
|
req['x-sessionToken'] = @session_token
|
115
139
|
req['Accept'] = 'application/json' #if format == :json
|
116
140
|
Net::HTTP.start(uri.hostname, uri.port) { |http|
|
117
|
-
|
141
|
+
begin
|
142
|
+
return http.request(req).body
|
143
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
144
|
+
abort "No response from server"
|
145
|
+
end
|
118
146
|
}
|
119
147
|
end
|
120
148
|
end
|