コード例 #1
0
def get_active_surveys():
    """ grab all active EFEAT surveys """

    usabilla_access_key = os.environ["USABILLA_ACCESS_KEY"]
    usabilla_secret_key = os.environ["USABILLA_SECRET_KEY"]

    try:
        api = ub.APIClient(usabilla_access_key, usabilla_secret_key)
        campaigns = api.get_resource(api.SCOPE_LIVE, api.PRODUCT_WEBSITES,
                                     api.RESOURCE_CAMPAIGN)
        surveys = campaigns["items"]

        output = []
        for survey in surveys:
            if is_active_survey(survey):
                output.append("{0}{1} {2}".format(USABILLA_URL, survey["id"],
                                                  survey["name"]))
        return "\n".join(output)

    except Exception as e:
        return e.message
コード例 #2
0
"""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
    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])
コード例 #3
0
ファイル: tests.py プロジェクト: maxbraeuninger/api-python
 def setUp(self):
     self.client_key = 'ACCESS-KEY'
     self.secret_key = 'SECRET-KEY'
     credentials = ub.Credentials(self.client_key, self.secret_key)
     self.client = ub.APIClient(ub.APIClient, credentials)
     self.assertIsInstance(self.client, ub.APIClient)