Skip to content

Commit bccd817

Browse files
committed
improve naming
1 parent 0e65d46 commit bccd817

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

workos/api_keys.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from workos.utils.request_helper import REQUEST_METHOD_POST
77

88
API_KEY_VALIDATION_PATH = "api_keys/validations"
9-
RESOURCE_OBJECT_PATH = "api_key"
9+
RESOURCE_OBJECT_ATTRIBUTE_NAME = "api_key"
1010

1111

1212
class ApiKeysModule(Protocol):
@@ -31,11 +31,12 @@ def __init__(self, http_client: SyncHTTPClient):
3131

3232
def validate_api_key(self, *, value: str) -> Optional[ApiKey]:
3333
response = self._http_client.request(
34-
API_KEY_VALIDATION_PATH, method=REQUEST_METHOD_POST, json={"value": value}
34+
API_KEY_VALIDATION_PATH, method=REQUEST_METHOD_POST, json={
35+
"value": value}
3536
)
36-
if response.get(RESOURCE_OBJECT_PATH) is None:
37+
if response.get(RESOURCE_OBJECT_ATTRIBUTE_NAME) is None:
3738
return None
38-
return ApiKey.model_validate(response[RESOURCE_OBJECT_PATH])
39+
return ApiKey.model_validate(response[RESOURCE_OBJECT_ATTRIBUTE_NAME])
3940

4041

4142
class AsyncApiKeys(ApiKeysModule):
@@ -46,8 +47,9 @@ def __init__(self, http_client: AsyncHTTPClient):
4647

4748
async def validate_api_key(self, *, value: str) -> Optional[ApiKey]:
4849
response = await self._http_client.request(
49-
API_KEY_VALIDATION_PATH, method=REQUEST_METHOD_POST, json={"value": value}
50+
API_KEY_VALIDATION_PATH, method=REQUEST_METHOD_POST, json={
51+
"value": value}
5052
)
51-
if response.get(RESOURCE_OBJECT_PATH) is None:
53+
if response.get(RESOURCE_OBJECT_ATTRIBUTE_NAME) is None:
5254
return None
53-
return ApiKey.model_validate(response[RESOURCE_OBJECT_PATH])
55+
return ApiKey.model_validate(response[RESOURCE_OBJECT_ATTRIBUTE_NAME])

0 commit comments

Comments
 (0)