Skip to content

Commit

Permalink
Improve deepl token type check
Browse files Browse the repository at this point in the history
  • Loading branch information
chrztoph committed Dec 8, 2024
1 parent e177511 commit b1427f1
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions app/lib/deepl/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,11 @@ def initialize(organization = nil)
end
else
@api_token = ENV.fetch('DEEPL_API_TOKEN', nil)
@api_endpoint = DEEPL_PRO_API
@api_endpoint = @api_token.ends_with?(":fx") ? DEEPL_FREE_API : DEEPL_PRO_API

# Determine if the free or pro API is used.
response = self.usage
if response.nil?
# It is not the pro API, now try the free API.
@api_endpoint = DEEPL_FREE_API

response = self.usage
if response.nil?
raise DeeplInvalidTokenException
end
raise DeeplInvalidTokenException
end
end
end
Expand Down

0 comments on commit b1427f1

Please sign in to comment.