Class: BorrowDirect::Authentication
- Defined in:
- lib/borrow_direct/authentication.rb
Overview
The BD Authorization API borrowdirect.pbworks.com/w/file/83346673/Authorization%20Service.docx
For now, always calls with ‘patron’ type.
Constant Summary collapse
- @@api_path =
"/portal-service/user/authentication/patron"
Instance Attribute Summary collapse
-
#patron_barcode ⇒ Object
readonly
Returns the value of attribute patron_barcode.
-
#patron_library_symbol ⇒ Object
readonly
Returns the value of attribute patron_library_symbol.
Attributes inherited from Request
#auth_id, #expected_error_codes, #http_client, #http_method, #last_request_json, #last_request_response, #last_request_time, #last_request_uri, #timeout
Instance Method Summary collapse
-
#authentication_request ⇒ Object
Returns raw Hash results of the Authentication request See also #get_auth_id.
- #authentication_request_hash(patron_barcode, library_symbol) ⇒ Object
-
#get_auth_id ⇒ Object
Makes a request and returns the “AId” value which is used as input “AuthorizationId” in other API calls.
-
#initialize(patron_barcode, patron_library_symbol = Defaults.library_symbol) ⇒ Authentication
constructor
BorrowDirect::Authentication.new(barcode) BorrowDirect::Authentication.new(barcode, library_symbol).
Methods inherited from Request
#fetch_auth_id!, #need_auth_id, #request, #request_headers, #with_auth_id
Constructor Details
#initialize(patron_barcode, patron_library_symbol = Defaults.library_symbol) ⇒ Authentication
BorrowDirect::Authentication.new(barcode) BorrowDirect::Authentication.new(barcode, library_symbol)
16 17 18 19 20 21 22 |
# File 'lib/borrow_direct/authentication.rb', line 16 def initialize(, patron_library_symbol = Defaults.library_symbol) super(@@api_path) @patron_barcode = @patron_library_symbol = patron_library_symbol end |
Instance Attribute Details
#patron_barcode ⇒ Object (readonly)
Returns the value of attribute patron_barcode.
10 11 12 |
# File 'lib/borrow_direct/authentication.rb', line 10 def @patron_barcode end |
#patron_library_symbol ⇒ Object (readonly)
Returns the value of attribute patron_library_symbol.
10 11 12 |
# File 'lib/borrow_direct/authentication.rb', line 10 def patron_library_symbol @patron_library_symbol end |
Instance Method Details
#authentication_request ⇒ Object
Returns raw Hash results of the Authentication request See also #get_auth_id
26 27 28 |
# File 'lib/borrow_direct/authentication.rb', line 26 def authentication_request self.request authentication_request_hash(self., self.patron_library_symbol) end |
#authentication_request_hash(patron_barcode, library_symbol) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/borrow_direct/authentication.rb', line 44 def authentication_request_hash(, library_symbol) { "AuthenticationInformation" => { "LibrarySymbol" => library_symbol, "PatronId" => } } end |
#get_auth_id ⇒ Object
Makes a request and returns the “AId” value which is used as input “AuthorizationId” in other API calls.
If one can’t be obtained for some reason, will raise BorrowDirect::Error
34 35 36 37 38 39 40 41 42 |
# File 'lib/borrow_direct/authentication.rb', line 34 def get_auth_id response = authentication_request if response["Authentication"] && response["Authentication"]["AuthnUserInfo"] && response["Authentication"]["AuthnUserInfo"]["AId"] return response["Authentication"]["AuthnUserInfo"]["AId"] else raise BorrowDirect::Error.new("Could not obtain AId from Authorization API call: #{response.inspect}") end end |