UNPKG

react-native-here-mobility-sdk

Version:

Offical Here Mobility SDK for react native to access Here's marketplace features

275 lines (257 loc) 11.1 kB
// @flow /********************************************************** * Copyright © 2018 HERE Global B.V. All rights reserved. * **********************************************************/ import { RideWaypoints, PriceEstimate, BookingConstraints, LatLng, CancellationPolicy, Supplier, TransitType } from "./Demand"; /** * Details of a driver. * @namespace DriverDetails * @property {string} name The full name of the driver. * @property {string} phoneNumber The phone number of the driver. * @property {string} photoUrl? URL pointing to photo of the driver, if one exists. null if it doesn't exist. * @property {string} drivingLicenseId? The driver's driving license number, if available. */ export type DriverDetails = { name: string, phoneNumber: string, photoUrl?: string, drivingLicenseId?: string }; /** * @property {string} NOT_SUPPLIED The supplier did not specify the vehicle type. * @property {string} STANDARD Standard vehicle. * @property {string} LIMO Limousine. * @property {string} VAN Van. * @property {string} OTHER Other type of vehicle. */ export type VehicleType = | "NOT_SUPPLIED" | "STANDARD" | "LIMO" | "VAN" | "OTHER"; /** * Vehicle details. * @namespace Vehicle * @property {string} licensePlateNumber License plate number. * @property {VehicleType} vehicleType The type of the vehicle. * @property {string} manufacturer The manufacturer of the vehicle. * @property {string} model The vehicle model. * @property {string.} color The vehicle color. */ export type Vehicle = { licensePlateNumber: string, vehicleType: VehicleType, manufacturer: string, model: string, color: string }; /** * The ride status. * @enum {string} RideStatus * @property {string} PROCESSING The request is being "processed" looking for a supplier. * @property {string} REJECTED None of the suppliers accepted the offer. No driver was assigned. * @property {string} ACCEPTED A supplier accepted the "ride" no driver was assigned yet. * @property {string} DRIVER_ASSIGNED A driver was assigned to the ride. * @property {string} DRIVER_EN_ROUTE The vehicle is on the way to the pickup point. * @property {string} AT_PICKUP The vehicle is waiting at the pickup point. * @property {string} PASSENGER_ON_BOARD The vehicle is on the way to the drop-off point. * @property {string} AT_DROP_OFF The vehicle arrived at the drop-off point. * @property {string} COMPLETED The ride was completed. * @property {string} CANCELLED The ride was cancelled (either by the driver or by the passenger) * @property {string} UNRECOGNIZED Unrecognized status of the ride */ export type RideStatus = | "PROCESSING" | "REJECTED" | "ACCEPTED" | "DRIVER_ASSIGNED" | "DRIVER_EN_ROUTE" | "AT_PICKUP" | "PASSENGER_ON_BOARD" | "AT_DROP_OFF" | "COMPLETED" | "CANCELLED" | "UNRECOGNIZED"; /** * A ride's status log. Contains the current status, and a chronological list of previous * statuses (ordered by timestamp in descending order). * @namespace RideStatusLog * @property { number} lastUpdateTime Timestamp of the last update, in milliseconds since Epoch. * @property { number} createTime The time the ride was created, in milliseconds since Epoch. * @property { number} closedTime? The time the ride was closed, in milliseconds since Epoch. null for active rides. * @property { boolean} isRideLocationAvailable Whether there are new updates on the ride location. The updates can be monitored via {@link #heremobilitysdkdemandregisterforridesupdates | HereMobilitySDKDemand#registerToRideUpdates }. * @property { RideStatus} currentStatus The current ride status. * @property { Array<RideRecord>} previousStatuses A list of the previous statuses, ordered by timestamp in descending order. */ export type RideStatusLog = { lastUpdateTime: number, createTime: number, closedTime?: number, isRideLocationAvailable: boolean, currentStatus: RideStatus, previousStatuses: Array<RideRecord> }; /** * @namespace RideRecord * @property {RideStatus} status The ride status. * @property {number} timestamp The timestamp of the status, in milliseconds since Epoch. */ export type RideRecord = { status: RideStatus, timestamp: number }; /** * The current location of the ride. * @namespace RideLocation * @property {string} rideId The ride ID. * @property {LatLng} vehicleLocation? Current location of the vehicle, if available. * @property {number} estimatedPickupTime? If the passenger was already picked up, will return the known pickup time. * @property {number} estimatedDropOffTime? If the vehicle already arrived, will return the known drop-off time. * @property {number} lastUpdateTime Timestamp of this update, in milliseconds since Epoch. */ export type RideLocation = { rideId: string, vehicleLocation?: LatLng, estimatedPickupTime?: number, estimatedDropOffTime?: number, lastUpdateTime: number }; /** * The details of a passenger. * @namespace PassengerDetails * @property {string} name The full name (first and last) of the passenger. * @property {string} phoneNumber The phone number of the passenger. * @property {string} photoUrl? Optional. A URL pointing to a photo of the passenger. null if doesn't exist. * @property {string} email? Optional. The email of the passenger, if exists. Return {@code null} if doesn't exist. */ export type PassengerDetails = { name: string, phoneNumber: string, photoUrl?: string, email?: string }; /** * Which party cancelled the ride. * @namespace CancellingParty * @property {string} DEMANDER The demander cancelled the ride. * @property {string} SUPPLIER The supplier cancelled the ride. */ export type CancellingParty = "DEMANDER" | "SUPPLIER"; /** * The status of the cancellation request. * @namespace CancellationStatus * @property {string} PROCESSING The cancellation request has been received and is now being processed. This value will be shown if there is a cancellation in progress, and this {@link CancellationInfo} is the result of {@link Ride} cancellationInfo. When receiving {@link CancellationInfo} as a result of {@link #heremobilitysdkdemandcancelride|HereMobilitySDKDemand#cancelRide}, this will never be the result. * @property {string} ACCEPTED The cancellation request was accepted. * @property {string} REJECTED The cancellation request was rejected. * @property {string} UNKNOWN The cancellation request is in unknown state. */ export type CancellationStatus = | "PROCESSING" | "ACCEPTED" | "REJECTED" | "UNKNOWN"; /** * Info about a ride cancellation. * @namespace CancellationInfo * @property {CancellingParty} cancellingParty Who cancelled the ride. * @property {string} cancelReason? The reason for the cancellation. * @property {number} requestTime The time the request was received at the marketplace. * @property {CancellationStatus} status The current status of the cancellation request. */ export type CancellationInfo = { cancellingParty: CancellingParty, cancelReason?: string, requestTime: number, status: CancellationStatus }; /** * Active Ride. * @namespace Ride * @property {string} userId ID of the user who ordered the ride. * @property {string} rideId Ride ID, to be sent to the server. * @property {RideWaypoints} route The route of the ride. * @property {number} prebookPickupTime? The requested pickup time in milliseconds since Epoch. Exists only for pre-booked rides. * @property {PriceEstimate} bookingEstimatedPrice? The price estimate, as was determined by booking time (will not be updated during the ride). * @property {BookingConstraints} constraints The constraints of the booking (e.g. passenger count, suitcase count...) * @property {RideStatusLog} statusLog The status log of the ride (current status and previous statuses). * @property {Supplier} supplier? The ride supplier. null if no supplier was assigned. * @property {PassengerDetails} passenger The details of the passenger that is the contact for this ride. * @property {string} passengerNote? An optional custom note from the passenger to the supplier. * @property {DriverDetails} driver? The details of the driver. null if no driver was assigned. * @property {Vehicle} vehicle? The vehicle. null if no vehicle was assigned, or no vehicle info was supplied. * @property {CancellationPolicy} cancellationPolicy The cancellation policy. * @property {CancellationInfo} cancellationInfo? If the ride was cancelled, contains info about the cancellation. Otherwise null */ export type Ride = { userId: string, rideId: string, route: RideWaypoints, prebookPickupTime?: number, bookingEstimatedPrice?: PriceEstimate, constraints: BookingConstraints, statusLog: RideStatusLog, supplier?: Supplier, passenger: PassengerDetails, passengerNote?: string, driver?: DriverDetails, vehicle?: Vehicle, cancellationPolicy: CancellationPolicy, cancellationInfo?: CancellationInfo }; /** * @property {string} PAST Finished rides (includes the statuses: COMPLETED, REJECTED or CANCELLED) for the last 72 hours. * @property {string} FUTURE Prebooked rides, up to 30 minutes before arrival time. * @property {string} ONGOING Ongoing rides. * @property {string} ALL All rides. */ export type StatusFilter = "PAST" | "FUTURE" | "ONGOING" | "ALL"; /** * @property {string} UPDATE_TIME_ASC Sort according to update time, ascending * @property {string} UPDATE_TIME_DESC Sort according to update time, descending * @property {string} CREATE_TIME_ASC Sort according to creation time, ascending * @property {string} CREATE_TIME_DESC Sort according to creation time, descending */ export type RideQuerySortType = | "UPDATE_TIME_ASC" | "UPDATE_TIME_DESC" | "CREATE_TIME_ASC" | "CREATE_TIME_DESC"; /** * Query to get a list of rides according to given filters. * @namespace RideQuery * @property {number} fromUpdateTime? Return only rides that were updated since this time. The lowest allowed value is NOW - 3 Hours. If an earlier time is requested, only rides from the last 3 hours will be returned. * @property {number} limit? Limit number of results to return. If not given, the default is 200 * @property {StatusFilter} statusFilter? Query only for rides with the given status filter. If not given, the default is 'ALL' * @property {RideQuerySortType} sortBy? In which order to sort the result. If not given, the default is 'UPDATE_TIME_ASC' */ export type RideQuery = { fromUpdateTime?: number, limit?: number, statusFilter?: StatusFilter, sortBy?: RideQuerySortType }; /** * Response to a {@link RideQuery}; contains the list of rides that match the query filters. * @namespace RideQueryResponse * @property { Array<Ride>} rides List of rides matching the query filters. * @property { number} fromTime Optional, The earliest update time in this result set. Given in seconds since Epoch. * @property { number} toTime The latest update time in this result set. Given in seconds since Epoch. */ export type RideQueryResponse = { rides: Array<Ride>, fromTime?: number, toTime: number };