UNPKG

react-native-here-mobility-sdk

Version:

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

215 lines (199 loc) 8.17 kB
// @flow /********************************************************** * Copyright © 2018 HERE Global B.V. All rights reserved. * **********************************************************/ /** * Represents a location on the planet, defined as a (latitude, longitude) pair. * @namespace LatLng * @property {number} lat The latitude; between -90 and 90 degrees, inclusive. * @property {number} lng The longitude; between -180 (inclusive) and 180 (exclusive) degrees. */ export type LatLng = { lat: number, lng: number }; /** * A generic address type. Note that due to the many different address standards, and different uses of this class, all of its fields are optionals. * @namespace Address * @property {string} countryName Optional, the country name. * @property {string} countryCode Optional, the ISO 3166 Alpha 3 country code. * @property {string} stateName Optional, the state name (if relevant). * @property {string} cityName Optional, the city name. * @property {string} districtName Optional, the district name (if relevant). * @property {string} streetName Optional, the street name. * @property {string} houseNumber Optional, the house number. * @property {string} postalCode Optional, the postal code. * @property {string} county Optional, the county (second subdivision level below the country). * @property {string} subDistrict Optional, the sub-district (subdivision level below the district; e.g. commonly used in IND). * @property {string} building Optional, the building name (e.g. commonly used in HKG). * @property {Array<String>} addressLines Optional, the formatted address lines, as they would have been written on an envelope. This field is optional, and may contain empty list. */ export type Address = { countryName?: String, countryCode?: String, stateName?: String, cityName?: String, districtName?: String, streetName?: String, houseNumber?: String, postalCode?: String, county?: String, subDistrict?: String, building?: String, addressLines?: Array<String> }; /** * Waypoint Type, that encapsulates a LatLng type, and additional information. * @namespace Waypoint * @property {LatLng} location Location of the waypoint. * @property {Address} address Optional, address of the waypoint, null if no address exists. * @property {string} description Optional, sets the free text description of the waypoint. */ export type Waypoint = { location: LatLng, address?: Address, description?: string }; /** * The route of the ride, composed of the pickup location and the destination. * @namespace RideWaypoints * @property {Waypoint} pickup Pickup waypoint. * @property {Waypoint} destination Destination waypoint. */ export type RideWaypoints = { pickup: Waypoint, destination: Waypoint }; /** * Range of the price. * @namespace PriceRange * @property {number} lowerBound Minimum amount. * @property {number} upperBound Maximum amount. * @property {string} currencyCode Currency code. */ export type PriceRange = { lowerBound: number, upperBound: number, currencyCode: string }; /** * Options relevant to public transport offers. * @namespace TransitOptions * @property {number} maxAllowedTransfers Optional, maximum number of allowed transportation method changes. Allowed values are between 0-6, or null . If null is given, there will be no limit on the number of transfers. * @property {number} maxWalkingDistance Optional, maximum walking distance in the offer. The measurement unit is meters. valid values are between 0-6000 meters. The default value is 2000 meters. * @property {string} locale Optional, the locale to use for the {@link PublicTransportRideOffer}. Complies with the ISO 639-1 standard. The default is "EN". */ export type TransitOptions = { maxAllowedTransfers?: number, maxWalkingDistance?: number, locale?: string }; /** * Constraints that the supplier must fulfill for the current booking. * @namespace BookingConstraints * @property {number} passengerCount Number of passengers on the ride. * @property {number} suitcaseCount Number of suitcases on the ride. */ export type BookingConstraints = { passengerCount: number, suitcaseCount: number }; /** * @namespace RideOfferRequestSortType * @property {string} BY_PRICE Sort offers by price (lowest price first) * @property {string} BY_ETA Sort offers by ETA to the pickup point (shortest ETA first) */ export type RideOfferRequestSortType = "BY_PRICE" | "BY_ETA"; /** * Request from the SDK to the server for ride offers. * @namespace RideOffersRequest * @property {RideWaypoints} rideWaypoints The requested route. * @property {BookingConstraints} constraints Optional, conditions that the supplier must accommodate, such as number of passengers, wheelchair access, etc. * @property {number} prebookPickupTime Optional pre-booked pickup time, if the ride is requested for more than 30 minutes in the future. The time is given in milliseconds since Epoch. * @property {PriceRange} priceRange Optional price range acceptable to the passenger. * @property {RideOfferRequestSortType} sortType Optional sort type. If not given, the order is by price, and then by ETA. * @property {String} passengerNote Optional note from the passenger. * @property {TransitOptions} transitOptions Optional Transit options. This will affect the public transport offers. **/ export type RideOffersRequest = { rideWaypoints: RideWaypoints, constraints?: BookingConstraints, prebookPickupTime?: number, priceRange?: PriceRange, sortType?: RideOfferRequestSortType, passengerNote?: String, transitOptions?: TransitOptions }; /** * The type of the offer. * @property {string} TAXI * @property {string} PUBLIC_TRANSPORT */ export type TransitType = "TAXI" | "PUBLIC_TRANSPORT"; /** * Price object with the amount to pay and the currency. * @namespace Price * @property {number} amount The amount to pay. * @property {string} currencyCode The ISO 4217 currency code of the price. */ export type Price = { amount: number, currencyCode: string }; /** * Estimation of the price, produced either by the HERE Marketplace or by a ride supplier. * The estimate can be either a single fixed price or a price range. * The recommended way to use this class is as follows: * @example * const { fixedPrice, priceRange } = estimatedPrice; * if (fixedPrice) { * const { amount, currencyCode } = fixedPrice; * console.log('price: ' + amount + " " + currencyCode); * } else { * const { lowerBound, upperBound, currencyCode } = priceRange; * console.log('price: ' + lowerBound + "-" + upperBound + " " + currencyCode); * } * @namespace PriceEstimate * @property {Price} fixedPrice The fixed price, if exists. The fixed price. Null if the estimation is a range. * @property {PriceRange} priceRange The price range, if exists. The price range. Null if the estimation is a fixed price. */ export type PriceEstimate = { fixedPrice: Price, priceRange: PriceRange }; /** * @property {string} UNKNOWN Unknown cancellation policy. * @property {string} ALLOWED Cancellation by the client is allowed. * @property {string} NOT_ALLOWED Cancellation by the client is not allowed. */ export type CancellationPolicy = "UNKNOWN" | "ALLOWED" | "NOT_ALLOWED"; /** * Supplier details. * @namespace Supplier * @property {string} englishName The English spelling of the supplier. * @property {string} localName Optional, the name of the supplier in the local language. * @property {string} logoUrl Optional, the logo URL of the supplier (if exists). * @property {string} phoneNumber Supplier phone number. * @property {string} address Supplier address. */ export type Supplier = { englishName: string, localName?: string, logoUrl?: string, phoneNumber: string, address: string }; /** * HereMobilityDemandError */ export type HereMobilityDemandError = { reason: string }; /** * Preferences of a ride. * @namespace RidePreferences * @property {boolean} subscribeToMessages Specifies if messages about the ride will be sent to the passenger. Default is false. */ export type RidePreferences = { subscribeToMessages: boolean };