Skip to content

Commit df0cad4

Browse files
committed
Add path to endpoint
1 parent b2a16ae commit df0cad4

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

python_core/python_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class HttpEndpoint:
1010
"""
1111

1212

13-
def __init__(self, endpoint_subdomain, global_req_params):
13+
def __init__(self, endpoint_subdomain, global_req_params, path=""):
1414
"""
1515
HttpEndpoint class, one instance per endpoint, offers get/post HTTP methods
1616
and handles both HTTP errors and API errors
@@ -21,7 +21,7 @@ def __init__(self, endpoint_subdomain, global_req_params):
2121
"""
2222

2323
self.endpoint_subdomain = endpoint_subdomain
24-
self.endpoint = f"https://{endpoint_subdomain}.abstractapi.com/v1/"
24+
self.endpoint = f"https://{endpoint_subdomain}.abstractapi.com/v1/{path}"
2525
self.global_req_params = global_req_params
2626

2727

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='abstract_python_core',
11-
version='1.0.0',
11+
version='1.1.0',
1212
author='Benjamin Bouchet',
1313
author_email='libraries@abstractapi.com',
1414
description='AbstractAPI Python Core Library - Used by the other Abstract API libraries.',

tests/test_python_core.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@ def __init__(self, *args, **kwargs):
1616
"https://phonevalidation.abstractapi.com/v1/", {'lang' : 'python'}
1717
)
1818

19+
def test_default_endpoint(self):
20+
21+
endpoint = HttpEndpoint(
22+
endpoint_subdomain='phonevalidation',
23+
global_req_params={
24+
'lang' : 'python'
25+
}
26+
)
27+
self.assertEqual(endpoint.endpoint, 'https://phonevalidation.abstractapi.com/v1/')
28+
29+
def test_endpoint_with_path(self):
30+
31+
endpoint = HttpEndpoint(
32+
endpoint_subdomain='phonevalidation',
33+
global_req_params={
34+
'lang' : 'python'
35+
},
36+
path='sub-dir/'
37+
)
38+
self.assertEqual(endpoint.endpoint, 'https://phonevalidation.abstractapi.com/v1/sub-dir/')
39+
1940
def test_no_config(self):
2041

2142
try:

0 commit comments

Comments
 (0)