From b3a83d4f0832ac3b86a4461bff54850a08555134 Mon Sep 17 00:00:00 2001 From: Duncan <52967253+dunkOnIT@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:09:54 +0200 Subject: [PATCH] Use authenticated route for querying competition API (#652) * changed comp url to use internal route * added auth for internal route --- lib/competition_api.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/competition_api.rb b/lib/competition_api.rb index 2d3acfca..8a6764e8 100644 --- a/lib/competition_api.rb +++ b/lib/competition_api.rb @@ -13,7 +13,7 @@ def self.find(competition_id) end def self.url(competition_id) - "#{EnvConfig.WCA_HOST}/api/v0/competitions/#{competition_id}" + "#{EnvConfig.WCA_HOST}/api/internal/v1/competitions/#{competition_id}" end def self.find!(competition_id) @@ -23,7 +23,7 @@ def self.find!(competition_id) def self.fetch_qualifications(competition_id) Rails.cache.fetch("#{competition_id}/qualifications", expires_in: 5.minutes) do - response = HTTParty.get("#{url(competition_id)}/qualifications") + response = HTTParty.get("#{url(competition_id)}/qualifications", headers: { WCA_API_HEADER => self.wca_token }) case response.code when 200 @status = 200 @@ -40,7 +40,7 @@ def self.fetch_qualifications(competition_id) private_class_method def self.fetch_competition(competition_id) Rails.cache.fetch(competition_id, expires_in: 5.minutes) do - response = HTTParty.get(CompetitionApi.url(competition_id)) + response = HTTParty.get(CompetitionApi.url(competition_id), headers: { WCA_API_HEADER => self.wca_token }) case response.code when 200 response.parsed_response