app/customers/customer_views.py
def post(self):
        '''place a new parcel order.'''

        data = request.get_json()
        origin = data['origin']
        price = data['price']
        destination = data['destination']
        weight = data['weight']

        validate = validators.Validators()

        if not validate.valid_destination_name(destination):
            return {'message': "destination is invalid"}, 400

        if not validate.valid_origin_name(origin):
            return {'message': "invalid origin name"}, 400

        if type(price) != int:
            return {'message': "Invalid price"}, 400

        if type(weight) != int:
            return {'message': "Invalid weight"}, 400

        order = Order(origin, price, destination, weight)

        if order.destination in destinations:
            orders.append(order)
            return {"message": "keep tight!Your parcel order has been placed!"}, 201
        return {"message": "sorry we do not deliver to {}".format(order.destination)}
place a new parcel order.
place a new parcel order.
place a new parcel order .
def post(self):
        data = request.get_json()
        origin = data['origin']
        price = data['price']
        destination = data['destination']
        weight = data['weight']
        validate = validators.Validators()
        if not validate.valid_destination_name(destination):
            return {'message': "destination is invalid"}, 400
        if not validate.valid_origin_name(origin):
            return {'message': "invalid origin name"}, 400
        if type(price) != int:
            return {'message': "Invalid price"}, 400
        if type(weight) != int:
            return {'message': "Invalid weight"}, 400
        order = Order(origin, price, destination, weight)
        if order.destination in destinations:
            orders.append(order)
            return {"message": "keep tight!Your parcel order has been placed!"}, 201
        return {"message": "sorry we do not deliver to {}".format(order.destination)}
def post ( self ) : data = request . get_json ( ) origin = data [ 'origin' ] price = data [ 'price' ] destination = data [ 'destination' ] weight = data [ 'weight' ] validate = validators . Validators ( ) if not validate . valid_destination_name ( destination ) : return { 'message' : "destination is invalid" } , 400 if not validate . valid_origin_name ( origin ) : return { 'message' : "invalid origin name" } , 400 if type ( price ) != int : return { 'message' : "Invalid price" } , 400 if type ( weight ) != int : return { 'message' : "Invalid weight" } , 400 order = Order ( origin , price , destination , weight ) if order . destination in destinations : orders . append ( order ) return { "message" : "keep tight!Your parcel order has been placed!" } , 201 return { "message" : "sorry we do not deliver to {}" . format ( order . destination ) }
place a new parcel order.
place a new parcel order .
'''place a new parcel order.'''
self