# Backend API Spec (11/21) ## Passenger ### POST /passenger ### PUT /passenger * [BE] check email and phone number is valid * [BE] check email and phone number is not taken by another passenger * [DB] update passenger name, email and phone number `Q:after email modified, do we need to verify it again?` ### GET /passenger * [DB] search a record from passenger table ### GET /passenger/login ### GET /passenger/verify-email * [DB] search a record from passenger table by `emailVerificationToken` * [BE] check emailVerificationToken matches ### GET /passenger/{walletAddress}/email-status * [DB] search a record from passenger table * [BE] return the email status (true/false) ### POST /passenger/{walletAddress}/resend-email * [DB] search a record from passenger table by `walletAddress` * [BE] send a email with verification link --- ## Driver ### POST /driver ### PUT /driver * [BE] check every fields with coresponding rule * [BE] check email and phone number is not taken by other driver * [DB] update driver `Q:after vehicle information modified, do we need to inspect driver again?` ### GET /driver/login ### GET /driver/{walletAddress}/verification-status * [DB] search a record from driver table * [BE] return the verfication status (true/false) ### GET /driver/status * [DB] search a record from driver table * [BE] return driver status (AVAILABLE/NOT_AVAILABLE) ### PUT /driver/status * [BE] check parameter in [AVAILABLE,NOT_AVAILABLE] * [DB] update driver status ### PUT /driver/location * [BE] check location is a valid GPS coordinates * [DB] update driver location --- ## Journey Request ### POST /journey-request/search * [BE] check there is no JourneyRequest with status=WAIT * [BE] calculate journey prices for different vehicle type * [BE] add x% to the price * [DB] create a new JourneySearch record * [DB] create many JourneySearchPrice record * [BE] return the JourneySearch recode with JourneySearchPrice list ### GET /journey-request/current * [BE] search a record from JourneyRequest table for current passenger with status=WAIT ### POST /journey-request * [BE] check there is no JourneyRequest with status=WAIT * [SC] check the NFTicket has already be presented by passenger and have enough balance * [BE] check the JourneySearch record and JourneySearchPrice record exists * [DB] search for N nearby drivers * [DB] create a new JourneyRequest record with driver id list * [BE] send notifcations to them * [BE] return the JourneyRequest record ### POST /journey-request/{id}/accept * [BE] check current user is a driver * [DB] get the JourneyRequest record * [BE] check the JourneyRequest record status=WAIT * [BE] check current driver in the driver id list * [BE] send notification to every other driver * [DB] update the JourneyRequest record, set driver wallet address and status to ACCEPTED * [DB] create a new Journey record, with status is WAIT_FOR_DRIVER_ARRIVAL * [BE] calculate ETA based on driver's location and pickup location * [DB] update driver status to NOT_AVAILABLE * [BE] return Journey record ### POST /journey-request/{id}/cancel * [DB] get the journey request record * [BE] check current user is the passenger of this journey request * [SC] call returnTicket without cancel fee * [DB] update journey reqest status to CANCELED * [BE] send notification to every driver --- ## Journey ### GET /journey * [DB] get journey list of current user(both driver and passenger) ### GET /journey/current * [BE] search a record from Journey table for current passenger with status=WAIT_FOR_DRIVER_ARRIVAL or STARTED ### GET /journey/{id} * [DB] get journey record * [BE] check the journey passenger/driver is current user ### POST /journey/{id}/start * [BE] check signature * [DB] get journey record * [BE] check the journey passenger is current user * [BE] check journey status is WAIT_FOR_DRIVER_ARRIVAL * [SC] call checkIn function of NFTicket SC * [DB] update journey record status to STARTED and realPickupLocation(Name/timestamp) ### POST /journey/{id}/passenger-end * [BE] check signature * [DB] get journey record * [BE] check the journey passenger is current user * [BE] check journey status is STARTED or DRIVER_END * [SC] call checkOut function of NFTicket SC * [DB] update journey record status to PASSENGER_END or BOTH_END and realPassengerEndLocation(Name/timestamp) ### POST /journey/{id}/driver-end * [BE] check signature * [DB] get journey record * [BE] check the journey driver is current user * [BE] check journey status is STARTED or PASSENGER_END * [BE] calculate final price of this journey * [SC] call endService function of NFTicket SC * [DB] update journey record status to DRIVER_END or BOTH_END and realDriverEndLocation(Name/timestamp) * [DB] update driver status to AVAILABLE ### POST /journey/{id}/cancel * [DB] get the journey record * [BE] check current user is the passenger of this journey * [BE] calculate cancel fee * [SC] call returnTicket function with cancel fee * [DB] update journey status to CANCELED, update cancelFee and reason * [BE] send notification to the driver ### POST /journey/{id}/review * [DB] get the journey record * [BE] check current user is the passenger of this journey * [DB] update journey reviewScore and reviewRemark ### POST /journey/{id}/complaint --- ## Payment ### GET /payment/exchange-rates ### GET /payment/top-up/{page} ### POST /payment/top-up ### POST /payment/top-up/{id}/payment-complete ### GET /payment/withdraw/{page} ### POST /payment/withdraw ### GET /payment/refund/{page} ### POST /payment/refund/request ### POST /payment/refund/{id}/confirm ### GET /payment/transaction/{page} ###### tags: `Nigeria`