ebsco-discovery-service-api 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ebsco-discovery-service-api.rb +38 -27
- metadata +2 -2
@@ -13,12 +13,12 @@ module EDSApi
|
|
13
13
|
# Connection object. Does what it says. ConnectionHandler is what is usually desired and wraps auto-reonnect features, etc.
|
14
14
|
class Connection
|
15
15
|
|
16
|
-
attr_accessor :auth_token, :session_token
|
17
|
-
|
16
|
+
attr_accessor :auth_token, :session_token, :debug_notes
|
18
17
|
attr_writer :userid, :password
|
19
18
|
|
20
19
|
# Init the object with userid and pass.
|
21
20
|
def uid_init(userid, password, profile)
|
21
|
+
@debug_notes = ""
|
22
22
|
@userid = userid
|
23
23
|
@password = password
|
24
24
|
@profile = profile
|
@@ -39,6 +39,7 @@ module EDSApi
|
|
39
39
|
req["Content-Type"] = "application/xml"
|
40
40
|
req["Accept"] = "application/json" #if format == :json
|
41
41
|
req.body = xml
|
42
|
+
@debug_notes << "<p>UID Authentication Call to " << uri.to_s << ": " << xml << "</p>";
|
42
43
|
https = Net::HTTP.new(uri.hostname, uri.port)
|
43
44
|
https.use_ssl = true
|
44
45
|
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
@@ -73,6 +74,7 @@ module EDSApi
|
|
73
74
|
req = Net::HTTP::Get.new(uri.request_uri)
|
74
75
|
req['x-authenticationToken'] = @auth_token
|
75
76
|
req['Accept'] = "application/json"
|
77
|
+
@debug_notes << "<p>CREATE SESSION Call to " << uri.to_s << " with auth token: " << req['x-authenticationToken'].to_s << "</p>";
|
76
78
|
# Net::HTTP.start(uri.hostname, uri.port) { |http|
|
77
79
|
# doc = JSON.parse(http.request(req).body)
|
78
80
|
# return doc['SessionToken']
|
@@ -107,6 +109,8 @@ module EDSApi
|
|
107
109
|
req['x-authenticationToken'] = @auth_token
|
108
110
|
req['x-sessionToken'] = @session_token
|
109
111
|
req['Accept'] = 'application/json' #if format == :json
|
112
|
+
@debug_notes << "<p>SEARCH Call to " << uri.to_s << " with auth token: " << req['x-authenticationToken'].to_s << " and session token: " << req['x-sessionToken'].to_s << "</p>";
|
113
|
+
|
110
114
|
Net::HTTP.start(uri.hostname, uri.port) { |http|
|
111
115
|
begin
|
112
116
|
return http.request(req).body
|
@@ -125,6 +129,8 @@ module EDSApi
|
|
125
129
|
req['x-authenticationToken'] = @auth_token
|
126
130
|
req['x-sessionToken'] = @session_token
|
127
131
|
req['Accept'] = 'application/json' #if format == :json
|
132
|
+
@debug_notes << "<p>RETRIEVE Call to " << uri.to_s << " with auth token: " << req['x-authenticationToken'].to_s << " and session token: " << req['x-sessionToken'].to_s << "</p>";
|
133
|
+
|
128
134
|
Net::HTTP.start(uri.hostname, uri.port) { |http|
|
129
135
|
begin
|
130
136
|
return http.request(req).body
|
@@ -140,6 +146,7 @@ module EDSApi
|
|
140
146
|
req['x-authenticationToken'] = @auth_token
|
141
147
|
req['x-sessionToken'] = @session_token
|
142
148
|
req['Accept'] = 'application/json' #if format == :json
|
149
|
+
@debug_notes << "<p>INFO Call to " << uri.to_s << " with auth token: " << req['x-authenticationToken'].to_s << " and session token: " << req['x-sessionToken'].to_s << "</p>";
|
143
150
|
Net::HTTP.start(uri.hostname, uri.port) { |http|
|
144
151
|
begin
|
145
152
|
return http.request(req).body
|
@@ -177,31 +184,35 @@ module EDSApi
|
|
177
184
|
@session_token = session_token
|
178
185
|
@auth_token = auth_token
|
179
186
|
loop do
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
187
|
+
result = JSON.parse(super(options, format))
|
188
|
+
if result.has_key?('ErrorNumber')
|
189
|
+
@debug_notes << "<p>Found ERROR " << result['ErrorNumber'].to_s
|
190
|
+
case result['ErrorNumber']
|
191
|
+
when "108"
|
192
|
+
@session_token = self.create_session
|
193
|
+
result = JSON.parse(super(options, format))
|
194
|
+
when "109"
|
195
|
+
@session_token = self.create_session
|
196
|
+
result = JSON.parse(super(options, format))
|
197
|
+
when "104"
|
198
|
+
self.uid_authenticate(:json)
|
199
|
+
result = JSON.parse(super(options, format))
|
200
|
+
when "107"
|
201
|
+
self.uid_authenticate(:json)
|
202
|
+
result = JSON.parse(super(options, format))
|
203
|
+
else
|
204
|
+
return result
|
205
|
+
end
|
206
|
+
unless result.has_key?('ErrorNumber')
|
207
|
+
return result
|
208
|
+
end
|
209
|
+
attempts += 1
|
210
|
+
if attempts >= @max_retries
|
211
|
+
return result
|
212
|
+
end
|
213
|
+
else
|
214
|
+
return result
|
215
|
+
end
|
205
216
|
end
|
206
217
|
end
|
207
218
|
def info (session_token, auth_token, format= :xml)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebsco-discovery-service-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Set of Ruby functions to interface with the EBSCO Discovery Service API.
|
16
16
|
email: eds@ebscohost.com
|