def lambda_handler(event, context):

    #print(event)
    
    #rider_id = 69257
    #rider_mobile = "+11609467790"
    
    rider_id = int(event['queryStringParameters']['rider_id'])
    rider_mobile = event['queryStringParameters']['rider_mobile']

    rider_name = "person" + str(rider_id)
    print("Rider Name=" + rider_name)

    riderid = rider_name + "@example.com"
    rider_email = riderid
    print("Rider ID= " + riderid)

    print("Rider Mobile = " + rider_mobile)

    pickUpDateTime = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
    id =  ''.join(["%s" % randint(0, 9) for num in range(0, 7)])
    tripinfo = pickUpDateTime +"," + id 
    print("Trip Info= " + tripinfo)

    status = "Booked"
    print("Status=" + status)

    tripInfo = {
        "riderid" : riderid,
        "tripinfo" : tripinfo,
        "RIDER_ID" : rider_id,
        "RIDER_MOBILE" : rider_mobile,
        "PICKUP_DATETIME" : pickUpDateTime,
        "RIDER_NAME" : rider_name,
        "RIDER_EMAIL" : rider_email,
        "Status" : status
    }

    print("Trip Information =" + json.dumps(tripInfo, indent=2))

    response = updateTripInfo(tripInfo)
    print("Trip information has been updated to Trips table")

    print("Rider Booking Trip Information =" + json.dumps(response['Attributes'], indent = 4, cls=DecimalEncoder))
    
    responseObjects = {}
    responseObjects['statusCode'] = 200
    responseObjects['headers'] = {}
    responseObjects['headers']['Content-Type'] = 'application/json'
    responseObjects['body'] = json.dumps(response['Attributes'], indent = 4, cls=DecimalEncoder)
    
    return responseObjects
Exemplo n.º 2
0
trip_info = input("Enter your tripinfo : ")

tripCompletedInfo = {
    "riderid": rider_id,
    "tripinfo": trip_info,
    "DROPOFF_LATITUDE": str(dropoff_latitude),
    "RATE_CODE_ID": rate_codes[randint(0, 6)],
    "TOLLS_AMOUNT": str(round(random.uniform(0, 5), 2)),
    "IMPROVEMENT_SURCHARGE": str(round(random.uniform(0, 1), 1)),
    "TIP_AMOUNT": str(round(random.uniform(0, 10), 2)),
    "DROPOFF_DATETIME": datetime.datetime.utcnow().isoformat() + 'Z',
    "TRIP_DISTANCE": randint(1, 50),
    "TOTAL_AMOUNT": str(round(random.uniform(5, 150), 2)),
    "MTA_TAX": str(round(random.uniform(0, 1), 1)),
    "DROPOFF_LONGITUDE": str(dropoff_longitude),
    "PAYMENT_TYPET": randint(1, 7),
    "EXTRA": str(round(random.uniform(0, 1), 1)),
    "FARE_AMOUNT": str(round(random.uniform(5, 150), 2)),
    "PASSENGER_COUNT": randint(1, 7),
    "Status": "Completed"
}

print("Trip complettion information = ", json.dumps(tripCompletedInfo,
                                                    indent=2))

response = updateTripInfo(tripCompletedInfo, "InProgress")
print("Trip completion information has been updated to Trips table")

print("Driver trip completion informaiton =" +
      json.dumps(response['Attributes'], indent=4, cls=DecimalEncoder))
tripAcceptInfo = {
    "riderid": rider_id,
    "tripinfo": trip_info,
    "VENDOR_ID": vendor_id,
    "PICKUP_LONGITUDE": pickup_longitude,
    "PICKUP_LATITUDE": pickup_latitude,
    "TRIP_TYPE": 2,
    "STORE_AND_FWD_FLAG": "N",
    "CAB_TYPE_ID": driver_info['vehicle_details']['type'],
    "DRIVER_NAME": driver_info['driver_name'],
    "VEHICLE_ID": driver_info['vehicle_details']['id'],
    "DRIVER_ID": driver_info['driver_id'],
    "DRIVER_EMAIL": driver_info['driver_email'],
    "DRIVER_MOBILE": driver_info['driver_mobile'],
    "DriverDetails": {
        "Name": driver_info['driver_name'],
        "Vehicle Details": {
            "id": driver_info['vehicle_details']['id'],
            "type": driver_info['vehicle_details']['type']
        }
    },
    "Status": "InProgress"
}

print("Trip accept information =" + json.dumps(tripAcceptInfo, indent=2))

response = updateTripInfo(tripAcceptInfo, "Booked")
print("Trip accept information has been updated to Trips table")

print("Driver Accept Trip Informaiton =" +
      json.dumps(response['Attributes'], indent=4, cls=DecimalEncoder))
def lambda_handler(event, context):

    driver_details = [{
        "driver_email": "*****@*****.**",
        "driver_id": "556550",
        "driver_name": "driver556550",
        "driver_mobile": "+11720912154",
        "vehicle_details": {
            "id": "QSY353471",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "541829",
        "driver_name": "driver541829",
        "driver_mobile": "+11264112049",
        "vehicle_details": {
            "id": "GTR508161",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "507977",
        "driver_name": "driver507977",
        "driver_mobile": "+11088418780",
        "vehicle_details": {
            "id": "XVJ356159",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "551153",
        "driver_name": "driver551153",
        "driver_mobile": "+11240868167",
        "vehicle_details": {
            "id": "CPX160101",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "520045",
        "driver_name": "driver520045",
        "driver_mobile": "+11751510159",
        "vehicle_details": {
            "id": "HHR298952",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "514040",
        "driver_name": "driver514040",
        "driver_mobile": "+11661484862",
        "vehicle_details": {
            "id": "TLA210480",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "527336",
        "driver_name": "driver527336",
        "driver_mobile": "+11564984764",
        "vehicle_details": {
            "id": "OVY229214",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "510909",
        "driver_name": "driver510909",
        "driver_mobile": "+11261783124",
        "vehicle_details": {
            "id": "UDT200764",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "549736",
        "driver_name": "driver549736",
        "driver_mobile": "+11561755450",
        "vehicle_details": {
            "id": "ORX460076",
            "type": 2
        }
    }, {
        "driver_email": "*****@*****.**",
        "driver_id": "528204",
        "driver_name": "driver528204",
        "driver_mobile": "+11185992795",
        "vehicle_details": {
            "id": "PXX248130",
            "type": 2
        }
    }]

    #rider_id = "*****@*****.**"

    #trip_info = input("Enter your tripinfo : ")
    #trip_info = event["key1"]
    #trip_info = '2021-10-12T01:35:17Z,9150417'

    i_rider_id = int(event['queryStringParameters']['rider_id'])
    trip_info = event['queryStringParameters']['trip_info']

    rider_name = "person" + str(i_rider_id)
    rider_id = rider_name + "@example.com"

    vendor_id = 2

    pickup_longitude = str(round(random.uniform(-74, -73), 6))
    pickup_latitude = str(round(random.uniform(40, 41), 6))
    driver_info = driver_details[randint(0, 9)]

    tripAcceptInfo = {
        "riderid": rider_id,
        "tripinfo": trip_info,
        "VENDOR_ID": vendor_id,
        "PICKUP_LONGITUDE": pickup_longitude,
        "PICKUP_LATITUDE": pickup_latitude,
        "TRIP_TYPE": 2,
        "STORE_AND_FWD_FLAG": "N",
        "CAB_TYPE_ID": driver_info['vehicle_details']['type'],
        "DRIVER_NAME": driver_info['driver_name'],
        "VEHICLE_ID": driver_info['vehicle_details']['id'],
        "DRIVER_ID": driver_info['driver_id'],
        "DRIVER_EMAIL": driver_info['driver_email'],
        "DRIVER_MOBILE": driver_info['driver_mobile'],
        "DriverDetails": {
            "Name": driver_info['driver_name'],
            "Vehicle Details": {
                "id": driver_info['vehicle_details']['id'],
                "type": driver_info['vehicle_details']['type']
            }
        },
        "Status": "InProgress"
    }

    print("Trip accept information =" + json.dumps(tripAcceptInfo, indent=2))

    response = updateTripInfo(tripAcceptInfo, "Booked")
    print("Trip accept information has been updated to Trips table")

    print("Driver Accept Trip Information =" +
          json.dumps(response['Attributes'], indent=4, cls=DecimalEncoder))

    responseObjects = {}
    responseObjects['statusCode'] = 200
    responseObjects['headers'] = {}
    responseObjects['headers']['Content-Type'] = 'application/json'
    responseObjects['body'] = json.dumps(response['Attributes'],
                                         indent=4,
                                         cls=DecimalEncoder)

    return responseObjects
print("Rider ID= " + riderid)

rider_mobile = "+11609467790"
print("Rider Mobile = " + rider_mobile)

pickUpDateTime = datetime.datetime.utcnow().isoformat() + 'Z'
id = ''.join(["%s" % randint(0, 9) for num in range(0, 7)])
tripinfo = id + "," + pickUpDateTime
print("Trip Info= " + tripinfo)

status = "Booked"
print("Status=" + status)

tripInfo = {
    "riderid": riderid,
    "tripinfo": tripinfo,
    "RIDER_ID": rider_id,
    "RIDER_MOBILE": rider_mobile,
    "PICKUP_DATETIME": pickUpDateTime,
    "RIDER_NAME": rider_name,
    "RIDER_EMAIL": rider_email,
    "Status": status
}

print("Trip Information =" + json.dumps(tripInfo, indent=2))

response = updateTripInfo(tripInfo)
print("Trip information has been updated to Trips table")

print("Rider Booking Trip Informaiton =" +
      json.dumps(response['Attributes'], indent=4, cls=DecimalEncoder))
def lambda_handler(event, context):

    rate_codes = [1, 2, 3, 4, 5, 6, 99]

    #rider_id = "*****@*****.**"
    #trip_info = input("Enter your tripinfo : ")
    #trip_info = event["key1"]

    i_rider_id = int(event['queryStringParameters']['rider_id'])
    trip_info = event['queryStringParameters']['trip_info']

    rider_name = "person" + str(i_rider_id)
    rider_id = rider_name + "@example.com"

    dropoff_longitude = round(random.uniform(-74, -73), 6)
    dropoff_latitude = round(random.uniform(40, 41), 6)

    tripCompletedInfo = {
        "riderid":
        rider_id,
        "tripinfo":
        trip_info,
        "DROPOFF_LATITUDE":
        str(dropoff_latitude),
        "RATE_CODE_ID":
        rate_codes[randint(0, 6)],
        "TOLLS_AMOUNT":
        str(round(random.uniform(0, 5), 2)),
        "IMPROVEMENT_SURCHARGE":
        str(round(random.uniform(0, 1), 1)),
        "TIP_AMOUNT":
        str(round(random.uniform(0, 10), 2)),
        "DROPOFF_DATETIME":
        datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
        "TRIP_DISTANCE":
        randint(1, 50),
        "TOTAL_AMOUNT":
        str(round(random.uniform(5, 150), 2)),
        "MTA_TAX":
        str(round(random.uniform(0, 1), 1)),
        "DROPOFF_LONGITUDE":
        str(dropoff_longitude),
        "PAYMENT_TYPET":
        randint(1, 7),
        "EXTRA":
        str(round(random.uniform(0, 1), 1)),
        "FARE_AMOUNT":
        str(round(random.uniform(5, 150), 2)),
        "PASSENGER_COUNT":
        randint(1, 7),
        "Status":
        "Completed"
    }

    print("Trip completion information = ",
          json.dumps(tripCompletedInfo, indent=2))

    response = updateTripInfo(tripCompletedInfo, "InProgress")
    print("Trip completion information has been updated to Trips table")

    print("Driver trip completion information =" +
          json.dumps(response['Attributes'], indent=4, cls=DecimalEncoder))

    responseObjects = {}
    responseObjects['statusCode'] = 200
    responseObjects['headers'] = {}
    responseObjects['headers']['Content-Type'] = 'application/json'
    responseObjects['body'] = json.dumps(response['Attributes'],
                                         indent=4,
                                         cls=DecimalEncoder)

    return responseObjects