Skip to content

Commit

Permalink
Use authenticated route for querying competition API (#652)
Browse files Browse the repository at this point in the history
* changed comp url to use internal route

* added auth for internal route
  • Loading branch information
dunkOnIT authored Oct 7, 2024
1 parent 8b3f5d9 commit b3a83d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/competition_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b3a83d4

Please sign in to comment.