lib/util/vsac_api.rb in cqm-parsers-2.0.1 vs lib/util/vsac_api.rb in cqm-parsers-3.0.0.0
- old
+ new
@@ -136,11 +136,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
@@ -157,11 +157,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
@@ -240,12 +240,12 @@
# Execute bulk requests for valuesets, return the raw Typheous responses (requests executed in parallel)
def get_multiple_valueset_raw_responses(needed_value_sets)
service_tickets = get_service_tickets(needed_value_sets.size)
- hydra = Typhoeus::Hydra.new # Hydra executes multiple HTTP requests at once
- requests = needed_value_sets.map do |n|
+ hydra = Typhoeus::Hydra.new(max_concurrency: 1) # Hydra executes multiple HTTP requests at once
+ requests = needed_value_sets.map do |n|
request = create_valueset_request(n[:value_set][:oid], service_tickets.pop, n[:vs_vsac_options])
hydra.queue(request)
request
end
@@ -256,11 +256,11 @@
# Bulk get an amount of service tickets (requests executed in parallel)
def get_service_tickets(amount)
raise VSACNoCredentialsError.new unless @ticket_granting_ticket
raise VSACTicketExpiredError.new if Time.now > @ticket_granting_ticket[:expires]
-
+
hydra = Typhoeus::Hydra.new # Hydra executes multiple HTTP requests at once
requests = amount.times.map do
request = create_service_ticket_request
hydra.queue(request)
request
@@ -297,18 +297,18 @@
return Typhoeus::Request.new("#{@config[:content_url]}/RetrieveMultipleValueSets", params: params)
end
# Create a typheous request for a service ticket (this must be executed later)
def create_service_ticket_request
- return Typhoeus::Request.new("#{@config[:auth_url]}/Ticket/#{@ticket_granting_ticket[:ticket]}",
+ return Typhoeus::Request.new("#{@config[:auth_url]}/Ticket/#{@ticket_granting_ticket[:ticket]}",
method: :post,
params: { service: TICKET_SERVICE_PARAM})
end
# Use your username and password to retrive a ticket granting ticket from VSAC
def get_ticket_granting_ticket(username, password)
response = Typhoeus.post(
- "#{@config[:auth_url]}/Ticket",
+ "#{@config[:auth_url]}/Ticket",
# looks like typheous sometimes switches the order of username/password when encoding
# which vsac cant handle (!?), so encode first
body: URI.encode_www_form(username: username, password: password)
)
raise VSACInvalidCredentialsError.new if response.response_code == 401