Skip to content

Commit 8f1a9c9

Browse files
authored
update env var name (#26)
* update env var name * update changelog * update api_url to api_base_url
1 parent 3df13a0 commit 8f1a9c9

9 files changed

Lines changed: 33 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [2025-10-15]
99

1010
### Changed
11+
- **BREAKING**: Configuration key `peek_app_key` has been renamed to `peek_api_key`
1112
- **BREAKING**: Configuration key `peek_api_url` has been deprecated in favor of `peek_api_base_url`
1213
- The new `peek_api_base_url` should contain only the base URL (e.g., `"https://apps.peekapis.com"`)
1314
- The SDK automatically appends appropriate paths (e.g., `/backoffice-gql`) for different API endpoints

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ writing apps.
1111
config :peek_app_sdk,
1212
peek_app_secret: "APP_SECRET",
1313
peek_app_id: "APP_ID",
14-
peek_api_url: "https://apps.peekapis.com/backoffice-gql",
15-
peek_app_key: "APP_KEY"
14+
peek_api_base_url: "https://apps.peekapis.com/",
15+
peek_api_key: "API_KEY"
1616
```
1717

1818
### Multiple Application Configurations
@@ -24,8 +24,8 @@ PeekAppSDK supports multiple configurations, allowing different applications to
2424
config :peek_app_sdk,
2525
peek_app_secret: "DEFAULT_SECRET",
2626
peek_app_id: "DEFAULT_APP_ID",
27-
peek_api_url: "https://apps.peekapis.com/backoffice-gql",
28-
peek_app_key: "DEFAULT_APP_KEY",
27+
peek_api_base_url: "https://apps.peekapis.com/",
28+
peek_api_key: "DEFAULT_API_KEY",
2929
# Centralized app configurations
3030
apps: [
3131
project_name: [peek_app_id: "project_name_APP_ID", peek_app_secret: "project_name_APP_SECRET"],
@@ -43,7 +43,7 @@ PeekAppSDK.query_peek_pro("install_id", "query { test }")
4343
PeekAppSDK.query_peek_pro("install_id", "query { test }", %{}, :project_name)
4444
```
4545

46-
Note that `peek_api_url` and `peek_app_key` are always taken from the default configuration.
46+
Note that `peek_api_base_url` and `peek_api_key` are always taken from the default configuration.
4747

4848
## Some setup tips:
4949

config/test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ config :peek_app_sdk,
55
peek_app_secret: "test_secret",
66
peek_app_id: "test_app_id",
77
peek_api_base_url: "https://apps.peekapis.com",
8-
peek_app_key: "test_app_key",
8+
peek_api_key: "test_api_key",
99
client_secret_token: "test_client_secret",
1010
# Centralized configuration structure
1111
apps: [
1212
project_name: [
1313
peek_app_id: "project_name_app_id",
14-
peek_app_key: "project_name_app_key",
14+
peek_api_key: "project_name_api_key",
1515
peek_app_secret: "project_name_app_secret",
1616
client_secret_token: "project_name_client_secret"
1717
],

lib/peek_app_sdk.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ defmodule PeekAppSDK do
2424
config :peek_app_sdk,
2525
peek_app_secret: "DEFAULT_SECRET",
2626
peek_app_id: "DEFAULT_APP_ID",
27-
peek_api_url: "https://apps.peekapis.com/backoffice-gql",
28-
peek_app_key: "APP_KEY",
27+
peek_api_base_url: "https://apps.peekapis.com/",
28+
peek_api_key: "API_KEY",
2929
# Centralized app configurations
3030
apps: [
3131
project_name: [peek_app_id: "project_name_APP_ID", peek_app_secret: "project_name_APP_SECRET"],
3232
another_app: [peek_app_id: "ANOTHER_APP_ID", peek_app_secret: "ANOTHER_APP_SECRET"]
3333
]
3434
```
3535
36-
Note that `peek_api_base_url` and `peek_app_key` are always taken from the default
36+
Note that `peek_api_base_url` and `peek_api_key` are always taken from the default
3737
`:peek_app_sdk` configuration, regardless of which application identifier is used.
3838
"""
3939

@@ -50,7 +50,7 @@ defmodule PeekAppSDK do
5050
peek_app_secret: "project_name_secret",
5151
peek_app_id: "project_name_app_id",
5252
peek_api_base_url: "https://apps.peekapis.com",
53-
peek_app_key: "default_app_key"
53+
peek_api_key: "default_api_key"
5454
}
5555
5656
Using the default configuration:
@@ -60,7 +60,7 @@ defmodule PeekAppSDK do
6060
peek_app_secret: "default_secret",
6161
peek_app_id: "default_app_id",
6262
peek_api_base_url: "https://apps.peekapis.com",
63-
peek_app_key: "default_app_key"
63+
peek_api_key: "default_api_key"
6464
}
6565
"""
6666
@spec get_config(atom() | nil) :: map()

lib/peek_app_sdk/client.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ defmodule PeekAppSDK.Client do
3939

4040
config = Config.get_config(config_id)
4141
peek_app_id = config.peek_app_id
42-
peek_app_key = config.peek_app_key
42+
peek_api_key = config.peek_api_key
4343

4444
operation_name = operation_name(gql_query)
4545

@@ -49,7 +49,7 @@ defmodule PeekAppSDK.Client do
4949
method: :post,
5050
url: url,
5151
body: body_params,
52-
headers: headers(install_id, config_id, peek_app_key)
52+
headers: headers(install_id, config_id, peek_api_key)
5353
) do
5454
# If we get back an error, fail the whole thing and return the error for now.
5555
{:ok, %Tesla.Env{status: 200, body: %{errors: [_error | _rest] = errors}}} ->
@@ -98,10 +98,10 @@ defmodule PeekAppSDK.Client do
9898
[x_peek_auth_header(install_id, config_id)]
9999
end
100100

101-
defp headers(install_id, config_id, peek_app_key) do
101+
defp headers(install_id, config_id, peek_api_key) do
102102
[
103103
x_peek_auth_header(install_id, config_id),
104-
{"pk-api-key", peek_app_key}
104+
{"pk-api-key", peek_api_key}
105105
]
106106
end
107107

lib/peek_app_sdk/config.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ defmodule PeekAppSDK.Config do
1414
peek_app_secret: "DEFAULT_SECRET",
1515
peek_app_id: "DEFAULT_APP_ID",
1616
peek_api_base_url: "https://apps.peekapis.com",
17-
peek_app_key: "APP_KEY",
17+
peek_api_key: "API_KEY",
1818
client_secret_token: "CLIENT_SECRET_TOKEN",
1919
apps: [
2020
project_name: [peek_app_id: "project_name_app_id", peek_app_secret: "project_name_secret", client_secret_token: "base64_key"],
2121
another_app: [peek_app_id: "another_app_id", peek_app_secret: "another_app_secret"]
2222
]
2323
```
2424
25-
Note that `peek_api_base_url` and `peek_app_key` are always taken from the default
25+
Note that `peek_api_base_url` and `peek_api_key` are always taken from the default
2626
`:peek_app_sdk` configuration, regardless of which application identifier is used.
2727
"""
2828

@@ -32,7 +32,7 @@ defmodule PeekAppSDK.Config do
3232
client_secret_token: any(),
3333
peek_api_base_url: any(),
3434
peek_app_id: any(),
35-
peek_app_key: any(),
35+
peek_api_key: any(),
3636
peek_app_secret: any()
3737
}
3838
@doc """
@@ -48,7 +48,7 @@ defmodule PeekAppSDK.Config do
4848
peek_app_secret: "project_name_secret",
4949
peek_app_id: "project_name_app_id",
5050
peek_api_base_url: "https://apps.peekapis.com",
51-
peek_app_key: "default_app_key"
51+
peek_api_key: "default_api_key"
5252
}
5353
5454
Using the default configuration:
@@ -58,10 +58,10 @@ defmodule PeekAppSDK.Config do
5858
peek_app_secret: "default_secret",
5959
peek_app_id: "default_app_id",
6060
peek_api_base_url: "https://apps.peekapis.com",
61-
peek_app_key: "default_app_key"
61+
peek_api_key: "default_api_key"
6262
}
6363
64-
Note that `peek_api_base_url` and `peek_app_key` are always taken from the default
64+
Note that `peek_api_base_url` and `peek_api_key` are always taken from the default
6565
`:peek_app_sdk` configuration, regardless of which application identifier is used.
6666
"""
6767
@spec get_config(atom() | nil) :: map()
@@ -74,7 +74,7 @@ defmodule PeekAppSDK.Config do
7474
peek_app_id: Application.get_env(:peek_app_sdk, :peek_app_id),
7575
peek_api_base_url:
7676
Application.get_env(:peek_app_sdk, :peek_api_base_url, @default_peek_api_base_url),
77-
peek_app_key: Application.get_env(:peek_app_sdk, :peek_app_key),
77+
peek_api_key: Application.get_env(:peek_app_sdk, :peek_api_key),
7878
client_secret_token: Application.get_env(:peek_app_sdk, :client_secret_token)
7979
}
8080
end
@@ -91,7 +91,7 @@ defmodule PeekAppSDK.Config do
9191
peek_app_id: Keyword.get(app_config, :peek_app_id),
9292
peek_api_base_url:
9393
Application.get_env(:peek_app_sdk, :peek_api_base_url, @default_peek_api_base_url),
94-
peek_app_key: Keyword.get(app_config, :peek_app_key),
94+
peek_api_key: Keyword.get(app_config, :peek_api_key),
9595
client_secret_token: Keyword.get(app_config, :client_secret_token)
9696
}
9797
else

lib/peek_app_sdk/metrics/client.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ defmodule PeekAppSDK.Metrics.Client do
2828
}
2929

3030
config = Config.get_config(config_id)
31-
peek_app_key = config.peek_app_key
31+
peek_api_key = config.peek_api_key
3232
peek_app_id = config.peek_app_id
3333
peek_api_base_url = config.peek_api_base_url
3434

3535
url =
3636
"#{peek_api_base_url}/registry/installations/#{peek_app_id}/#{install_id}/configuration_status"
3737

38-
case Tesla.put!(client(), url, body, headers: headers(install_id, config_id, peek_app_key)) do
38+
case Tesla.put!(client(), url, body, headers: headers(install_id, config_id, peek_api_key)) do
3939
%Tesla.Env{status: 200} ->
4040
:ok
4141

@@ -169,10 +169,10 @@ defmodule PeekAppSDK.Metrics.Client do
169169
[x_peek_auth_header(install_id, config_id)]
170170
end
171171

172-
defp headers(install_id, config_id, peek_app_key) do
172+
defp headers(install_id, config_id, peek_api_key) do
173173
[
174174
x_peek_auth_header(install_id, config_id),
175-
{"pk-api-key", peek_app_key}
175+
{"pk-api-key", peek_api_key}
176176
]
177177
end
178178

test/peek_app_sdk/client_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ defmodule PeekAppSDK.ClientTest do
5656
end)
5757

5858
assert Enum.any?(env.headers, fn {k, v} ->
59-
k == "pk-api-key" && v == "project_name_app_key"
59+
k == "pk-api-key" && v == "project_name_api_key"
6060
end)
6161

6262
{:ok, %Tesla.Env{status: 200, body: %{data: response_data}}}
@@ -108,7 +108,7 @@ defmodule PeekAppSDK.ClientTest do
108108
Client.query_peek_pro(install_id, query, variables, :project_name)
109109
end
110110

111-
test "pk-api-key only sent if peek_app_key is set" do
111+
test "pk-api-key only sent if peek_api_key is set" do
112112
install_id = "test_install_id"
113113
query = "query Test { test }"
114114
variables = %{"foo" => "bar"}

test/peek_app_sdk/config_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ defmodule PeekAppSDK.ConfigTest do
4848
assert Map.has_key?(config, :client_secret_token)
4949
assert config.peek_app_secret == "project_name_app_secret"
5050
assert config.peek_app_id == "project_name_app_id"
51-
assert config.peek_app_key == "project_name_app_key"
51+
assert config.peek_api_key == "project_name_api_key"
5252
assert config.client_secret_token == "project_name_client_secret"
5353
end
5454

@@ -60,7 +60,7 @@ defmodule PeekAppSDK.ConfigTest do
6060
assert Map.has_key?(config, :client_secret_token)
6161
assert config.peek_app_secret == "other_app_secret"
6262
assert config.peek_app_id == "other_app_id"
63-
assert config.peek_app_key == nil
63+
assert config.peek_api_key == nil
6464
assert config.client_secret_token == nil
6565
end
6666

0 commit comments

Comments
 (0)