-
Notifications
You must be signed in to change notification settings - Fork 18
/
booking.yml
949 lines (809 loc) · 43 KB
/
booking.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
openapi: 3.0.0
servers:
- url: http://localhost:3000
description: Local server
info:
version: 1.1.0
title: WhimApp TSP API
## NB: All Markdown paragraphs need to be 2 empty lines and all Markdown links must be resolved against repo root (not against this file path)
## Also x-logo must be resolved against repo root (not against this file path)
## Examples (externalValue) and $ref are resolved relative to this file path
description: |
## Introduction
This is an API specification of REST endpoints that a Transport Service
Provider (TSP) should implement to offer their services through the
[Whim application](https://whimapp.com/).
It is written in machine-readable [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification) format,
so that API endpoints, validators, and test clients can be generated from the
documentation.
### Download
* OpenAPI Specification [JSON, single file document](./specs/booking.json)
* OpenAPI Specification [YAML](./specs/booking.yml)
## Terminology
* **endpoint** Publically resolvable URL either managed by MaaS Global (Whim Backend API) or by TSP (Booking API).
* **booking** Information about single leg during the customer trip, together with customer information and state.
* **journey** Multi-leg trip which user plans via WhimApp.
* **leg** Single trip which is performed by TSP. Booking created and contain the state of this trip.
* **TSP** Transport service provider. MaaS Global partner which offers their services via WhimApp.
* **route** One of the possible journey. To determine it, we call TSP booking options endpoint to get available offers.
* **micromobility** Light vehicles such as electric scooters, shared bicycles and electric bicycles.
* **WhimApp** Mobile application or similar, which is used by Whim User to perform journeys. Collectively we treat all communication from the point of WhimApp and user experience during the time the user interacts with the application.
* **Whim backend** Caller of TSP API endpoints. WhimApp never calls TSP endpoints directly. All invocations are done from cloud-native infrastructure managed by MaaS Global.
* **MaaS Global** MaaS Global is the world’s first true Mobility-as-a-Service (MaaS) operator with its award-winning Whim app, which provides users all city transport services in one app.
## Versions
### 1.0.0 Initial release (2018)
**deprecated**
* [OpenAPI Specification](specs/maas-v1.yml)
* [Documentation](?maas-v1.yml)
* [SwaggerUI](swagger-ui.html?urls.primaryName=maas-v1.yml)
* Source code [repository](https://github.com/maasglobal/maas-tsp-api/tree/v1.0)
### 1.1.0 Current version
From this version onwards, this documentation are living documentation for current and future versions. Any specific features not available in production are marked as **1.X.X-future**.
* [OpenAPI Specification](specs/booking.json)
* [Documentation](?booking.json)
* [JSON Schema documentation](https://maasglobal.github.io/maas-schemas)
* [SwaggerUI](swagger-ui.html?urls.primaryName=booking.yml)
* Source code [repository](https://github.com/maasglobal/maas-tsp-api/)
### 1.2.0 Future version
* Not yet available in production
* Marked by **v.1.2.0-future** in this documentation
## Getting started
### Running a local documentation server
To run local documentation server, follow the instructions in the [GitHub repo](https://github.com/maasglobal/maas-tsp-api/)
git clone https://github.com/maasglobal/maas-tsp-api/
cd maas-tsp-api
npm install
npm start
Open your browser and navigate to http://localhost:3000
> ⚠️ You can change a port by specifying `PORT` env variable
contact:
name: Maas Global Team
email: [email protected]
url: 'https://github.com/maasglobal/maas-tsp-api'
license:
name: MIT
url: 'https://opensource.org/licenses/MIT'
x-logo:
url: 'assets/whim-logo.svg'
altText: 'Whim logo'
href: 'https://whimapp.com'
tags:
- name: Booking lifecycle
description: |
The following scenario explains the life-cycle of an individual journey from a TSP viewpoint. Whenever a new concept (such as an actor or action is represented, it is imprinted in **bold**.
This scenario, with a few extra details, is shown in the sequence diagrams below. It should be noted from the picture that MaaS more often acts as a caller than a callee for Transport Service Provider.
### TAXI
Taxi or Private Hire Vehicle (PHV) booking sequence flow, both on-demand and prebooking.
![Taxi workflow](./specs/workflow/taxi-sequence.svg)
### Docked Bike
Free ride and docked bike sharing.
![Docked bike workflow](./specs/workflow/docked-bike-sequence.svg)
## Booking explained
Booking represents state about one leg of a journey, connected with TSP specific information and state.
Data model as specified by [JSON Schema](https://maasglobal.github.io/maas-schemas/core/booking.html) allows representing information about any type of transport and state. To better understand how the booking works, let's take a look at the basic states and essential parts of the booking data.
### State
Booking goes through multiple states during the journey; here are the most important states. Please see [Tracking booking](#section/Tracking-booking) on information on how WhimApp and TSP exchange this information.
| State | Description |
|-----|------|
| **RESERVED** | Booking created by calling [Create booking](#operation/bookingCreate) endpoint. |
| **CONFIRMED** | Booking confirmed, e.g. TAXI driver have accepted this order. We are waiting for this state update from TSP by periodically calling [Get booking](#operation/bookingGet) or waiting for webhook invocation via [Update booking state](#operation/backendBookingReceive) endpoint invocation. |
| **ARRIVED** | Not applicable for all modes of transportation. For TAXI means driver have arrived to the pickup point. We are waiting for this state update from TSP. |
| **ACTIVATED** | Booking has started. For TAXI means TAXI has picked up the passenger. We are waiting for this state update from some TSPs e.g. Taxi and will send this state update via [Update booking](#operation/bookingUpdate) call for car sharing and micromobility providers (to unlock car or a scooter and start a ride). |
| **ON_HOLD** | Booking still active but have been paused, for example for Car Sharing - lock the car but not finish the ride. We will send this state update via [Update booking](#operation/bookingUpdate) call. **v.1.2.0-future**: For docked bikes transition to this state reserves docking bay. |
| **EXPIRED** | Ride was completed. We are waiting for this state update from TSP. |
| **FINISHED** | Payment receipt reconcillation completed, for example for extra charges during Taxi ride, see [Get final booking receipt](#operation/bookingGetReceipt) endpoint. |
| **CANCELLED** | Cancelled by user. Booking can be subject to a fee or/and not be refundable as specified by TSP in booking cancellation rules. |
| **REJECTED** | Rejected by TSP. We can update with this state on **PENDING**, **RESERVED**, **CONFIRMED**, **ACTIVATED** state and show User message about the reason for rejection, as received from TSP. |
### Taxi state
Flow for taxi, both for on-call and prebooking PHV (private hire vehicles) are shown below.
![Taxi workflow](./specs/workflow/taxi.svg)
### Rental car state
Flow for rental car
![Rental car workflow](./specs/workflow/car-rental.svg)
### Shared car state
Flow for car-sharing
![Shared car workflow](./specs/workflow/car-sharing.svg)
### Bike state
State flow for bike, scooter and other micromobility are shown below.
![Bike workflow](./specs/workflow/bike.svg)
### Docked bike state
Docked bike state, when you need to reserve a dock before you can return a bike.
> ⚠️ ON_HOLD state for docked bikes only supported in version **v.1.2.0-future** which is not yet implemented.
![Docked bike workflow](./specs/workflow/docked-bike.svg)
### Structure
See examples for a [Create booking](#operation/bookingCreate) or schema for [Booking create](https://maasglobal.github.io/maas-schemas/#tspbooking-create) to understand all available data in a booking.
Here are the most essential parts of the booking data.
| State | Required? | Description |
|-----|------|------|
| `leg.from` | Y | Pickup point with name, address and coordinates (lat, long) |
| `leg.to` | N | Destination point with name, address and coordinates (lat, long) |
| `leg.startTime` | N | Start time of a trip, may be in future. |
| `leg.endTime` | N | End time of a trip, must be in future. |
| `leg.mode` | Y | Requested mode of transportation, i.e. TAXI |
| `customer` | Y | Customer information |
| `state` | Y | State of the booking |
| `meta` | Y | Information about TSP. Also contains driver for TAXI |
| `tspId` | Y | TSP specifid ID for this booking |
| `cost` | Y | Amount and currency this booking cost |
## Planning a route
**User** **queries** for a **Route** with an address or latitude-longitude pair from one place to another. WhimApp queries the route from a third party **Routing Engine** that contains the data for **TSP** routes. At this point, WhimApp makes no queries to the TSP - it expects the Routing Engine contains valid GTFS data for the TSP.
> ⚠️ Routing and GTFS are used only if applicable for TSP provider. For example, for micromobility providers, we don't use GTFS and route planning.
**WhimApp** shows several possible **Plans**, each containing a valid **Route** with several **Legs** with a part of a route using a specific TSP.
## Booking options
To determine available mobility services, WhimApp calls [Available options](#operation/bookingOptionsGet) endpoint. Depending on the TSP mode of transportation, this endpoint returns available TAXIs or cars or bikes for the specified location. After User selection, one of the options is used to create a booking by calling [Create Booking](#operation/bookingCreate) endpoint.
| Related API | Related schemas | Examples |
| --------- | --------- | ------ |
| [Available taxi types](#operation/bookingOptionsGet) | [tsp/booking-options-list](https://maasglobal.github.io/maas-schemas/#tspbooking-options-list) | TAXI - [response](examples/taxi/booking-options-response.json) |
| [Available scooters](#operation/bookingOptionsGet) | [tsp/booking-options-list](https://maasglobal.github.io/maas-schemas/#tspbooking-options-list) | SCOOTER - [response](examples/scooter/booking-options-response.json) |
| [Available cars](#operation/bookingOptionsGet) | [tsp/booking-options-list](https://maasglobal.github.io/maas-schemas/#tspbooking-options-list) | CAR SHARING - [response](examples/car/booking-options-response.json) |
| [Available bikes](#operation/bookingOptionsGet) | [tsp/booking-options-list](https://maasglobal.github.io/maas-schemas/#tspbooking-options-list) | DOCKED BIKE - [response](examples/bike/booking-options-response.json) |
| [Available stations](#operation/stationsGet) | [tsp/stations-list](https://maasglobal.github.io/maas-schemas/#tspstations-list) | DOCKED BIKE - [response](examples/bike/stations-list-response.json) |
| [Retrieve station](#operation/stationGet) | [tsp/stations-retrieve](https://maasglobal.github.io/maas-schemas/#tspstations-retrieve) | DOCKED BIKE - [response](examples/bike/stations-retrieve-response.json) |
## Creating a booking
The User browses through the plans and chooses to book a journey. For each Leg in the Plan Route, WhimApp creates a new booking by invoking the corresponding endpoint in TSP.
It should be noted that the booking may be hours or days in advance - a bit like in booking a hotel. The booking contains the individual leg as the detailed travel plan for the TSP, as well as customer contact information.
> ⚠️ Specific parts of customer information (E-mail, Phone, Last name, First name, etc.) which are sent to the TSP are subject to agreement between MaaS Global and TSP.
TSP receives the booking and confirms the trip. TSP may modify the details
of the booking, such as moving the **start location** to closest known
street address or delaying the Leg **start time**, as long as the
**end time** can be guaranteed. The booking is supplemented with
**booked** state information and additional **terms** such as
the latest **cancellation rules**.
WhimApp checks that the creation of booking succeeded and stores the booking for future reference.
> ⚠️ User can also book a trip directly for the TAXI, car or micromobility transport (which will result in a journey with one leg)
| Related API | Related schemas | Examples |
| --------- | --------- | ------ |
| [Create booking](#operation/bookingCreate) | [tsp/booking-create](https://maasglobal.github.io/maas-schemas/#tspbooking-create) | TAXI - [request](examples/taxi/booking-create-request.json), [response](examples/taxi/booking-create-response.json) |
| [Create booking](#operation/bookingCreate) | [tsp/booking-create](https://maasglobal.github.io/maas-schemas/#tspbooking-create) | SCOOTER - [request](examples/scooter/booking-create-request.json), [response](examples/scooter/booking-create-response.json) |
| [Create booking](#operation/bookingCreate) | [tsp/booking-create](https://maasglobal.github.io/maas-schemas/#tspbooking-create) | CAR SHARING - [request](examples/car/booking-create-request.json), [response](examples/car/booking-create-response.json) |
| [Create booking](#operation/bookingCreate) | [tsp/booking-create](https://maasglobal.github.io/maas-schemas/#tspbooking-create) | **v.1.2.0-future**: DOCKED BIKE - [response](examples/bike/booking-create-response.json) |
## Paying a booking
When booking created, it is already paid according to the options received and selected by User. See [Booking options](#section/Booking+options) for more information.
If the booking can not be created, the paid amount will be refunded to the User.
## Navigating a route
The User starts to navigate the Route. WhimApp tracks for the user location to know if there are any changes needed in the plan. WhimApp triggers the changes for bookings by monitoring the individual legs.
WhimApp monitors the booking terms and Leg **start time**. When the actual Leg starts, WhimApp **starts** the Leg and notifies the TSP. User or TSP may request changes to the booking, e.g., in a case of a delay or cancellation.
Each of these scenarios is described below.
## Updating a booking
A booking may be updated by a User or WhimApp when any party receives new information that the Leg needs to be changed. For example, when the User wants to change a destination. Such change may be subject to a fee, which should be reflected in response to update or when new booking retrieved via [Get booking](#operation/bookingGet) endpoint.
Also we update the booking when state for the booking changes, for example to start a ride on a scooter or shared car.
| Related API | Related schemas | Examples |
| --------- | --------- | ------ |
| [Update booking](#operation/bookingUpdate) | [tsp/booking-update](https://maasglobal.github.io/maas-schemas/#tspbooking-update) | SCOOTER, finish a ride - [request](examples/scooter/booking-update-expired-request.json), [response](examples/scooter/booking-update-expired-response.json) |
| [Update booking](#operation/bookingUpdate) | [tsp/booking-update](https://maasglobal.github.io/maas-schemas/#tspbooking-update) | CAR SHARING, lock - [request](examples/car/booking-update-request-lock.json), [response](examples/car/booking-update-response-lock.json)|
| [Update booking](#operation/bookingUpdate) | [tsp/booking-update](https://maasglobal.github.io/maas-schemas/#tspbooking-update) | CAR SHARING, unlock - [request](examples/car/booking-update-request-unlock.json) |
| [Update booking](#operation/bookingUpdate) | [tsp/booking-update](https://maasglobal.github.io/maas-schemas/#tspbooking-update) | **v.1.2.0-future**: DOCKED BIKE, reserve dock - [request](examples/bike/booking-update-request-reserve-dock.json), [response](examples/bike/booking-update-response-reserve-dock.json) |
## Cancelling a booking
A booking may be canceled by User or WhimApp as specified by **cancellation rules** in **terms** of the booking. WhimApp invokes a [Cancel booking](#operation/bookingCancel) endpoint. TSP confirms and updates its own systems. If TSP can not cancel booking, it returns a 403 Forbidden error.
It should be noted that cancellation is an exceptional case and is likely happen only when the user chooses to cancel the whole route Plan.
| Related API | Related schemas | Examples |
| --------- | --------- | ------ |
| [Cancel booking](#operation/bookingCancel) | [tsp/booking-cancel](https://maasglobal.github.io/maas-schemas/#tspbooking-cancel ) | CAR SHARING - [response](examples/car/booking-cancel-response.json) |
## Tracking a booking
To provide a smooth user experience, it is very important to keep the booking state updated on the WhimApp side. To do this, we can use two approaches:
* We periodically check booking state, by calling [Get booking](#operation/bookingGet) endpoint
* TSP sends us latest update, by calling Whim Backend endpoint [Update booking state](#operation/backendBookingReceive)
While the latter is preferred way, MVP implementation can be created by only providing **required** [Get booking](#operation/bookingGet) endpoint.
| Related API | Related schemas | Examples |
| --------- | --------- | ------ |
| [Get booking](#operation/bookingGet) | [tsp/booking-read-by-id](https://maasglobal.github.io/maas-schemas/#tspbooking-read-by-id) | TAXI - [RESERVED](examples/taxi/booking-read-by-id-response.json), [ACTIVATED](examples/taxi/booking-read-by-id-response-activated.json) |
| [Get booking](#operation/bookingGet) | [tsp/booking-read-by-id](https://maasglobal.github.io/maas-schemas/#tspbooking-read-by-id) | SCOOTER - [ACTIVATED](examples/scooter/booking-read-by-id-response-activated.json) |
| [Update booking state](#operation/backendBookingReceive) | [tsp/booking-read-by-id](https://maasglobal.github.io/maas-schemas/#tspbooking-read-by-id) | See [above](#section/Updating-a-booking) |
| [Get receipt](#operation/bookingGetReceipt) | [tsp/booking-receipt](https://maasglobal.github.io/maas-schemas/#tspbooking-receipt) | SCOOTER - [response](examples/scooter/booking-receipt-response.json) |
## Error Cases
It may be possible that WhimApp sends an invalid request, or the TSP cannot fulfill a request. In any such case, TSP may respond with an error. If TSP responds with an error, WhimApp assumes the state was not changed (e.g., a transaction was rolled back). WhimApp may repeat the request with the same or different data later on.
The same principle applies when TSP is communicating with WhimApp.
The error response body are defined as JSON in [JSON Schema](https://maasglobal.github.io/maas-schemas/core/error.html#code) and can contain additional fields, e.g.
```json
{
code: "BOOKING_ALREADY_EXISTS",
message: "Active booking already exists for this user.",
bookingId: "deadbeefdeadbeefdeadcafe0000"
}
```
x-traitTag: true
- name: Booking
description: |
Booking related APIs are the core of a TSP implementation.
Correspondingly, a booking is the main object exchanged between WhimApp and a
TSP. For more information about booking, see [Booking explained](#section/Booking-explained)
x-traitTag: false
x-displayName: Booking API
- name: Stations
description: |
Stations available for public transport and micromobility docking.
x-traitTag: false
x-displayName: Stations API
- name: WebHook
description: |
Publically available API which you can call to send booking state changes immediately when they happen, without the need to for us to poll our system by calling [Get booking](#operation/bookingGet) multiple times.
These endpoints are treated as Webhooks, which TSP **may** call to make communication faster and booking process smoother.
> ⚠️ The specific endpoint URL to be invoked are subject to agreement between TSP and MaaS Global.
x-traitTag: false
x-displayName: Whim Backend API
- name: Support
description: |
We would like to help you with code and other questions you might have.
Search our documentation, contact our [tech team](mailto:[email protected]), or connect with our [sales team](https://whimapp.com/partners/).
### Improving documentation
It would be great if you have anything to contribute to our documentation, you can do it by creating a fork and issuing a pull-request.
Or you can file an [issue](https://github.com/maasglobal/maas-tsp-api/issues) if you discover some problem or invalid information.
You also can reach the team via [email protected]
x-traitTag: true
x-displayName: Support
components:
securitySchemes:
apiKeyHeader:
in: header
name: X-API-Key
type: apiKey
description: |
Authorization scheme to use with TSP API should be based on specifying `X-API-Key` header when WhimApp makes a request to the TSP API.
*Please note* what due to serverless nature of our infrastructure we are unable to provide you with a set of IP addresses HTTP request will be originating from.
security:
- apiKeyHeader: []
paths:
/bookings/options:
get:
operationId: bookingOptionsGet
summary: Available options
description: |
Returns available options or offers.
The options are used to construct a booking to be created after the User selects it by calling [Create booking](#operation/bookingCreate).
Full schema for parameters defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/booking-options-list/request.html) project
tags:
- Booking
parameters:
- name: from
description: "User's location in comma separated form e.g. 60.123,27.456"
in: query
required: true
schema:
$ref: ../schemas/core/components/units-geo.json#/definitions/shortLocationString
- name: to
description: 'A desired destination e.g. 60.123,27.456'
in: query
required: false
schema:
$ref: ../schemas/core/components/units-geo.json#/definitions/shortLocationString
- name: startTime
description: 'Start journey time'
in: query
required: true
schema:
$ref: ../schemas/core/components/units.json#/definitions/time
- name: endTime
description: 'End journey time'
in: query
required: false
schema:
$ref: ../schemas/core/components/units.json#/definitions/time
- name: mode
description: 'Transfer mode'
in: query
required: false
schema:
$ref: ../schemas/core/components/travel-mode.json
x-code-samples:
- lang: Shell
label: Query for taxi
source: |
curl --location --request GET 'http://localhost:3000/bookings/options? \
customer[clientId]=whim&customer[locale]=en& \
customer[opaqueId]=deadbeef-deadbeef& \
customer[phone]=+35840000000& \
distance=9734&endTime=1572347575000& \
from=60.1769789,24.9504135& \
fromAddress=streetName:Siltasaarenkatu|streetNumber:1|city:Helsinki|zipCode:00530|country:Suomi&fromName=Siltasaarenkatu%201%20Helsinki& \
mode=TAXI& \
startTime=1572347575000& \
tspProductIds=testtaxi1-product1& \
to=60.23044350000001,24.8990183& \
toAddress=streetName:Ida%20Aalbergin%20tie|streetNumber:3|city:Helsinki|zipCode:00400|country:Suomi& \
toName=Ida%20Aalbergin%20tie%203%20Helsinki' \
--header "x-api-key: pieY8Oezeicioyei5eisheeb7sheeLie"
- lang: Shell
label: Query for scooter
source: |
curl --location --request GET 'http://localhost:3000/bookings/options? \
customer[clientId]=whim&customer[locale]=en& \
customer[opaqueId]=deadbeef-deadbeef& \
customer[phone]=+358400001010& \
customer[firstName]=Tester& \
customer[lastName]=Test& \
endTime=1577969729830& \
from=60.1769789,24.9504135& \
fromRadius=400& \
mode=SCOOTER& \
tspProductIds=scooterinc1& \
startTime=1577966129830& \
to=60.1769789,24.9504135&' \
--header "x-api-key: pieY8Oezeicioyei5eisheeb7sheeLie"
- lang: Shell
label: Query for car sharing
source: |
curl --location --request GET 'http://localhost:3000/bookings/options? \
customer[clientId]=whim&customer[locale]=en& \
customer[opaqueId]=deadbeef-deadbeef& \
customer[phone]=+358400001010& \
customer[firstName]=Tester& \
customer[lastName]=Test& \
endTime=1577969729830& \
from=60.1769789,24.9504135& \
fromRadius=20000& \
mode=CAR& \
tspProductIds=carsharingabc1& \
startTime=1577966129830& \
to=60.1769789,24.9504135&' \
--header "x-api-key: pieY8Oezeicioyei5eisheeb7sheeLie"
responses:
'200':
x-summary: Array of options
description: |
Available transport options matching the given query parameters. If no transport options are available; an empty array is returned.
### JSON Schema documentation
Full schema for response defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/booking-options-list/response.html) project
content:
application/json:
schema:
$ref: ../schemas/tsp/booking-options-list/response.json
examples:
Taxi:
summary: Taxi
externalValue: '../examples/taxi/booking-options-response.json'
Scooter:
summary: Scooter
externalValue: '../examples/scooter/booking-options-response.json'
CarSharing:
summary: Car sharing
externalValue: '../examples/car/booking-options-response.json'
/bookings:
post:
operationId: bookingCreate
summary: Create booking
description: |
Creates a new booking for the TSP in **RESERVED** state.
The returned object will be a reference that is passed back & forth throughout the booking lifecycle.
Booking request are based upon the response returned by calling [Available options](#operation/bookingOptionsGet) endpoint.
The booking may be modified in the response, e.g., the location can be adjusted for a more suitable pick-up location.
In addition, the service may contain a **meta** attribute for arbitrary TSP metadata that the TSP needs later, and **token** attribute depicting how long the current state is valid.
### JSON Schema documentation
Full schema for request defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/booking-create/request.html) project
tags:
- Booking
requestBody:
content:
application/json:
schema:
$ref: ../schemas/tsp/booking-create/request.json
examples:
Taxi:
summary: Taxi
externalValue: ../examples/taxi/booking-create-request.json
Scooter:
summary: Scooter
externalValue: ../examples/scooter/booking-create-request.json
CarSharing:
summary: Car sharing
externalValue: ../examples/car/booking-create-request.json
description: |
Parameters of booking to be created, optionally referencing
offerId returned on the `/bookings/options` call.
required: true
responses:
'200':
x-summary: Booking
description: |
Booking information. For more information about the booking, see [Booking explained](#section/Booking-explained).
### JSON Schema documentation
Full schema for response defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/booking-create/response.html) project
content:
application/json:
schema:
$ref: ../schemas/tsp/booking-create/response.json
examples:
Taxi:
summary: Taxi
externalValue: ../examples/taxi/booking-create-response.json
Scooter:
summary: Scooter
externalValue: ../examples/scooter/booking-create-response.json
CarSharing:
summary: Car sharing
externalValue: ../examples/car/booking-create-response.json
'400':
description: Bad request
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'401':
description: Authorization error (invalid API key)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'409':
description: |
Another Booking exists for this User.
If TSP does not support more than one booking per user, it can indicate it by sending this response when
WhimApp creates a new booking. Booking ID can be specified as an extra property in a response. See [Error Cases](#section/Error-Cases) for more information.
content:
application/json:
schema:
$ref: ../schemas/core/error.json
default:
description: unexpected error
content:
application/json:
schema:
$ref: ../schemas/core/error.json
/bookings/{tspId}:
get:
operationId: bookingGet
summary: Get booking
description: |
Returns the booking that has been created earlier.
### JSON Schema documentation
Full schema for response defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/booking-read-by-id/response.html) project
tags:
- Booking
parameters:
- name: tspId
description: ID of the booking created earlier
in: path
required: true
schema:
$ref: ../schemas/core/booking.json#/definitions/tspId
responses:
'200':
description: The booking matching the query
content:
application/json:
schema:
$ref: ../schemas/tsp/booking-read-by-id/response.json
examples:
Taxi1:
summary: Taxi - RESERVED
externalValue: '../examples/taxi/booking-read-by-id-response.json'
Taxi2:
summary: Taxi - ACTIVATED
externalValue: '../examples/taxi/booking-read-by-id-response-activated.json'
Scooter:
summary: Scooter - ACTIVATED
externalValue: '../examples/scooter/booking-read-by-id-response-activated.json'
'400':
description: Bad request (invalid query parameters)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'401':
description: Authorization error (invalid API key)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
default:
description: unexpected error
content:
application/json:
schema:
$ref: ../schemas/core/error.json
patch:
operationId: bookingUpdate
summary: Update booking
description: |
Update booking, changing state, or changing booking details.
### JSON Schema documentation
Full schema for request defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/booking-update/request.html) project
tags:
- Booking
parameters:
- name: tspId
description: ID of the booking created earlier
in: path
required: true
schema:
$ref: ../schemas/core/booking.json#/definitions/tspId
requestBody:
content:
application/json:
schema:
$ref: ../schemas/tsp/booking-update/request.json
examples:
carSharingLock:
summary: Lock a car
externalValue: ../examples/car/booking-update-request-lock.json
carSharingUnlock:
summary: Unlock a car
externalValue: ../examples/car/booking-update-request-unlock.json
scooterReturn:
summary: Return scooter
externalValue: ../examples/scooter/booking-update-expired-request.json
responses:
'200':
description: Updated, old booking returned
content:
application/json:
schema:
$ref: ../schemas/tsp/booking-update/response.json
examples:
CarSharing:
summary: Car sharing response lock
externalValue: '../examples/car/booking-update-response-lock.json'
'204':
description: Updated, no content returned
'400':
description: Bad request
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'401':
description: Authorization error (invalid API key)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
default:
description: unexpected error
content:
application/json:
schema:
$ref: ../schemas/core/error.json
delete:
operationId: bookingCancel
summary: Cancel booking
description: |
Cancel booking if it is possible.
Cancel can be subject to a fee, as returned by 200 OK response to this method.
tags:
- Booking
parameters:
- name: tspId
description: ID of the booking created earlier
in: path
required: true
schema:
$ref: ../schemas/core/booking.json#/definitions/tspId
responses:
'200':
description: Deleted, old booking returned
content:
application/json:
schema:
$ref: ../schemas/tsp/booking-cancel/response.json
examples:
CarSharing:
summary: Car sharing cancel
externalValue: '../examples/car/booking-cancel-response.json'
'204':
description: Deleted, no content returned
'400':
description: Bad request
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'401':
description: Authorization error (invalid API key)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'403':
description: Cancellation forbidden
content:
application/json:
schema:
$ref: ../schemas/core/error.json
default:
description: unexpected error
content:
application/json:
schema:
$ref: ../schemas/core/error.json
/bookings/{tspId}/receipt:
get:
operationId: bookingGetReceipt
summary: Get final booking receipt
description: |
Get finalized pricing and receipt for the booking.
### JSON Schema documentation
Full schema for response defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/booking-receipt/response.html) project
tags:
- Booking
parameters:
- name: tspId
description: ID of the booking created earlier
in: path
required: true
schema:
$ref: ../schemas/core/booking.json#/definitions/tspId
responses:
'200':
description: The bookings matching the query with final receipt
content:
application/json:
schema:
$ref: ../schemas/core/booking.json
examples:
Scooter:
summary: Scooter
externalValue: '../examples/scooter/booking-receipt-response.json'
'400':
description: Bad request (invalid query parameters)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'401':
description: Authorization error (invalid API key)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'404':
description: Receipt not ready
content:
application/json:
schema:
$ref: ../schemas/core/error.json
default:
description: unexpected error
content:
application/json:
schema:
$ref: ../schemas/core/error.json
/stations:
get:
operationId: stationsGet
summary: Get stations
description: |
Returns the list of stations
### JSON Schema documentation
Full schema for response defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/stations-list/response.html) project
tags:
- Stations
parameters:
- name: location
description: Starting point
in: query
required: true
schema:
$ref: ../schemas/core/components/units-geo.json#/definitions/shortLocationString
- name: radius
description: Radius to look for stations in, if not specified return all stations.
in: query
required: false
schema:
$ref: ../schemas/core/components/units-geo.json#/definitions/distance
- name: type
description: Type of points to return
in: query
required: false
schema:
type: string
responses:
'200':
description: The stations matching the query
content:
application/json:
schema:
$ref: ../schemas/tsp/stations-list/response.json
examples:
Bikes1:
summary: Docked bike stations
externalValue: '../examples/bike/stations-list-response.json'
'400':
description: Bad request (invalid query parameters)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'401':
description: Authorization error (invalid API key)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
default:
description: unexpected error
content:
application/json:
schema:
$ref: ../schemas/core/error.json
/stations/{id}:
get:
operationId: stationGet
summary: Get station
description: |
Returns the information about the specific station
### JSON Schema documentation
Full schema for response defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/stations-retrieve/response.html) project
tags:
- Stations
parameters:
- name: id
description: ID of the station
in: path
required: true
schema:
$ref: ../schemas/core/components/station.json#/definitions/id
- name: agencyId
description: TSP provider id which this station belongs to
in: query
required: true
schema:
$ref: ../schemas/core/components/common.json#/definitions/agencyId
responses:
'200':
description: Information about a single station
content:
application/json:
schema:
$ref: ../schemas/tsp/stations-retrieve/response.json
examples:
Bikes1:
summary: Docked bike stations
externalValue: '../examples/bike/stations-retrieve-response.json'
'400':
description: Bad request (invalid query parameters)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
'401':
description: Authorization error (invalid API key)
content:
application/json:
schema:
$ref: ../schemas/core/error.json
default:
description: unexpected error
content:
application/json:
schema:
$ref: ../schemas/core/error.json
/backend/booking/{tspId}:
patch:
operationId: backendBookingReceive
summary: Receive updated booking state
description: |
Updates booking information at the WhimApp backend.
It is called by the TSP whenever the state of the booking are updated.
### JSON Schema documentation
Full schema for payload defined in [maas-schemas](https://maasglobal.github.io/maas-schemas/tsp/webhooks-bookings-update/remote-request.html) project
parameters:
- name: tspId
description: ID of the booking created earlier
in: path
required: true
schema:
$ref: ../schemas/core/booking.json#/definitions/tspId
tags:
- WebHook
requestBody:
content:
application/json:
schema:
$ref: ../schemas/tsp/webhooks-bookings-update/remote-request.json
examples:
Taxi:
summary: Taxi
externalValue: '../examples/taxi/webhook-booking-update-status.json'
description: |
Booking information with updated state.
required: true
responses:
'204':
x-summary: Acknowledged
description: |
Received, no state.
'400':
description: Bad request (data failed validation)
content:
application/json:
schema:
$ref: ../schemas/core/error.json