DmitrMakeev commited on
Commit
e551110
·
verified ·
1 Parent(s): 4e34d1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +125 -4
app.py CHANGED
@@ -152,6 +152,41 @@ def send_request(list_id, email, phone, name, param_phone, param_name):
152
  "email": email,
153
  "unconfirmed": False,
154
  "values": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  {
156
  "parameter_id": param_phone,
157
  "kind": "string",
@@ -178,12 +213,98 @@ def send_request(list_id, email, phone, name, param_phone, param_name):
178
 
179
 
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  @app.route('/incoming', methods=['POST'])
182
  def handle_incoming_request():
183
  datas = request.json
184
  name = datas.get('name')
185
  email = datas.get('email')
186
  phone = datas.get('phone')
 
 
 
 
 
 
187
 
188
  # Устанавливаем временную зону Москвы
189
  moscow_timezone = pytz.timezone('Europe/Moscow')
@@ -197,12 +318,12 @@ def handle_incoming_request():
197
 
198
  if current_day in [0, 4, 5, 6]: # Понедельник, Пятница, Суббота, Воскресенье
199
  # Отправляем запросы в листы подряд
200
- response_1 = send_request(list_id_1, email, phone, name, 393120, 393119)
201
- response_2 = send_request(list_id_2, email, phone, name, 393196, 393195)
202
- response_3 = send_request(list_id_3, email, phone, name, 393198, 393197)
203
 
204
  # Возвращаем список ответов
205
- return {'responses': [response_1, response_2, response_3]}
206
 
207
  elif current_day == 1: # Вторник
208
  if current_hour < 19:
 
152
  "email": email,
153
  "unconfirmed": False,
154
  "values": [
155
+ {
156
+ "parameter_id": pr5_id,
157
+ "kind": "string",
158
+ "list_id": list_id,
159
+ "title": "pr5",
160
+ "value": pr5
161
+ },
162
+ {
163
+ "parameter_id": pr4_id,
164
+ "kind": "string",
165
+ "list_id": list_id,
166
+ "title": "pr4",
167
+ "value": pr4
168
+ },
169
+ {
170
+ "parameter_id": pr3_id,
171
+ "kind": "string",
172
+ "list_id": list_id,
173
+ "title": "pr3",
174
+ "value": pr3
175
+ },
176
+ {
177
+ "parameter_id": pr2_id,
178
+ "kind": "string",
179
+ "list_id": list_id,
180
+ "title": "pr2",
181
+ "value": pr2
182
+ },
183
+ {
184
+ "parameter_id": pr1_id,
185
+ "kind": "string",
186
+ "list_id": list_id,
187
+ "title": "pr1",
188
+ "value": pr1
189
+ },
190
  {
191
  "parameter_id": param_phone,
192
  "kind": "string",
 
213
 
214
 
215
 
216
+ # Константы для базового URL и токена авторизации
217
+ base_url = "https://api.notisend.com/v1"
218
+ token = "your_token_here"
219
+
220
+ # ID списков
221
+ list_id_1 = 560768
222
+ list_id_2 = 560832
223
+ list_id_3 = 560833
224
+
225
+ # Плейсхолдеры для ID параметров
226
+ pr5_id = 000000
227
+ pr4_id = 000000
228
+ pr3_id = 000000
229
+ pr2_id = 000000
230
+ pr1_id = 000000
231
+
232
+ def send_request(list_id, email, phone, name, param_phone, param_name, pr5, pr4, pr3, pr2, pr1, pr5_id, pr4_id, pr3_id, pr2_id, pr1_id):
233
+ """Функция для отправки запроса на сервер."""
234
+ data = {
235
+ "email": email,
236
+ "unconfirmed": False,
237
+ "values": [
238
+ {
239
+ "parameter_id": pr5_id,
240
+ "kind": "string",
241
+ "list_id": list_id,
242
+ "title": "pr5",
243
+ "value": pr5
244
+ },
245
+ {
246
+ "parameter_id": pr4_id,
247
+ "kind": "string",
248
+ "list_id": list_id,
249
+ "title": "pr4",
250
+ "value": pr4
251
+ },
252
+ {
253
+ "parameter_id": pr3_id,
254
+ "kind": "string",
255
+ "list_id": list_id,
256
+ "title": "pr3",
257
+ "value": pr3
258
+ },
259
+ {
260
+ "parameter_id": pr2_id,
261
+ "kind": "string",
262
+ "list_id": list_id,
263
+ "title": "pr2",
264
+ "value": pr2
265
+ },
266
+ {
267
+ "parameter_id": pr1_id,
268
+ "kind": "string",
269
+ "list_id": list_id,
270
+ "title": "pr1",
271
+ "value": pr1
272
+ },
273
+ {
274
+ "parameter_id": param_phone,
275
+ "kind": "string",
276
+ "list_id": list_id,
277
+ "title": "phone",
278
+ "value": phone
279
+ },
280
+ {
281
+ "parameter_id": param_name,
282
+ "kind": "string",
283
+ "list_id": list_id,
284
+ "title": "name",
285
+ "value": name
286
+ }
287
+ ]
288
+ }
289
+ headers = {
290
+ 'Authorization': f'Bearer {token}',
291
+ 'Content-Type': 'application/json'
292
+ }
293
+ response = requests.post(f"{base_url}/email/lists/{list_id}/recipients", json=data, headers=headers)
294
+ return response.json()
295
+
296
  @app.route('/incoming', methods=['POST'])
297
  def handle_incoming_request():
298
  datas = request.json
299
  name = datas.get('name')
300
  email = datas.get('email')
301
  phone = datas.get('phone')
302
+
303
+ pr5 = datas.get('pr5')
304
+ pr4 = datas.get('pr4')
305
+ pr3 = datas.get('pr3')
306
+ pr2 = datas.get('pr2')
307
+ pr1 = datas.get('pr1')
308
 
309
  # Устанавливаем временную зону Москвы
310
  moscow_timezone = pytz.timezone('Europe/Moscow')
 
318
 
319
  if current_day in [0, 4, 5, 6]: # Понедельник, Пятница, Суббота, Воскресенье
320
  # Отправляем запросы в листы подряд
321
+ response_1 = send_request(list_id_1, email, phone, name, 393120, 393119, pr5, pr4, pr3, pr2, pr1, pr5_id, pr4_id, pr3_id, pr2_id, pr1_id)
322
+ response_2 = send_request(list_id_2, email, phone, name, 393196, 393195, pr5, pr4, pr3, pr2, pr1, pr5_id, pr4_id, pr3_id, pr2_id, pr1_id)
323
+ response_3 = send_request(list_id_3, email, phone, name, 393198, 393197, pr5, pr4, pr3, pr2, pr1, pr5_id, pr4_id, pr3_id, pr2_id, pr1_id)
324
 
325
  # Возвращаем список ответов
326
+ return {'responses': [response_1, response_2, response_3]}
327
 
328
  elif current_day == 1: # Вторник
329
  if current_hour < 19: