Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -147,31 +147,32 @@ def handle_incoming_request():
|
|
147 |
name = datas.get('name')
|
148 |
email = datas.get('email')
|
149 |
phone = datas.get('phone')
|
150 |
-
|
151 |
current_datetime = datetime.datetime.now()
|
152 |
current_day = 5 # 0 - Понедельник, ..., 6 - Воскресенье
|
153 |
current_hour = current_datetime.hour
|
154 |
|
155 |
if current_day in [0, 4, 5, 6]: # Понедельник, Пятница, Суббота, Воскресенье
|
156 |
-
#
|
|
|
|
|
|
|
157 |
# Лист 1
|
158 |
-
|
159 |
-
list_id = 560768
|
160 |
-
data = {
|
161 |
"email": email,
|
162 |
"unconfirmed": False,
|
163 |
"values": [
|
164 |
{
|
165 |
"parameter_id": 393120,
|
166 |
"kind": "string",
|
167 |
-
"list_id":
|
168 |
"title": "phone",
|
169 |
"value": phone
|
170 |
},
|
171 |
{
|
172 |
"parameter_id": 393119,
|
173 |
"kind": "string",
|
174 |
-
"list_id":
|
175 |
"title": "name",
|
176 |
"value": name
|
177 |
}
|
@@ -181,9 +182,39 @@ def handle_incoming_request():
|
|
181 |
'Authorization': f'Bearer {token}',
|
182 |
'Content-Type': 'application/json'
|
183 |
}
|
184 |
-
response = requests.post(f"{base_url}/email/lists/560768/recipients", json=data, headers=headers)
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
|
|
187 |
|
188 |
elif current_day == 1: # Вторник
|
189 |
if current_hour < 19:
|
|
|
147 |
name = datas.get('name')
|
148 |
email = datas.get('email')
|
149 |
phone = datas.get('phone')
|
150 |
+
|
151 |
current_datetime = datetime.datetime.now()
|
152 |
current_day = 5 # 0 - Понедельник, ..., 6 - Воскресенье
|
153 |
current_hour = current_datetime.hour
|
154 |
|
155 |
if current_day in [0, 4, 5, 6]: # Понедельник, Пятница, Суббота, Воскресенье
|
156 |
+
# Отправка в лист 1, лист 2 подряд
|
157 |
+
list_id_1 = 560768
|
158 |
+
list_id_2 = 560769
|
159 |
+
|
160 |
# Лист 1
|
161 |
+
data_1 = {
|
|
|
|
|
162 |
"email": email,
|
163 |
"unconfirmed": False,
|
164 |
"values": [
|
165 |
{
|
166 |
"parameter_id": 393120,
|
167 |
"kind": "string",
|
168 |
+
"list_id": list_id_1,
|
169 |
"title": "phone",
|
170 |
"value": phone
|
171 |
},
|
172 |
{
|
173 |
"parameter_id": 393119,
|
174 |
"kind": "string",
|
175 |
+
"list_id": list_id_1,
|
176 |
"title": "name",
|
177 |
"value": name
|
178 |
}
|
|
|
182 |
'Authorization': f'Bearer {token}',
|
183 |
'Content-Type': 'application/json'
|
184 |
}
|
|
|
185 |
|
186 |
+
# Отправляем первый запрос и сохраняем ответ
|
187 |
+
response_1 = requests.post(f"{base_url}/email/lists/{list_id_1}/recipients", json=data_1, headers=headers)
|
188 |
+
|
189 |
+
# Лист 2
|
190 |
+
data_2 = {
|
191 |
+
"email": email,
|
192 |
+
"unconfirmed": False,
|
193 |
+
"values": [
|
194 |
+
{
|
195 |
+
"parameter_id": 393120,
|
196 |
+
"kind": "string",
|
197 |
+
"list_id": list_id_2,
|
198 |
+
"title": "phone",
|
199 |
+
"value": phone
|
200 |
+
},
|
201 |
+
{
|
202 |
+
"parameter_id": 393119,
|
203 |
+
"kind": "string",
|
204 |
+
"list_id": list_id_2,
|
205 |
+
"title": "name",
|
206 |
+
"value": name
|
207 |
+
}
|
208 |
+
]
|
209 |
+
}
|
210 |
+
|
211 |
+
# Отправляем второй запрос и сохраняем ответ
|
212 |
+
response_2 = requests.post(f"{base_url}/email/lists/{list_id_2}/recipients", json=data_2, headers=headers)
|
213 |
+
|
214 |
+
# Возвращаем список ответов
|
215 |
+
return {'responses': [response_1.json(), response_2.json()]}
|
216 |
|
217 |
+
|
218 |
|
219 |
elif current_day == 1: # Вторник
|
220 |
if current_hour < 19:
|