Skip to content

Commit 1c60764

Browse files
committed
get typeform API data and send Twilio SMS Setup
1 parent 8a3b167 commit 1c60764

File tree

5,926 files changed

+1176859
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,926 files changed

+1176859
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

Whitespace-only changes.

ProcessDynamoDBStream.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import print_function
2+
3+
def lambda_handler(event, context):
4+
for record in event['Records']:
5+
print(record['eventID'])
6+
print(record['eventName'])
7+
print('Successfully processed %s records.' % str(len(event['Records'])))

ProcessDynamoDBStream.zip

771 Bytes
Binary file not shown.

data.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"total_items": 3, "items": [{"landing_id": "7871feabea036e9aaebf7455bc3974de", "landed_at": "2018-06-14T20:38:36Z", "calculated": {"score": 0}, "answers": [{"field": {"ref": "9bab6d06-6922-4bc5-a68d-ead5c823c6d5", "type": "short_text", "id": "JomoOraxCZNn"}, "type": "text", "text": "1234561234"}, {"field": {"ref": "96d146f5-35b7-4feb-9a75-38a077ac62b1", "type": "short_text", "id": "shoDLZaF2OXS"}, "type": "text", "text": "Shubha"}, {"field": {"ref": "71ed1f17-75df-4b52-8aed-c55726e69f62", "type": "short_text", "id": "eK0p6DZrF9rZ"}, "type": "text", "text": "Sam"}, {"field": {"ref": "11280a52-2840-4dfe-b507-5d3e0327f61f", "type": "multiple_choice", "id": "dZ0AWx0czOJa"}, "type": "choice", "choice": {"label": "Birthday"}}], "token": "7871feabea036e9aaebf7455bc3974de", "submitted_at": "2018-06-14T20:38:54Z", "hidden": {}, "metadata": {"network_id": "16508e485f", "platform": "other", "referer": "https://shubhaswamy.typeform.com/to/ht2toX", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36", "browser": "default"}}, {"landing_id": "67a3fc4d4fcab385ca095014cb5d1df4", "landed_at": "2018-06-14T21:03:08Z", "calculated": {"score": 0}, "answers": [{"field": {"ref": "96d146f5-35b7-4feb-9a75-38a077ac62b1", "type": "short_text", "id": "shoDLZaF2OXS"}, "type": "text", "text": "test"}, {"field": {"ref": "71ed1f17-75df-4b52-8aed-c55726e69f62", "type": "short_text", "id": "eK0p6DZrF9rZ"}, "type": "text", "text": "test2"}, {"field": {"ref": "11280a52-2840-4dfe-b507-5d3e0327f61f", "type": "multiple_choice", "id": "dZ0AWx0czOJa"}, "type": "choice", "choice": {"label": "Graduation"}}, {"field": {"ref": "9bab6d06-6922-4bc5-a68d-ead5c823c6d5", "type": "short_text", "id": "JomoOraxCZNn"}, "type": "text", "text": "1234563456"}], "token": "67a3fc4d4fcab385ca095014cb5d1df4", "submitted_at": "2018-06-14T21:03:24Z", "hidden": {}, "metadata": {"network_id": "16508e485f", "platform": "other", "referer": "https://shubhaswamy.typeform.com/to/ht2toX", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36", "browser": "default"}}, {"landing_id": "8549e10896f25edd6636ce16d16d4b57", "landed_at": "2018-06-16T05:57:37Z", "calculated": {"score": 0}, "answers": [{"field": {"ref": "11280a52-2840-4dfe-b507-5d3e0327f61f", "type": "multiple_choice", "id": "dZ0AWx0czOJa"}, "type": "choice", "choice": {"label": "Have a great day!"}}, {"field": {"ref": "96d146f5-35b7-4feb-9a75-38a077ac62b1", "type": "short_text", "id": "shoDLZaF2OXS"}, "type": "text", "text": "Shubha "}, {"field": {"ref": "71ed1f17-75df-4b52-8aed-c55726e69f62", "type": "short_text", "id": "eK0p6DZrF9rZ"}, "type": "text", "text": "Myself"}, {"field": {"ref": "9bab6d06-6922-4bc5-a68d-ead5c823c6d5", "type": "short_text", "id": "JomoOraxCZNn"}, "type": "text", "text": "+19167051881"}], "token": "8549e10896f25edd6636ce16d16d4b57", "submitted_at": "2018-06-16T05:58:00Z", "hidden": {}, "metadata": {"network_id": "16508e485f", "platform": "other", "referer": "https://shubhaswamy.typeform.com/to/ht2toX", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36", "browser": "default"}}], "page_count": 1}

getresults.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import requests
2+
import json
3+
from collections import OrderedDict
4+
5+
# api-endpoint
6+
7+
ACCESS_TOKEN = "HrHtpTSH1ZpVZgoK9gdVZy5m66FTgSME8yA5h25rSemq"
8+
9+
#URL2 = "https://api.typeform.com/v1/form/ht2toX?key=HrHtpTSH1ZpVZgoK9gdVZy5m66FTgSME8yA5h25rSemq"
10+
URL = "https://api.typeform.com/forms/ht2toX/responses"
11+
12+
# location given here
13+
14+
response = requests.get(URL, headers={'authorization': 'bearer HrHtpTSH1ZpVZgoK9gdVZy5m66FTgSME8yA5h25rSemq'})
15+
data = response.json()
16+
17+
#data2 = json.loads(data.decode('utf-8'), object_pairs_hook=OrderedDict)
18+
#data2 =json.dumps(data)
19+
20+
#print(data2)
21+
#response2 = requests.get(URL2)
22+
#data2 = response2.json()
23+
24+
print(data)
25+
26+
27+
#with open('data.txt', 'w') as outfile:
28+
#json.dump(data, outfile)
29+
30+
31+
def printJSON(d):
32+
phoneNumber = ""
33+
34+
phoneNumber = ""
35+
for i in d['items']:
36+
for x in i['answers']:
37+
typeVal = x['type']
38+
print(type(x[typeVal]), x[typeVal])
39+
40+
41+
42+
43+
44+
'''
45+
phoneNumber = ""
46+
for i in d['items']:
47+
for x in i['answers']:
48+
typeVal = x['type']
49+
print(type(x[typeVal]), x[typeVal])
50+
51+
'''
52+
53+
printJSON(data)
54+
55+
print("done")
56+
57+
58+
#print(response.status_code)
59+
#print(data)
60+
61+
62+
#print(data)

input.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"Records":[
3+
{
4+
"eventID":"1",
5+
"eventName":"INSERT",
6+
"eventVersion":"1.0",
7+
"eventSource":"aws:dynamodb",
8+
"awsRegion":"us-east-1",
9+
"dynamodb":{
10+
"Keys":{
11+
"Id":{
12+
"N":"101"
13+
}
14+
},
15+
"NewImage":{
16+
"Message":{
17+
"S":"New item!"
18+
},
19+
"Id":{
20+
"N":"101"
21+
}
22+
},
23+
"SequenceNumber":"111",
24+
"SizeBytes":26,
25+
"StreamViewType":"NEW_AND_OLD_IMAGES"
26+
},
27+
"eventSourceARN":"stream-ARN"
28+
},
29+
{
30+
"eventID":"2",
31+
"eventName":"MODIFY",
32+
"eventVersion":"1.0",
33+
"eventSource":"aws:dynamodb",
34+
"awsRegion":"us-east-1",
35+
"dynamodb":{
36+
"Keys":{
37+
"Id":{
38+
"N":"101"
39+
}
40+
},
41+
"NewImage":{
42+
"Message":{
43+
"S":"This item has changed"
44+
},
45+
"Id":{
46+
"N":"101"
47+
}
48+
},
49+
"OldImage":{
50+
"Message":{
51+
"S":"New item!"
52+
},
53+
"Id":{
54+
"N":"101"
55+
}
56+
},
57+
"SequenceNumber":"222",
58+
"SizeBytes":59,
59+
"StreamViewType":"NEW_AND_OLD_IMAGES"
60+
},
61+
"eventSourceARN":"stream-ARN"
62+
},
63+
{
64+
"eventID":"3",
65+
"eventName":"REMOVE",
66+
"eventVersion":"1.0",
67+
"eventSource":"aws:dynamodb",
68+
"awsRegion":"us-east-1",
69+
"dynamodb":{
70+
"Keys":{
71+
"Id":{
72+
"N":"101"
73+
}
74+
},
75+
"OldImage":{
76+
"Message":{
77+
"S":"This item has changed"
78+
},
79+
"Id":{
80+
"N":"101"
81+
}
82+
},
83+
"SequenceNumber":"333",
84+
"SizeBytes":38,
85+
"StreamViewType":"NEW_AND_OLD_IMAGES"
86+
},
87+
"eventSourceARN":"stream-ARN"
88+
}
89+
]
90+
}

my_project/.Python

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/Python

my_project/bin/activate

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This file must be used with "source bin/activate" *from bash*
2+
# you cannot run it directly
3+
4+
deactivate () {
5+
unset -f pydoc >/dev/null 2>&1
6+
7+
# reset old environment variables
8+
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
9+
if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then
10+
PATH="$_OLD_VIRTUAL_PATH"
11+
export PATH
12+
unset _OLD_VIRTUAL_PATH
13+
fi
14+
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
15+
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
16+
export PYTHONHOME
17+
unset _OLD_VIRTUAL_PYTHONHOME
18+
fi
19+
20+
# This should detect bash and zsh, which have a hash command that must
21+
# be called to get it to forget past commands. Without forgetting
22+
# past commands the $PATH changes we made may not be respected
23+
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
24+
hash -r 2>/dev/null
25+
fi
26+
27+
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
28+
PS1="$_OLD_VIRTUAL_PS1"
29+
export PS1
30+
unset _OLD_VIRTUAL_PS1
31+
fi
32+
33+
unset VIRTUAL_ENV
34+
if [ ! "${1-}" = "nondestructive" ] ; then
35+
# Self destruct!
36+
unset -f deactivate
37+
fi
38+
}
39+
40+
# unset irrelevant variables
41+
deactivate nondestructive
42+
43+
VIRTUAL_ENV="/Users/shubha/Documents/Typeform/my_project"
44+
export VIRTUAL_ENV
45+
46+
_OLD_VIRTUAL_PATH="$PATH"
47+
PATH="$VIRTUAL_ENV/bin:$PATH"
48+
export PATH
49+
50+
# unset PYTHONHOME if set
51+
if ! [ -z "${PYTHONHOME+_}" ] ; then
52+
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
53+
unset PYTHONHOME
54+
fi
55+
56+
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
57+
_OLD_VIRTUAL_PS1="$PS1"
58+
if [ "x" != x ] ; then
59+
PS1="$PS1"
60+
else
61+
PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1"
62+
fi
63+
export PS1
64+
fi
65+
66+
# Make sure to unalias pydoc if it's already there
67+
alias pydoc 2>/dev/null >/dev/null && unalias pydoc
68+
69+
pydoc () {
70+
python -m pydoc "$@"
71+
}
72+
73+
# This should detect bash and zsh, which have a hash command that must
74+
# be called to get it to forget past commands. Without forgetting
75+
# past commands the $PATH changes we made may not be respected
76+
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
77+
hash -r 2>/dev/null
78+
fi

my_project/bin/activate.csh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This file must be used with "source bin/activate.csh" *from csh*.
2+
# You cannot run it directly.
3+
# Created by Davide Di Blasi <[email protected]>.
4+
5+
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
6+
7+
# Unset irrelevant variables.
8+
deactivate nondestructive
9+
10+
setenv VIRTUAL_ENV "/Users/shubha/Documents/Typeform/my_project"
11+
12+
set _OLD_VIRTUAL_PATH="$PATH"
13+
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
14+
15+
16+
17+
if ("" != "") then
18+
set env_name = ""
19+
else
20+
set env_name = `basename "$VIRTUAL_ENV"`
21+
endif
22+
23+
# Could be in a non-interactive environment,
24+
# in which case, $prompt is undefined and we wouldn't
25+
# care about the prompt anyway.
26+
if ( $?prompt ) then
27+
set _OLD_VIRTUAL_PROMPT="$prompt"
28+
set prompt = "[$env_name] $prompt"
29+
endif
30+
31+
unset env_name
32+
33+
alias pydoc python -m pydoc
34+
35+
rehash
36+

0 commit comments

Comments
 (0)