Skip to content

Commit bb3f44f

Browse files
kdakerJorge Chavez
authored andcommitted
adds version number to config and dynamic accept-header (altyaper#8)
1 parent b7f9c72 commit bb3f44f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

config/config.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ use Mix.Config
33
config :conekta,
44
publickey: "PUBLIC",
55
privatekey: "PRIVATE",
6-
locale: "es"
6+
locale: "es",
7+
apiversion: "2.0.0"

lib/wrapper.ex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Conekta.Wrapper do
22
@moduledoc false
33
use HTTPoison.Base
4-
@conekta_accept_header "application/vnd.conekta-v2.0.0+json"
4+
@conekta_accept_header "application/vnd.conekta-v{{version}}+json"
55

66
def process_url(url) do
77
"https://api.conekta.io/" <> url
@@ -13,7 +13,11 @@ defmodule Conekta.Wrapper do
1313

1414
def headers do
1515
basic_auth = "Basic " <> Base.encode64(key() <> ":")
16-
["Accept": @conekta_accept_header, "Accept-Language": locale(),"Content-type": "application/json", "Authorization": basic_auth]
16+
["Accept": accept_header(), "Accept-Language": locale(),"Content-type": "application/json", "Authorization": basic_auth]
17+
end
18+
19+
def accept_header do
20+
String.replace(@conekta_accept_header, "{{version}}", api_version())
1721
end
1822

1923
def key do
@@ -24,4 +28,7 @@ defmodule Conekta.Wrapper do
2428
Application.get_env(:conekta, :locale)
2529
end
2630

31+
def api_version do
32+
Application.get_env(:conekta, :apiversion)
33+
end
2734
end

0 commit comments

Comments
 (0)