Esempio n. 1
0
def create_demo_user(guid):
    """
    Create a new user for a single demo

    :param guid:   The demo's guid
    :param {
        "retailerId": "123"
    }

    :return: {
        "id": "123",
        "demoId": "123",
        "username": "******",
        "email": "*****@*****.**"
    }
    """

    # Get inputs and make sure required params are not null
    data = web_utils.get_json_data(request)
    retailer_id = data.get('retailerId')
    web_utils.check_null_input(
        (guid, 'demo for which to create a user'),
        (retailer_id, 'retailer to make a user for the demo'))

    user = user_service.create_user(guid, retailer_id)
    return Response(user, status=201, mimetype='application/json')
Esempio n. 2
0
def create_demo():
    """
    Create a new demo resource.

    :param {
        "name": "Example Demo Name",
        "email": "*****@*****.**"
    }

    :return: {
        "id": "123",
        "name": "Example Demo Name",
        "guid": "JDJhJDEdTRUR...VBrbW9vcj3k4L2sy",
        "createdAt": "2015-11-05T22:00:51.692765",
        "users": [{User}...{User}]
    }

    """

    # Get inputs and make sure required params are not null
    data = web_utils.get_json_data(request)
    demo_name = data.get('name')
    user_email = data.get('email')
    web_utils.check_null_input(
        (demo_name, 'demo name for the new demo session'))

    demo = demo_service.create_demo(demo_name, user_email)
    return Response(demo, status=201, mimetype='application/json')
Esempio n. 3
0
def create_shipment():
    """
    Create a new shipment object.

    :param {
        "status": "NEW",
        "estimatedTimeOfArrival": "2016-07-10T00:00:00.000Z",
        "fromId": "D2",
        "toId": "123"
    }

    :return: {
        "id": "123",
        "status": "ACCEPTED",
        "createdAt": "2015-11-05T22:00:51.692765",
        "updatedAt": "2015-11-08T22:00:51.692765",
        "deliveredAt": "2015-11-08T22:00:51.692765",
        "estimatedTimeOfArrival": "2016-07-10T00:00:00.000Z",
        "currentLocation": {Address},
        "fromId": "D2",
        "toId:": "123"
    }

    """

    # Get inputs and make sure required params are not null
    data = get_json_data(request)

    shipment = shipment_service.create_shipment(token=g.auth['loopback_token'],
                                                shipment=data)
    return Response(shipment, status=201, mimetype='application/json')
def create_shipment():
    """
    Create a new shipment object.

    :param {
        "status": "NEW",
        "estimatedTimeOfArrival": "2016-07-10T00:00:00.000Z",
        "fromId": "D2",
        "toId": "123"
    }

    :return: {
        "id": "123",
        "status": "ACCEPTED",
        "createdAt": "2015-11-05T22:00:51.692765",
        "updatedAt": "2015-11-08T22:00:51.692765",
        "deliveredAt": "2015-11-08T22:00:51.692765",
        "estimatedTimeOfArrival": "2016-07-10T00:00:00.000Z",
        "currentLocation": {Address},
        "fromId": "D2",
        "toId:": "123"
    }

    """

    # Get inputs and make sure required params are not null
    data = get_json_data(request)

    shipment = shipment_service.create_shipment(token=g.auth['loopback_token'], shipment=data)
    return Response(shipment,
                    status=201,
                    mimetype='application/json')
Esempio n. 5
0
def create_demo():
    """
    Create a new demo resource.

    :param {
        "name": "Example Demo Name",
        "email": "*****@*****.**"
    }

    :return: {
        "id": "123",
        "name": "Example Demo Name",
        "guid": "JDJhJDEdTRUR...VBrbW9vcj3k4L2sy",
        "createdAt": "2015-11-05T22:00:51.692765",
        "users": [{User}...{User}]
    }

    """

    # Get inputs and make sure required params are not null
    data = web_utils.get_json_data(request)
    demo_name = data.get('name')
    user_email = data.get('email')
    web_utils.check_null_input((demo_name, 'demo name for the new demo session'))

    demo = demo_service.create_demo(demo_name, user_email)
    return Response(demo,
                    status=201,
                    mimetype='application/json')
Esempio n. 6
0
def create_demo_user(guid):
    """
    Create a new user for a single demo

    :param guid:   The demo's guid
    :param {
        "retailerId": "123"
    }

    :return: {
        "id": "123",
        "demoId": "123",
        "username": "******",
        "email": "*****@*****.**"
    }
    """

    # Get inputs and make sure required params are not null
    data = web_utils.get_json_data(request)
    retailer_id = data.get('retailerId')
    web_utils.check_null_input((guid, 'demo for which to create a user'),
                               (retailer_id, 'retailer to make a user for the demo'))

    user = user_service.create_user(guid, retailer_id)
    return Response(user,
                    status=201,
                    mimetype='application/json')
Esempio n. 7
0
def acknowledge_recommendation():
    """
    Acknowledge a recommendation.
    """
    body = get_json_data(request)

    response = weather_service.acknowledge_recommendation(
        g.auth['guid'], body.get('id'))
    return Response(response, status=200, mimetype='application/json')
Esempio n. 8
0
def get_observations():
    """
    Return observations for the given location.
    :return: observations for the given location.
    """
    body = get_json_data(request)

    observations = weather_service.get_observations(body.get('latitude'),
                                                    body.get('longitude'))
    return Response(observations, status=200, mimetype='application/json')
def update_shipment(shipment_id):
    """
    Update a single shipment object.

    :param shipment_id:   The shipment's id
    :param  {
        "id": "123",
        "status": "SHIPPED",
        "createdAt": "2015-11-05T22:00:51.692765",
        "updatedAt": "2015-11-08T22:00:51.692765",
        "deliveredAt": "2015-11-08T22:00:51.692765",
        "estimatedTimeOfArrival": "2015-11-07T22:00:51.692765",
        "currentLocation": {Address},
        "fromId": "D2",
        "toId:": "123"
    }

    :return: {
        "id": "123",
        "status": "SHIPPED",
        "createdAt": "2015-11-05T22:00:51.692765",
        "updatedAt": "2015-11-08T22:00:51.692765",
        "deliveredAt": "2015-11-08T22:00:51.692765",
        "estimatedTimeOfArrival": "2015-11-07T22:00:51.692765",
        "currentLocation": {Address},
        "fromId": "D2",
        "toId:": "123"
    }

    """
    check_null_input((shipment_id, 'shipment to update'))

    updated_shipment = get_json_data(request)
    shipment = shipment_service.update_shipment(token=g.auth['loopback_token'],
                                                shipment_id=shipment_id, shipment=updated_shipment)
    return Response(shipment,
                    status=200,
                    mimetype='application/json')
Esempio n. 10
0
def update_shipment(shipment_id):
    """
    Update a single shipment object.

    :param shipment_id:   The shipment's id
    :param  {
        "id": "123",
        "status": "SHIPPED",
        "createdAt": "2015-11-05T22:00:51.692765",
        "updatedAt": "2015-11-08T22:00:51.692765",
        "deliveredAt": "2015-11-08T22:00:51.692765",
        "estimatedTimeOfArrival": "2015-11-07T22:00:51.692765",
        "currentLocation": {Address},
        "fromId": "D2",
        "toId:": "123"
    }

    :return: {
        "id": "123",
        "status": "SHIPPED",
        "createdAt": "2015-11-05T22:00:51.692765",
        "updatedAt": "2015-11-08T22:00:51.692765",
        "deliveredAt": "2015-11-08T22:00:51.692765",
        "estimatedTimeOfArrival": "2015-11-07T22:00:51.692765",
        "currentLocation": {Address},
        "fromId": "D2",
        "toId:": "123"
    }

    """
    check_null_input((shipment_id, 'shipment to update'))

    updated_shipment = get_json_data(request)
    shipment = shipment_service.update_shipment(token=g.auth['loopback_token'],
                                                shipment_id=shipment_id,
                                                shipment=updated_shipment)
    return Response(shipment, status=200, mimetype='application/json')