lib/util/vsac_api.rb in bonnie_bundler-2.2.5 vs lib/util/vsac_api.rb in bonnie_bundler-3.0.0

- old
+ new

@@ -6,28 +6,28 @@ # Generic VSAC related exception. class VSACError < StandardError end - # Error represnting a not found response from the API. Includes OID for reporting to user. + # Error representing a not found response from the API. Includes OID for reporting to user. class VSNotFoundError < VSACError attr_reader :oid def initialize(oid) super("Value Set (#{oid}) was not found.") @oid = oid end end - # Error represnting a program not found response from the API. + # Error representing a program not found response from the API. class VSACProgramNotFoundError < VSACError attr_reader :oid def initialize(program) super("VSAC Program #{program} does not exist.") end end - # Error represnting a response from the API that had no concepts. + # Error representing a response from the API that had no concepts. class VSEmptyError < VSACError attr_reader :oid def initialize(oid) super("Value Set (#{oid}) is empty.") @oid = oid @@ -42,18 +42,18 @@ end # Raised when the user credentials were invalid. class VSACInvalidCredentialsError < VSACError def initialize - super('VSAC ULMS credentials are invalid.') + super('VSAC UMLS credentials are invalid.') end end # Raised when a call requiring auth is attempted when no ticket_granting_ticket or credentials were provided. class VSACNoCredentialsError < VSACError def initialize - super('VSAC ULMS credentials were not provided.') + super('VSAC UMLS credentials were not provided.') end end # Raised when the arguments passed in are bad. class VSACArgumentError < VSACError @@ -90,11 +90,11 @@ raise VSACArgumentError.new("Required param :config is missing required URLs.") end end # if a ticket_granting_ticket was passed in, check it and raise errors if found - # username and password will be ignored + # VSAC API Key will be ignored if !options[:ticket_granting_ticket].nil? provided_ticket_granting_ticket = options[:ticket_granting_ticket] if provided_ticket_granting_ticket[:ticket].nil? || provided_ticket_granting_ticket[:expires].nil? raise VSACArgumentError.new("Optional param :ticket_granting_ticket is missing :ticket or :expires") end @@ -106,13 +106,13 @@ # ticket granting ticket looks good @ticket_granting_ticket = { ticket: provided_ticket_granting_ticket[:ticket], expires: provided_ticket_granting_ticket[:expires] } - # if username and password were provided use them to get a ticket granting ticket - elsif !options[:username].nil? && !options[:password].nil? - @ticket_granting_ticket = get_ticket_granting_ticket(options[:username], options[:password]) + # if api key was provided use it to get a ticket granting ticket + elsif !options[:api_key].nil? + @ticket_granting_ticket = get_ticket_granting_ticket(options[:api_key]) end end ## # Gets the list of profiles. This may be used without credentials. @@ -151,11 +151,11 @@ ## # Gets the details for a program. This may be used without credentials. # # Optional parameter program is the program to request from the API. If it is not provided it will look for - # a :program in the config passed in during construction. If there is no :program in the config it will use + # a :program in the config passed in during construction. If there is no :program in the config it will use # the DEFAULT_PROGRAM constant for the program. # # Returns the JSON parsed response for program details. def get_program_details(program = nil) # if no program was provided use the one in the config or default in constant @@ -178,11 +178,11 @@ # "name": "eCQM Update 2018-05-04", # "requestTime": "2018-05-21 03:39:04 PM" # } # # Optional parameter program is the program to request from the API. If it is not provided it will look for - # a :program in the config passed in during construction. If there is no :program in the config it will use + # a :program in the config passed in during construction. If there is no :program in the config it will use # the DEFAULT_PROGRAM constant for the program. # # Returns the name of the latest profile for the given program. def get_latest_profile_for_program(program = nil) # if no program was provided use the one in the config or default in constant @@ -286,12 +286,12 @@ @ticket_granting_ticket[:expires] = Time.now raise VSACTicketExpiredError.new end end - def get_ticket_granting_ticket(username, password) + def get_ticket_granting_ticket(api_key) begin - ticket = RestClient.post("#{@config[:auth_url]}/Ticket", username: username, password: password) + ticket = RestClient.post("#{@config[:auth_url]}/Ticket", apikey: api_key) return { ticket: String.new(ticket), expires: Time.now + 8.hours } rescue RestClient::Unauthorized raise VSACInvalidCredentialsError.new end end