-
Notifications
You must be signed in to change notification settings - Fork 0
/
sponsors.py
45 lines (38 loc) · 1.27 KB
/
sponsors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
from parse_response import parse_response
BASE_URL = 'https://pythoncanarias.es'
def get_sponsors_information() -> object:
url = 'https://pythoncanarias.es/api/v1/events/pydaygc19/sponsors'
response = requests.get(url)
data = response.json()
return data
def create_sponsor_cards(sponsor_information: list) -> list:
sponsors = []
for sponsor in sponsor_information['result']:
sponsors.append(
{
"card": {
"title": sponsor['name'],
"imageUri": BASE_URL + sponsor['logo'],
"buttons": [
{
"text": "prueba button"
}
]
},
'platform': 'TELEGRAM',
}
)
return sponsors
def sponsors_action(req: object = None) -> object:
"""sponsor action
"""
sponsors_information = get_sponsors_information()
sponsor_cards = create_sponsor_cards(sponsors_information)
result = {"fulfillmentMessages": []}
for sponsor_card in sponsor_cards:
result['fulfillmentMessages'].append(sponsor_card)
response = parse_response(result)
return response