Skip to content

Commit be79632

Browse files
authored
Merge pull request #13 from hergetto/development
[Chore]: Release v0.1.1
2 parents cefe635 + 064ee57 commit be79632

5 files changed

Lines changed: 27 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Changelog
22

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+
37
## v0.1.0 (2023-08-17)
48

5-
* Initial release
6-
* Add `translate/3` function ([#2](https://github.com/hergetto/deepl_ex/pull/2))
7-
* 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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ by adding `deepl_ex` to your list of dependencies in `mix.exs`:
1010
```elixir
1111
def deps do
1212
[
13-
{:deepl_ex, "~> 0.1.0"}
13+
{:deepl_ex, "~> 0.1.1"}
1414
]
1515
end
1616
```
1717

1818
The docs can be found at <https://hexdocs.pm/deepl_ex>.
19+
1920
## Configuration
2021

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.
2223

2324
```elixir
2425
config :deepl_ex,
25-
api_key: "", # String containing your DeepL api key
26-
tier: :free # Can be :free or :pro
26+
api_key: "" # String containing your DeepL api key
2727
```
28+
29+
We determine the tier based on the api key, so you don't need to specify the tier.

lib/deepl_ex.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ defmodule DeeplEx do
3838
{:valid_target_language?, true} <-
3939
LanguageValidator.valid_target_language?(target_language),
4040
{:ok, api_key} = Configuration.api_key(),
41-
{:ok, tier} = Configuration.tier(),
41+
tier = Configuration.tier(api_key),
4242
client <- DeepL.client(api_key, tier),
4343
{:ok, %{body: %{"translations" => [%{"text" => translation}]}}} <-
4444
DeepL.translate(client, %{
@@ -53,8 +53,9 @@ defmodule DeeplEx do
5353
end
5454
end
5555

56-
defp error_response({error, _}) when error in [:valid_source_language?, :valid_target_language],
57-
do: {:error, :invalid_language_specification}
56+
defp error_response({error, _})
57+
when error in [:valid_source_language?, :valid_target_language?],
58+
do: {:error, :invalid_language_specification}
5859

5960
defp error_response(error), do: error
6061
end

lib/helpers/configuration.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,13 @@ defmodule DeeplEx.Configuration do
1010
end
1111
end
1212

13-
def tier, do: {:ok, Application.get_env(:deepl_ex, :tier, :free)}
13+
def tier(api_key) do
14+
case String.ends_with?(api_key, ":fx") do
15+
true ->
16+
:free
17+
18+
_ ->
19+
:pro
20+
end
21+
end
1422
end

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule DeeplEx.MixProject do
22
use Mix.Project
33

4-
@version "0.1.0"
4+
@version "0.1.1"
55
@source_url "https://github.com/hergetto/deepl_ex"
66

77
def project do

0 commit comments

Comments
 (0)