Skip to content

Commit 2e5e14c

Browse files
fix setting region as EU
1 parent 17420e9 commit 2e5e14c

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[build-system]
22
requires = ["setuptools>=42"]
3+
requires-python = ">=3.9"
34
build-backend = "setuptools.build_meta"
45

56
[tool.pytest.ini_options]

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = ipdata
3-
version = 4.0.3
3+
version = 4.0.4
44
author = Jonathan Kosgei
55
author_email = jonathan@ipdata.co
66
description = This is the official IPData client library for Python

src/ipdata/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# Configuration
1212
api_key = None
13-
endpoint = None
13+
endpoint = "https://api.ipdata.co/"
1414
default_client = None
1515

1616

@@ -28,6 +28,7 @@ def _proxy(method, *args, **kwargs):
2828
if not default_client:
2929
default_client = IPData(
3030
api_key,
31+
endpoint
3132
)
3233

3334
fn = getattr(default_client, method)

src/ipdata/ipdata.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ def lookup(self, resource="", fields=[]):
209209
try:
210210
data = DotDict(response.json())
211211
data["status"] = status_code
212+
if "eu-api" in self.endpoint:
213+
data["endpoint"] = "EU"
212214
except ValueError:
213215
raise IPDataException(
214216
f"An error occured while decoding the API response: {response.text}"
@@ -265,9 +267,12 @@ def bulk(self, resources, fields=[]):
265267
data["status"] = status_code
266268
return data
267269

268-
return DotDict(
270+
result = DotDict(
269271
{
270272
"responses": [DotDict(resource) for resource in data],
271273
"status": status_code,
272274
}
273275
)
276+
if "eu-api" in self.endpoint:
277+
result["endpoint"] = "EU"
278+
return result

0 commit comments

Comments
 (0)