in source/services/vehicle/lib/trip.js [107:160]
trip.prototype.getVehicleTrip = function(ticket, vin, tripId, cb) {
// verify user owns vehicle
let params = {
TableName: ownerTable,
Key: {
owner_id: ticket['cognito:username'],
vin: vin
}
};
let docClient = new AWS.DynamoDB.DocumentClient(dynamoConfig);
docClient.get(params, function(err, data) {
if (err) {
console.log(err);
return cb(err, null);
}
if (!_.isEmpty(data)) {
let trip_params = {
TableName: ddbTable,
Key: {
vin: vin,
trip_id: tripId
}
};
let docClient = new AWS.DynamoDB.DocumentClient(dynamoConfig);
docClient.get(trip_params, function(err, trip_data) {
if (err) {
console.log(err);
return cb(err, null);
}
if (!_.isEmpty(trip_data)) {
return cb(null, trip_data.Item);
} else {
return cb({
error: {
message: 'The trip record requested does not exist.'
}
}, null);
}
});
} else {
return cb({
error: {
message: 'The vehicle requested is not registered under the user.'
}
}, null);
}
});
};