diff --git a/README.md b/README.md index a7e1093..c230576 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Add a new dependency to `mix.exs`: ```elixir def deps do [ - {:elixir_lokalise_api, "~> 2.0"} + {:elixir_lokalise_api, "~> 3.3"} ] end ``` diff --git a/config/dev.exs b/config/dev.exs index 14bd4ae..1bcec6f 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -3,4 +3,6 @@ import Config config :elixir_lokalise_api, api_token: {:system, "LOKALISE_API_TOKEN"}, oauth2_client_id: {:system, "OAUTH2_CLIENT_ID"}, - oauth2_client_secret: {:system, "OAUTH2_CLIENT_SECRET"} + oauth2_client_secret: {:system, "OAUTH2_CLIENT_SECRET"}, + base_url_api: {:system, "LOKALISE_API_BASE_URL"}, + base_url_oauth2: {:system, "LOKALISE_OAUTH2_BASE_URL"} diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 33ab5e9..d42392b 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -1,8 +1,9 @@ GEM remote: https://rubygems.org/ specs: - activesupport (7.2.1) + activesupport (8.0.0) base64 + benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) @@ -12,20 +13,23 @@ GEM minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) base64 (0.2.0) + benchmark (0.4.0) bigdecimal (3.1.8) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) colorator (1.1.0) - commonmarker (0.23.10) + commonmarker (0.23.11) concurrent-ruby (1.3.4) connection_pool (2.4.1) csv (3.3.0) - dnsruby (1.72.2) + dnsruby (1.72.3) + base64 (~> 0.2.0) simpleidn (~> 0.2.1) drb (2.2.1) em-websocket (0.5.3) @@ -34,13 +38,13 @@ GEM ethon (0.16.0) ffi (>= 1.15.0) eventmachine (1.2.7) - execjs (2.9.1) - faraday (2.12.0) - faraday-net_http (>= 2.0, < 3.4) + execjs (2.10.0) + faraday (2.12.1) + faraday-net_http (>= 2.0, < 3.5) json logger - faraday-net_http (3.3.0) - net-http + faraday-net_http (3.4.0) + net-http (>= 0.5.0) ffi (1.17.0-x64-mingw-ucrt) forwardable-extended (2.6.0) gemoji (4.1.0) @@ -212,7 +216,7 @@ GEM gemoji (>= 3, < 5) html-pipeline (~> 2.2) jekyll (>= 3.0, < 5.0) - json (2.7.2) + json (2.8.2) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) @@ -227,8 +231,8 @@ GEM jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) - minitest (5.25.1) - net-http (0.4.1) + minitest (5.25.2) + net-http (0.5.0) uri nokogiri (1.16.7-x64-mingw-ucrt) racc (~> 1.4) @@ -242,7 +246,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rexml (3.3.8) + rexml (3.3.9) rouge (3.30.0) rubyzip (2.3.2) safe_yaml (1.0.5) @@ -254,7 +258,7 @@ GEM sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) - securerandom (0.3.1) + securerandom (0.3.2) simpleidn (0.2.3) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) @@ -265,9 +269,9 @@ GEM tzinfo-data (1.2024.2) tzinfo (>= 1.0.0) unicode-display_width (1.8.0) - uri (0.13.1) + uri (1.0.2) wdm (0.2.0) - webrick (1.8.2) + webrick (1.9.0) PLATFORMS x64-mingw-ucrt @@ -283,4 +287,4 @@ DEPENDENCIES wdm (~> 0.2.0) BUNDLED WITH - 2.5.21 + 2.5.23 diff --git a/docs/additional_info/changelog.md b/docs/additional_info/changelog.md index 92b6abc..5495fcd 100644 --- a/docs/additional_info/changelog.md +++ b/docs/additional_info/changelog.md @@ -1,5 +1,14 @@ # Changelog +## 3.3.0 (27-Nov-2024) + +* Allow to redefine host for API and OAuth2 requests: + +```elixir +config :elixir_lokalise_api, base_url_api: "YOUR_API_BASE_URL" +config :elixir_lokalise_api, base_url_oauth2: "YOUR_OAUTH2_BASE_URL" +``` + ## 3.2.0 (15-Oct-2024) * Added support for a new [`PermissionTemplates` endpoint](https://developers.lokalise.com/reference/list-all-permission-templates): diff --git a/docs/additional_info/customization.md b/docs/additional_info/customization.md index 097ff6f..a0c4ccb 100644 --- a/docs/additional_info/customization.md +++ b/docs/additional_info/customization.md @@ -13,4 +13,11 @@ config :elixir_lokalise_api, ``` If the `request_options` is not provided, the default options will be utilized. You can find full list -of all the available `:options` in the [HTTPoison docs](https://hexdocs.pm/httpoison/HTTPoison.Request.html). \ No newline at end of file +of all the available `:options` in the [HTTPoison docs](https://hexdocs.pm/httpoison/HTTPoison.Request.html). + +You can also override the default host URLs: + +```elixir +config :elixir_lokalise_api, base_url_api: "YOUR_API_BASE_URL" +config :elixir_lokalise_api, base_url_oauth2: "YOUR_OAUTH2_BASE_URL" +``` \ No newline at end of file diff --git a/lib/elixir_lokalise_api/config.ex b/lib/elixir_lokalise_api/config.ex index bcfa2d8..7eed289 100644 --- a/lib/elixir_lokalise_api/config.ex +++ b/lib/elixir_lokalise_api/config.ex @@ -37,14 +37,17 @@ defmodule ElixirLokaliseApi.Config do @doc """ Returns package version """ - def version, do: from_env(:version, "3.2.0") + def version, do: from_env(:version, "3.3.0") @doc """ - Returns the base URL of the Lokalise APIv2 or OAuth2 - """ - def base_url(:api), do: "https://api.lokalise.com/api2/" + Returns the base URL of the Lokalise APIv2 or OAuth2. Set it inside your `mix.exs`: + config :elixir_lokalise_api, base_url_api: "YOUR_API_BASE_URL" + config :elixir_lokalise_api, base_url_oauth2: "YOUR_OAUTH2_BASE_URL" - def base_url(:oauth2), do: "https://app.lokalise.com/oauth2/" + You can also use `{:system, "ENV_VAR_NAME"}` to set it via environment variables. + """ + def base_url(:api), do: from_env(:base_url_api, "https://api.lokalise.com/api2/") + def base_url(:oauth2), do: from_env(:base_url_oauth2, "https://app.lokalise.com/oauth2/") @doc """ A wrapper around `Application.put_env/3` diff --git a/lib/elixir_lokalise_api/request.ex b/lib/elixir_lokalise_api/request.ex index 7604ff4..23ed7de 100644 --- a/lib/elixir_lokalise_api/request.ex +++ b/lib/elixir_lokalise_api/request.ex @@ -42,6 +42,7 @@ defmodule ElixirLokaliseApi.Request do {:error, error} -> # HTTPoison error {:error, error.reason} + # coveralls-ignore-end {:error, data, status} -> diff --git a/mix.exs b/mix.exs index 7f12424..13570dd 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule ElixirLokaliseApi.MixProject do use Mix.Project @source_url "https://github.com/lokalise/elixir-lokalise-api" - @version "3.2.0" + @version "3.3.0" def project do [ diff --git a/mix.lock b/mix.lock index cf7e076..a3625cf 100644 --- a/mix.lock +++ b/mix.lock @@ -1,8 +1,8 @@ %{ "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, "certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"}, - "credo": {:hex, :credo, "1.7.8", "9722ba1681e973025908d542ec3d95db5f9c549251ba5b028e251ad8c24ab8c5", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cb9e87cc64f152f3ed1c6e325e7b894dea8f5ef2e41123bd864e3cd5ceb44968"}, - "dialyxir": {:hex, :dialyxir, "1.4.4", "fb3ce8741edeaea59c9ae84d5cec75da00fa89fe401c72d6e047d11a61f65f70", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "cd6111e8017ccd563e65621a4d9a4a1c5cd333df30cebc7face8029cacb4eff6"}, + "credo": {:hex, :credo, "1.7.10", "6e64fe59be8da5e30a1b96273b247b5cf1cc9e336b5fd66302a64b25749ad44d", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "71fbc9a6b8be21d993deca85bf151df023a3097b01e09a2809d460348561d8cd"}, + "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, "earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"}, "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, "ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"}, @@ -16,8 +16,8 @@ "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm", "fc3499fed7a726995aa659143a248534adc754ebd16ccd437cd93b649a95091f"}, - "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, + "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, + "makeup_elixir": {:hex, :makeup_elixir, "1.0.0", "74bb8348c9b3a51d5c589bf5aebb0466a84b33274150e3b6ece1da45584afc82", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49159b7d7d999e836bedaf09dcf35ca18b312230cf901b725a64f3f42e407983"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, "meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},