Skip to content

Commit 0fe7667

Browse files
committed
✨ build: satinize
1 parent 52bbf8e commit 0fe7667

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ __pycache__
33
dist
44
build
55
dymoapi.egg-info
6-
env
6+
env
7+
.env
8+
venv
9+
.venv

dymoapi/branches/private.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
def is_valid_data(token, data):
99
if not any([key in list(data.keys()) for key in ["url", "email", "phone", "domain", "creditCard", "ip", "wallet", "userAgent", "iban"]]): raise BadRequestError("You must provide at least one parameter.")
1010
try:
11-
response = requests.post(f"{get_base_url()}/v1/private/secure/verify", json=data, headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.61", "Authorization": token})
11+
response = requests.post(f"{get_base_url()}/v1/private/secure/verify", json=data, headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.62", "Authorization": token})
1212
response.raise_for_status()
1313
return response.json()
1414
except requests.RequestException as e: raise APIError(str(e))
1515

1616
def is_valid_data_raw(token, data):
1717
if not any([key in list(data.keys()) for key in ["url", "email", "phone", "domain", "creditCard", "ip", "wallet", "userAgent", "iban"]]): raise BadRequestError("You must provide at least one parameter.")
1818
try:
19-
response = requests.post(f"{get_base_url()}/v1/private/secure/verify", json=data, headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.61", "Authorization": token})
19+
response = requests.post(f"{get_base_url()}/v1/private/secure/verify", json=data, headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.62", "Authorization": token})
2020
response.raise_for_status()
2121
return response.json()
2222
except requests.RequestException as e: raise APIError(str(e))
@@ -54,7 +54,7 @@ def is_valid_email(token: Optional[str], email: str, rules: Optional[Dict[str, L
5454
resp = requests.post(
5555
f"{get_base_url()}/v1/private/secure/verify",
5656
json={"email": email, "plugins": plugins},
57-
headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.61", "Authorization": token}
57+
headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.62", "Authorization": token}
5858
)
5959
resp.raise_for_status()
6060
data = resp.json().get("email", {})
@@ -121,7 +121,7 @@ def is_valid_ip(token: Optional[str], ip: str, rules: Optional[Dict[str, List[st
121121
resp = requests.post(
122122
f"{get_base_url()}/v1/private/secure/verify",
123123
json={"email": ip, "plugins": plugins},
124-
headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.61", "Authorization": token}
124+
headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.62", "Authorization": token}
125125
)
126126
resp.raise_for_status()
127127
data = resp.json().get("ip", {})
@@ -185,7 +185,7 @@ def is_valid_phone(token: Optional[str], phone: str, rules: Optional[Dict[str, L
185185
resp = requests.post(
186186
f"{get_base_url()}/v1/private/secure/verify",
187187
json={"phone": phone, "plugins": plugins},
188-
headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.61", "Authorization": token}
188+
headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.62", "Authorization": token}
189189
)
190190
resp.raise_for_status()
191191
data = resp.json().get("phone", {})
@@ -224,7 +224,7 @@ def send_email(token, data):
224224
if not data.get("subject"): raise BadRequestError("You must provide a subject for the email to be sent.")
225225
if not data.get("html"): raise BadRequestError("You must provide HTML.")
226226
try:
227-
response = requests.post(f"{get_base_url()}/v1/private/sender/sendEmail", json=data, headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.61", "Authorization": token})
227+
response = requests.post(f"{get_base_url()}/v1/private/sender/sendEmail", json=data, headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.62", "Authorization": token})
228228
response.raise_for_status()
229229
return response.json()
230230
except requests.RequestException as e: raise APIError(str(e))
@@ -240,7 +240,7 @@ def get_random(token, data):
240240
if data.min < -1000000000 or data.min > 1000000000: raise BadRequestError("'min' must be an integer in the interval [-1000000000}, 1000000000].")
241241
if data.max < -1000000000 or data.max > 1000000000: raise BadRequestError("'max' must be an integer in the interval [-1000000000}, 1000000000].")
242242
try:
243-
response = requests.post(f"{get_base_url()}/v1/private/srng", json=data, headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.61", "Authorization": token})
243+
response = requests.post(f"{get_base_url()}/v1/private/srng", json=data, headers={"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.62", "Authorization": token})
244244
response.raise_for_status()
245245
return response.json()
246246
except requests.RequestException as e: raise APIError(str(e))

dymoapi/branches/public.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ..utils.decorators import deprecated
55
from ..exceptions import APIError, BadRequestError
66

7-
headers = {"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.61"}
7+
headers = {"User-Agent": "DymoAPISDK/1.0.0", "X-Dymo-SDK-Env": "Python", "X-Dymo-SDK-Version" : "0.0.62"}
88

99
def get_prayer_times(data):
1010
"""
@@ -31,8 +31,7 @@ def get_prayer_times(data):
3131
return response.json()
3232
except requests.RequestException as e: raise APIError(str(e))
3333

34-
@deprecated("satinize")
35-
def satinizer(data):
34+
def satinize(input_value):
3635
"""
3736
Sanitizes the given input according to the Dymo API standard.
3837
@@ -47,13 +46,34 @@ def satinizer(data):
4746
APIError: If the request fails.
4847
"""
4948
try:
50-
input_value = data.get("input")
5149
if input_value is None: raise BadRequestError("You must specify at least the input.")
5250
response = requests.get(f"{get_base_url()}/v1/public/inputSatinizer", params={"input":quote(input_value)}, headers=headers)
5351
response.raise_for_status()
5452
return response.json()
5553
except requests.RequestException as e: raise APIError(str(e))
5654

55+
@deprecated("satinize")
56+
def satinizer(input_value):
57+
"""
58+
Sanitizes the given input according to the Dymo API standard.
59+
60+
Args:
61+
data (dict): Data containing the input to sanitize.
62+
63+
Returns:
64+
dict: Sanitized input.
65+
66+
Raises:
67+
BadRequestError: If the input is not provided.
68+
APIError: If the request fails.
69+
"""
70+
try:
71+
if input is None: raise BadRequestError("You must specify at least the input.")
72+
response = requests.get(f"{get_base_url()}/v1/public/inputSatinizer", params={"input":quote(input_value)}, headers=headers)
73+
response.raise_for_status()
74+
return response.json()
75+
except requests.RequestException as e: raise APIError(str(e))
76+
5777
def satinize(input_value):
5878
"""
5979
Sanitizes the given input according to the Dymo API standard.

setup.py

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

33
setup(
44
name="dymoapi",
5-
version="0.0.61",
5+
version="0.0.62",
66
packages=find_packages(),
77
description="Dymo Python API library.",
88
long_description=open("README.md").read(),

0 commit comments

Comments
 (0)