DmitrMakeev
commited on
Commit
•
548884c
1
Parent(s):
66fac43
Update google_db.py
Browse files- google_db.py +10 -15
google_db.py
CHANGED
@@ -6,12 +6,6 @@ import globs
|
|
6 |
api_key = os.getenv('api_key')
|
7 |
base_url = os.getenv('base_url') # URL сервера, например, 'https://api.notisend.ru/v1/email/'
|
8 |
token = os.getenv('token') # Ваш токен
|
9 |
-
globs.name = "Example Name"
|
10 |
-
globs.email = "[email protected]"
|
11 |
-
globs.phone = "1234567890"
|
12 |
-
globs.grup_id = "556756"
|
13 |
-
globs.pr1 = "example_pr1"
|
14 |
-
globs.pr2 = "example_pr2"
|
15 |
|
16 |
def save_db():
|
17 |
err = 0
|
@@ -28,13 +22,17 @@ def save_db():
|
|
28 |
|
29 |
# Создаем данные для отправки
|
30 |
data = {
|
31 |
-
'list_id': grups_id,
|
32 |
'email': emails,
|
|
|
33 |
'values': [
|
34 |
-
{'
|
35 |
-
{'
|
36 |
-
{'
|
37 |
-
{'
|
|
|
|
|
|
|
|
|
38 |
]
|
39 |
}
|
40 |
|
@@ -43,7 +41,7 @@ def save_db():
|
|
43 |
'Authorization': f'Bearer {token}',
|
44 |
'Content-Type': 'application/json'
|
45 |
}
|
46 |
-
response = requests.post(f"{base_url}lists/{
|
47 |
|
48 |
# Сохраняем ответ от сервера в глобальную переменную
|
49 |
globs.server_response = response.text
|
@@ -55,8 +53,6 @@ def save_db():
|
|
55 |
else:
|
56 |
response_message = f"Error: {response.status_code} - {response.text}"
|
57 |
err = 0
|
58 |
-
else:
|
59 |
-
response_message = "Invalid API key"
|
60 |
|
61 |
response_data = {
|
62 |
"status": "success" if err == 1 else "error",
|
@@ -66,4 +62,3 @@ def save_db():
|
|
66 |
}
|
67 |
|
68 |
return jsonify(response_data)
|
69 |
-
|
|
|
6 |
api_key = os.getenv('api_key')
|
7 |
base_url = os.getenv('base_url') # URL сервера, например, 'https://api.notisend.ru/v1/email/'
|
8 |
token = os.getenv('token') # Ваш токен
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
def save_db():
|
11 |
err = 0
|
|
|
22 |
|
23 |
# Создаем данные для отправки
|
24 |
data = {
|
|
|
25 |
'email': emails,
|
26 |
+
'unconfirmed': True,
|
27 |
'values': [
|
28 |
+
{'parameter_id': '1', 'value': names},
|
29 |
+
{'parameter_id': '2', 'value': phones},
|
30 |
+
{'parameter_id': '3', 'value': pr1s},
|
31 |
+
{'parameter_id': '4', 'value': pr2s}
|
32 |
+
],
|
33 |
+
'tags': [
|
34 |
+
'buyer',
|
35 |
+
'regular customer'
|
36 |
]
|
37 |
}
|
38 |
|
|
|
41 |
'Authorization': f'Bearer {token}',
|
42 |
'Content-Type': 'application/json'
|
43 |
}
|
44 |
+
response = requests.post(f"{base_url}lists/{grups_id}/recipients", json=data, headers=headers)
|
45 |
|
46 |
# Сохраняем ответ от сервера в глобальную переменную
|
47 |
globs.server_response = response.text
|
|
|
53 |
else:
|
54 |
response_message = f"Error: {response.status_code} - {response.text}"
|
55 |
err = 0
|
|
|
|
|
56 |
|
57 |
response_data = {
|
58 |
"status": "success" if err == 1 else "error",
|
|
|
62 |
}
|
63 |
|
64 |
return jsonify(response_data)
|
|