DmitrMakeev commited on
Commit
7c09dcc
1 Parent(s): ff0ece9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -6
app.py CHANGED
@@ -26,25 +26,70 @@ def send_request():
26
 
27
  @app.route('/save_db', methods=['GET'])
28
  def save_db():
29
- show_params = False
 
 
30
 
 
 
31
  name = request.args.get('name')
32
- email = request.args.get('email')
 
33
  phone = request.args.get('phone')
34
- grup_id = request.args.get('grup_id')
35
  pr1 = request.args.get('pr1')
 
36
  pr2 = request.args.get('pr2')
37
-
 
 
38
  data = {
39
  "email": email,
40
- "unconfirmed": False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
 
43
  headers = {
44
  'Authorization': f'Bearer {token}',
45
  'Content-Type': 'application/json'
46
  }
47
- response = requests.post(f"{base_url}/email/lists/{grup_id}/recipients", json=data, headers=headers)
48
 
49
  if show_params:
50
  system_vars = {
 
26
 
27
  @app.route('/save_db', methods=['GET'])
28
  def save_db():
29
+ api_key_from_request = request.args.get('api_key')
30
+ if api_key_from_request != api_key:
31
+ return jsonify({'error': '666', 'message': 'Invalid api_key'}), 403
32
 
33
+ show_params = False
34
+ list_id = request.args.get('list_id')
35
  name = request.args.get('name')
36
+ name_id = request.args.get('name_id')
37
+ email = request.args.get('email')
38
  phone = request.args.get('phone')
39
+ phone_id = request.args.get('phone_id')
40
  pr1 = request.args.get('pr1')
41
+ pr1_id = request.args.get('pr1_id')
42
  pr2 = request.args.get('pr2')
43
+ pr2_id = request.args.get('pr2_id')
44
+ pr3 = request.args.get('pr3')
45
+ pr3_id = request.args.get('pr3_id')
46
  data = {
47
  "email": email,
48
+ "unconfirmed": False,
49
+ "values": [
50
+ {
51
+ "parameter_id": pr3_id,
52
+ "kind": "string",
53
+ "list_id": list_id,
54
+ "title": "pr3",
55
+ "value": pr3
56
+ },
57
+ {
58
+ "parameter_id": pr2_id,
59
+ "kind": "string",
60
+ "list_id": list_id,
61
+ "title": "pr2",
62
+ "value": pr2
63
+ },
64
+ {
65
+ "parameter_id": pr1_id,
66
+ "kind": "string",
67
+ "list_id": list_id,
68
+ "title": "pr1",
69
+ "value": pr1
70
+ },
71
+ {
72
+ "parameter_id": phone_id,
73
+ "kind": "string",
74
+ "list_id": list_id,
75
+ "title": "phone",
76
+ "value": phone
77
+ },
78
+ {
79
+ "parameter_id": name_id,
80
+ "kind": "string",
81
+ "list_id": list_id,
82
+ "title": "name",
83
+ "value": name
84
+ }
85
+ ]
86
  }
87
 
88
  headers = {
89
  'Authorization': f'Bearer {token}',
90
  'Content-Type': 'application/json'
91
  }
92
+ response = requests.post(f"{base_url}/email/lists/{list_id}/recipients", json=data, headers=headers)
93
 
94
  if show_params:
95
  system_vars = {