Skip to content

Commit

Permalink
refactor: API base URL to include current API version + related updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sr-murthy committed Dec 10, 2024
1 parent 265e1da commit 7df5bde
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/fsrapiclient/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def common_search(self, search_str: str) -> FsrApiResponse:
>>> client.common_search(urlencode({'q': 'Hastings Direct', 'type': 'firm'}))
<Response [200]>
"""
url = f'{FSR_API_CONSTANTS.BASEURL.value}/{self.api_version}/Search?{search_str}'
url = f'{FSR_API_CONSTANTS.BASEURL.value}/Search?{search_str}'

try:
return FsrApiResponse(self.api_session.get(url))
Expand Down Expand Up @@ -564,8 +564,6 @@ def _get_resource_info(self, resource_ref_number: str, resource_type: str, modif
url = (
f'{FSR_API_CONSTANTS.BASEURL.value}'
'/'
f'{self.api_version}'
'/'
f'{resource_endpoint_base}'
'/'
f'{resource_ref_number}'
Expand Down Expand Up @@ -1587,8 +1585,6 @@ def get_regulated_markets(self) -> FsrApiResponse:
url = (
f'{FSR_API_CONSTANTS.BASEURL.value}'
'/'
f'{self.api_version}'
'/'
'CommonSearch'
'?'
f'{urlencode({"q": "RM"})}'
Expand Down
6 changes: 3 additions & 3 deletions src/fsrapiclient/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ class FSR_API_CONSTANTS(Enum):
Examples
--------
>>> FSR_API_CONSTANTS.BASEURL.value
'https://register.fca.org.uk/services'
>>> FSR_API_CONSTANTS.API_VERSION.value
'V0.1'
>>> FSR_API_CONSTANTS.BASEURL.value
'https://register.fca.org.uk/services/V0.1'
>>> FSR_API_CONSTANTS.RESOURCE_TYPES.value
{'firm': {'type_name': 'firm', 'endpoint_base': 'Firm'}, 'fund': {'type_name': 'fund', 'endpoint_base': 'CIS'}, 'individual': {'type_name': 'individual', 'endpoint_base': 'Individuals'}}
"""

BASEURL = 'https://register.fca.org.uk/services'
API_VERSION = 'V0.1'
BASEURL = f'https://register.fca.org.uk/services/{API_VERSION}'
RESOURCE_TYPES = {
'firm': {'type_name': 'firm', 'endpoint_base': 'Firm'},
'fund': {'type_name': 'fund', 'endpoint_base': 'CIS'},
Expand Down
2 changes: 1 addition & 1 deletion tests/units/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class TestFsrApiConstants:

def test_fsr_api_constants(self):
assert FSR_API_CONSTANTS.BASEURL.value == 'https://register.fca.org.uk/services'
assert FSR_API_CONSTANTS.API_VERSION.value == 'V0.1'
assert FSR_API_CONSTANTS.BASEURL.value == 'https://register.fca.org.uk/services/V0.1'
assert FSR_API_CONSTANTS.RESOURCE_TYPES.value == {
'firm': {'type_name': 'firm', 'endpoint_base': 'Firm'},
'fund': {'type_name': 'fund', 'endpoint_base': 'CIS'},
Expand Down

0 comments on commit 7df5bde

Please sign in to comment.