Exemple #1
0
#!/usr/bin/env python
import os
import json
import requests
from beacons.portal.models import Header, IBeacon
from beacons.portal.helper import BeaconHelper, URLBuilder
from config import REGISTER_BEACONS, ERROR, SUCCESS, LIST_BEACONS, \
    USER_INFO, ESTIMOTE_CMD, NAMESPACE

beacon_helper = BeaconHelper()
url_builder = URLBuilder()


def list_beacons(credentials):
    """
    Returns list of the registered beacons
    """
    header = Header(credentials.access_token)
    response = requests.get(LIST_BEACONS, headers=header.get_header_body())
    return json.loads(response.content)


def list_beacons_attachment(beacon, credentials):
    """
    Returns list of all the attachments to the beacon
    """
    header = Header(credentials.access_token)
    url = url_builder.beacon_view_attachment_url(beacon)
    response = requests.get(url, headers=header.get_header_body())
    return response.content