We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents cefe635 + 064ee57 commit be79632Copy full SHA for be79632
5 files changed
CHANGELOG.md
@@ -1,7 +1,11 @@
1
# Changelog
2
3
+## v0.1.1 (2023-08-22)
4
+
5
+- Automatically determine the tier based on the api key ([#12](https://github.com/hergetto/deepl_ex/pull/12))
6
7
## v0.1.0 (2023-08-17)
8
-* Initial release
-* Add `translate/3` function ([#2](https://github.com/hergetto/deepl_ex/pull/2))
-* Update license to `Apache-2.0` to match the common licenses found in the Elixir ecosystem ([#3](https://github.com/hergetto/deepl_ex/pull/3))
9
+- Initial release
10
+- Add `translate/3` function ([#2](https://github.com/hergetto/deepl_ex/pull/2))
11
+- Update license to `Apache-2.0` to match the common licenses found in the Elixir ecosystem ([#3](https://github.com/hergetto/deepl_ex/pull/3))
README.md
@@ -10,18 +10,20 @@ by adding `deepl_ex` to your list of dependencies in `mix.exs`:
```elixir
def deps do
12
[
13
- {:deepl_ex, "~> 0.1.0"}
+ {:deepl_ex, "~> 0.1.1"}
14
]
15
end
16
```
17
18
The docs can be found at <https://hexdocs.pm/deepl_ex>.
19
20
## Configuration
21
-After installing the package, you should add some variables to your config.
22
+After installing the package, the following should be added to your config.
23
24
25
config :deepl_ex,
- api_key: "", # String containing your DeepL api key
26
- tier: :free # Can be :free or :pro
+ api_key: "" # String containing your DeepL api key
27
28
29
+We determine the tier based on the api key, so you don't need to specify the tier.
lib/deepl_ex.ex
@@ -38,7 +38,7 @@ defmodule DeeplEx do
38
{:valid_target_language?, true} <-
39
LanguageValidator.valid_target_language?(target_language),
40
{:ok, api_key} = Configuration.api_key(),
41
- {:ok, tier} = Configuration.tier(),
+ tier = Configuration.tier(api_key),
42
client <- DeepL.client(api_key, tier),
43
{:ok, %{body: %{"translations" => [%{"text" => translation}]}}} <-
44
DeepL.translate(client, %{
@@ -53,8 +53,9 @@ defmodule DeeplEx do
53
54
55
56
- defp error_response({error, _}) when error in [:valid_source_language?, :valid_target_language],
57
- do: {:error, :invalid_language_specification}
+ defp error_response({error, _})
+ when error in [:valid_source_language?, :valid_target_language?],
58
+ do: {:error, :invalid_language_specification}
59
60
defp error_response(error), do: error
61
lib/helpers/configuration.ex
@@ -10,5 +10,13 @@ defmodule DeeplEx.Configuration do
- def tier, do: {:ok, Application.get_env(:deepl_ex, :tier, :free)}
+ def tier(api_key) do
+ case String.ends_with?(api_key, ":fx") do
+ true ->
+ :free
+ _ ->
+ :pro
+ end
mix.exs
@@ -1,7 +1,7 @@
defmodule DeeplEx.MixProject do
use Mix.Project
- @version "0.1.0"
+ @version "0.1.1"
@source_url "https://github.com/hergetto/deepl_ex"
def project do
0 commit comments