Skip to content

Commit debb4b4

Browse files
committed
Rename PlatformApiClient to Oauth2ApiClient
1 parent e893a7a commit debb4b4

5 files changed

Lines changed: 15 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22

33
## v0.0.7 - 2/28/23
4-
- Added PlatformApiClient for oauth2 authenticated calls to our Platform API
4+
- Added Oauth2ApiClient for oauth2 authenticated calls to our Platform API and Sierra
55

66
## v0.0.5 - 2/22/23
77
- Support write queries to PostgreSQL and MySQL databases

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This package contains common Python utility classes and functions.
1010
* Connecting to and querying a MySQL database
1111
* Connecting to and querying a PostgreSQL database using a connection pool
1212
* Connecting to and querying Redshift
13-
* Making requests to the NYPL Platform API
13+
* Making requests to the Oauth2 authenticated APIS such as NYPL Platform API and Sierra
1414

1515
## Functions
1616
* Reading a YAML config file and putting the contents in os.environ

src/nypl_py_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .classes.kinesis_client import KinesisClient, KinesisClientError # noqa
33
from .classes.kms_client import KmsClient, KmsClientError # noqa
44
from .classes.mysql_client import MySQLClient, MySQLClientError # noqa
5-
from .classes.platform_api_client import PlatformApiClient # noqa
5+
from .classes.oauth2_api_client import Oauth2ApiClient # noqa
66
from .classes.postgresql_client import PostgreSQLClient, PostgreSQLClientError # noqa
77
from .classes.redshift_client import RedshiftClient, RedshiftClientError # noqa
88
from .classes.s3_client import S3Client, S3ClientError # noqa

src/nypl_py_utils/classes/platform_api_client.py renamed to src/nypl_py_utils/classes/oauth2_api_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
from nypl_py_utils.functions.log_helper import create_log
55

66

7-
class PlatformApiClient:
7+
class Oauth2ApiClient:
88
"""
9-
Client for interacting with NYPL Platform API endpoints
9+
Client for interacting with an Oauth2 authenticated API such as NYPL's
10+
Platform API endpoints
1011
"""
1112

1213
def __init__(self, client_id=None, client_secret=None, base_url=None,
@@ -23,7 +24,7 @@ def __init__(self, client_id=None, client_secret=None, base_url=None,
2324
self.client = None
2425
self.token = None
2526

26-
self.logger = create_log('platform_api_client')
27+
self.logger = create_log('oauth2_api_client')
2728

2829
def get(self, request_path, **kwargs):
2930
"""
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
from requests_oauthlib import OAuth2Session
55

6-
from nypl_py_utils import PlatformApiClient
6+
from nypl_py_utils import Oauth2ApiClient
77
# from requests.exceptions import ConnectTimeout
88

99
_TOKEN_RESPONSE = {
@@ -18,18 +18,18 @@
1818
BASE_URL = 'https://example.com/api/v0.1'
1919

2020

21-
class TestPlatformApiClient:
21+
class TestOauth2ApiClient:
2222

2323
@pytest.fixture
2424
def test_instance(self, requests_mock):
2525
token_url = 'https://oauth.example.com/oauth/token'
2626
requests_mock.post(token_url, text=json.dumps(_TOKEN_RESPONSE))
2727

28-
return PlatformApiClient(base_url=BASE_URL,
29-
token_url=token_url,
30-
client_id='clientid',
31-
client_secret='clientsecret'
32-
)
28+
return Oauth2ApiClient(base_url=BASE_URL,
29+
token_url=token_url,
30+
client_id='clientid',
31+
client_secret='clientsecret'
32+
)
3333

3434
def test_uses_env_vars(self):
3535
env = {
@@ -41,7 +41,7 @@ def test_uses_env_vars(self):
4141
for key, value in env.items():
4242
os.environ[key] = value
4343

44-
client = PlatformApiClient()
44+
client = Oauth2ApiClient()
4545
assert client.client_id == 'env client id'
4646
assert client.client_secret == 'env client secret'
4747
assert client.token_url == 'env token url'

0 commit comments

Comments
 (0)