-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathexamples_apps.py
More file actions
49 lines (41 loc) · 1.55 KB
/
examples_apps.py
File metadata and controls
49 lines (41 loc) · 1.55 KB
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
"""Example Usabilla for Apps"""
import usabilla as ub
from datetime import datetime, timedelta
if __name__ == '__main__':
# Create an API client with access key and secret key
api = ub.APIClient('YOUR-ACCESS-KEY', 'YOUR-SECRET-KEY')
# Set the limit of buttons to retrieve to 1
if False:
api.set_query_parameters({'limit': 1})
# Set a limit for last 7 days
# NB: You might need to convert the since_unix calculation from scientific notation or set the since parameter manually
if False:
epoch = datetime(1970, 1, 1)
since = timedelta(days=7)
since_unix = (datetime.utcnow() - since - epoch).total_seconds() * 1000
api.set_query_parameters({'since': since_unix})
# Get all apps forms for this account
forms = api.get_resource(api.SCOPE_LIVE, api.PRODUCT_APPS, api.RESOURCE_APP)
first_form = forms['items'][0]
print first_form['name']
# Get the feedback of the first app form
feedback = api.get_resource(
api.SCOPE_LIVE,
api.PRODUCT_APPS,
api.RESOURCE_FEEDBACK,
first_form['id'],
iterate=True)
print len([item for item in feedback])
# Campaigns for apps
app_campaigns = api.get_resource(
api.SCOPE_LIVE,
api.PRODUCT_APPS,
api.RESOURCE_CAMPAIGN)
first_campaign = app_campaigns['items'][0]
responses = api.get_resource(
api.SCOPE_LIVE,
api.PRODUCT_APPS,
api.RESOURCE_CAMPAIGN_RESULT,
first_campaign['id'],
iterate=True)
print len([item for item in responses])