Skip to content

Commit 15d1e4e

Browse files
Merge pull request #8 from socketlabs/hotfix/remote-endpoint
adding setter for HttpEndpoint
2 parents 6619038 + ae6d7d3 commit 15d1e4e

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

socketlabs/injectionapi/core/httpendpoint.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1+
from urllib.parse import urlparse
2+
13
class HttpEndpoint(object):
24
"""
35
The HTTP endpoint
46
"""
57

6-
def __init__(self, host: str = None, url: str = None):
8+
def __init__(self, url: str):
79
"""
810
Create an instance of the HttpEndpoint class
911
:param host: the host name
1012
:type host: str
1113
:param url: the url
1214
:type url: str
1315
"""
14-
self._host = host
15-
self._url = url
16+
parsed_url = urlparse(url)
17+
self._host = parsed_url.hostname
18+
self._url = parsed_url.path
19+
1620

1721
@property
1822
def url(self):

socketlabs/injectionapi/socketlabsclient.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,25 @@ def __init__(self, server_id: int, api_key: str, proxy: Proxy = None):
3838
self._http_proxy = proxy
3939
self._request_timeout = 120
4040
self._number_of_retries = 0
41+
self._http_endpoint = "https://inject.socketlabs.com/api/v1/email"
4142

4243
@property
43-
def __endpoint(self):
44+
def endpoint(self):
4445
"""
4546
The SocketLabs Injection API endpoint
4647
:return the Http Endpoint for the request
4748
:rtype HttpEndpoint
4849
"""
49-
return HttpEndpoint("inject.socketlabs.com", "/api/v1/email")
50+
return self._http_endpoint
51+
52+
@endpoint.setter
53+
def endpoint(self, http_endpoint: str):
54+
"""
55+
The SocketLabs Injection API endpoint
56+
:return the Http Endpoint for the request
57+
:rtype HttpEndpoint
58+
"""
59+
self._http_endpoint = http_endpoint
5060

5161
@property
5262
def __proxy(self):
@@ -91,7 +101,8 @@ def __build_http_request(self, authentication: str):
91101
:return the HttpRequest object to use for the request
92102
:rtype HttpRequest
93103
"""
94-
req = HttpRequest(HttpRequest.HttpRequestMethod.POST, self.__endpoint, self.request_timeout, authentication)
104+
endpoint = HttpEndpoint(self.endpoint)
105+
req = HttpRequest(HttpRequest.HttpRequestMethod.POST, endpoint, self.request_timeout, authentication)
95106
if self._http_proxy is not None:
96107
req.proxy = self._http_proxy
97108
return req

socketlabs/injectionapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version_info = (1, 4, 3)
1+
version_info = (1, 4, 4)
22
__version__ = '.'.join(str(v) for v in version_info)

0 commit comments

Comments
 (0)