From b1427f1c07c5b65eafeab107e24336920562e4f3 Mon Sep 17 00:00:00 2001 From: Christoph Werner Date: Sun, 8 Dec 2024 21:54:13 +0100 Subject: [PATCH] Improve deepl token type check --- app/lib/deepl/client.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/lib/deepl/client.rb b/app/lib/deepl/client.rb index 4cf831e9..a477a5bb 100644 --- a/app/lib/deepl/client.rb +++ b/app/lib/deepl/client.rb @@ -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