@@ -13,21 +13,28 @@ defmodule PeekAppSDK.Config do
1313 config :peek_app_sdk,
1414 peek_app_secret: "DEFAULT_SECRET",
1515 peek_app_id: "DEFAULT_APP_ID",
16- peek_api_url : "https://apps.peekapis.com/backoffice-gql ",
17- peek_app_key : "APP_KEY ",
16+ peek_api_base_url : "https://apps.peekapis.com",
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_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
29- @ default_peek_url "https://apps.peekapis.com/backoffice-gql "
29+ @ default_peek_api_base_url "https://apps.peekapis.com"
3030
31+ @ spec get_config ( ) :: % {
32+ client_secret_token: any ( ) ,
33+ peek_api_base_url: any ( ) ,
34+ peek_app_id: any ( ) ,
35+ peek_api_key: any ( ) ,
36+ peek_app_secret: any ( )
37+ }
3138 @ doc """
3239 Gets the configuration for the given identifier.
3340 If no identifier is provided, returns the default configuration from :peek_app_sdk.
@@ -40,8 +47,8 @@ defmodule PeekAppSDK.Config do
4047 %{
4148 peek_app_secret: "project_name_secret",
4249 peek_app_id: "project_name_app_id",
43- peek_api_url : "https://apps.peekapis.com/backoffice-gql ",
44- peek_app_key : "default_app_key "
50+ peek_api_base_url : "https://apps.peekapis.com",
51+ peek_api_key : "default_api_key "
4552 }
4653
4754 Using the default configuration:
@@ -50,11 +57,11 @@ defmodule PeekAppSDK.Config do
5057 %{
5158 peek_app_secret: "default_secret",
5259 peek_app_id: "default_app_id",
53- peek_api_url : "https://apps.peekapis.com/backoffice-gql ",
54- peek_app_key : "default_app_key "
60+ peek_api_base_url : "https://apps.peekapis.com",
61+ peek_api_key : "default_api_key "
5562 }
5663
57- Note that `peek_api_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
5865 `:peek_app_sdk` configuration, regardless of which application identifier is used.
5966 """
6067 @ spec get_config ( atom ( ) | nil ) :: map ( )
@@ -65,8 +72,9 @@ defmodule PeekAppSDK.Config do
6572 % {
6673 peek_app_secret: Application . get_env ( :peek_app_sdk , :peek_app_secret ) ,
6774 peek_app_id: Application . get_env ( :peek_app_sdk , :peek_app_id ) ,
68- peek_api_url: Application . get_env ( :peek_app_sdk , :peek_api_url , @ default_peek_url ) ,
69- peek_app_key: Application . get_env ( :peek_app_sdk , :peek_app_key ) ,
75+ peek_api_base_url:
76+ Application . get_env ( :peek_app_sdk , :peek_api_base_url , @ default_peek_api_base_url ) ,
77+ peek_api_key: Application . get_env ( :peek_app_sdk , :peek_api_key ) ,
7078 client_secret_token: Application . get_env ( :peek_app_sdk , :client_secret_token )
7179 }
7280 end
@@ -81,13 +89,39 @@ defmodule PeekAppSDK.Config do
8189 % {
8290 peek_app_secret: Keyword . get ( app_config , :peek_app_secret ) ,
8391 peek_app_id: Keyword . get ( app_config , :peek_app_id ) ,
84- peek_api_url: Application . get_env ( :peek_app_sdk , :peek_api_url , @ default_peek_url ) ,
85- peek_app_key: Keyword . get ( app_config , :peek_app_key ) ,
92+ peek_api_base_url:
93+ Application . get_env ( :peek_app_sdk , :peek_api_base_url , @ default_peek_api_base_url ) ,
94+ peek_api_key: Keyword . get ( app_config , :peek_api_key ) ,
8695 client_secret_token: Keyword . get ( app_config , :client_secret_token )
8796 }
8897 else
8998 # Fall back to default configuration if the app is not configured
9099 get_config ( nil )
91100 end
92101 end
102+
103+ # Migration helper functions
104+ @ doc """
105+ Checks for deprecated peek_api_url configuration and raises an error if found.
106+ This is called when using the update_configuration_status feature.
107+ """
108+ def check_deprecated_config! do
109+ if Application . get_env ( :peek_app_sdk , :peek_api_url ) do
110+ raise """
111+ Configuration error: peek_api_url is deprecated and no longer supported.
112+
113+ Please update your configuration to use peek_api_base_url instead:
114+
115+ OLD (deprecated):
116+ config :peek_app_sdk,
117+ peek_api_url: "https://apps.peekapis.com/backoffice-gql"
118+
119+ NEW (required):
120+ config :peek_app_sdk,
121+ peek_api_base_url: "https://apps.peekapis.com"
122+
123+ The SDK will automatically append the appropriate path (/backoffice-gql) when making API calls.
124+ """
125+ end
126+ end
93127end
0 commit comments