-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhandlers.py
52 lines (33 loc) · 1.12 KB
/
handlers.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
46
47
48
49
50
51
52
# handlers.py
import logging
from json import loads
from i90.api import Api
from i90.responses import responses
api = Api()
def get_redirect(event, *args, **kwargs):
if event.get("source") == "aws.events":
return
params = event.get("pathParameters", {})
token = params.get("token", "").strip()
return api.get(token)
def redirect(event, *args, **kwargs):
if event.get("source") == "aws.events":
return
params = event.get("pathParameters", {})
token = params.get("token", "").strip()
return api.redirect(token, event=event)
def claim(event, *args, **kwargs):
if event.get("source") == "aws.events":
return
body = loads(event.get("body", "{}"))
if not len(body):
return responses.user_error()
token = body.pop("token", None)
destination = body.pop("destination", None)
return api.claim(token, destination, **body)
def conceive(event, *args, **kwargs):
if event.get("source") == "aws.events":
return
body = loads(event.get("body", "{}"))
destination = body.pop("destination", None)
return api.conceive(destination, **body)