This repository contains the necessary code integrate OJP into the NOVA Preisauskunft.
- Check out the code
- Create a pycharm project from it
Necessary libraries are named in requirements.txt
$ python3 -m pip install -r requirements.txt
xsdata -p ojp -ss clusters path-to-ojp.xsd
The repository is missing the relevant configuration. The configuration is only handed out, when necessary. Contact [email protected], if necessary. However, the access is and will remain limited.
Relevant fields:
NOVA_URL_TOKEN = ""
NOVA_CLIENT_ID = ''
NOVA_CLIENT_SECRET = ''
NOVA_URL_API = ""
OJP_URL_API = "https://api.opentransportdata.swiss/ojp2020"
OJP_TOKEN = ''
run server.py starts a server on: http://127.0.0.1:8000
run test_client.py This will result in a TripRequest/TripDelivery to the OJP service.
see service
run network_flow.py The following should happen
- client: Builds an OJPTripRequest from "Bern" to "Zürich" with departure time now
- client: The OJPTripDelivery from OJP is obtained
- client: From the result an OJPFareRequest ist constructed
- client: the OJPFareRequest ist sent to the server
- server: Transforms the OJPFareRequest into a NOVA Preisauskunft requdst
- server: Process the result from NOVA, build an OJPFareDelivery and send it to the client
- client: Show the result
Everything is written to xml files for inspection
@startuml
() OJP - [tyk API manager]
[tyk API manager] - () OJP_int
node "The new service" {
[https proxy] - [OJPFare2Nova]
}
() OJP_int - [https proxy]
[OJPFare2Nova] - () OJPTrip
() OJPTrip - ["OJP Service (opentransportdata.swiss)"]
[OJPFare2Nova] -- () "Preisauskunft"
() "Preisauskunft" - [Nova service]
@enduml
@startuml
Client -> "tyk": OJPTripRequest
tyk -> "https proxy": OJPTripRequest
"https proxy" -> OJPFare2Nova: OJPTripRequest
OJPFare2Nova -> "OJP Service": OJPTripRequest
"OJP Service" --> OJPFare2Nova: OJPTripDelivery
OJPFare2Nova --> "https proxy": OJPTripDelivery
"https proxy" --> tyk: OJPTripDelivery
tyk --> Client: OJPTripDelivery
Client -> Client: "Wrap trips into OJPFare Request"
Client -> tyk: OJPFareRequest
tyk -> "https proxy": OJPFareRequest
"https proxy" -> OJPFare2Nova: OJPFareRequest
OJPFare2Nova -> OJPFare2Nova: MapOJP2Nova
OJPFare2Nova -> Nova: "Nova Preisauskunft"
Nova --> OJPFare2Nova : "Nova Preisauskunft"
OJPFare2Nova -> OJPFare2Nova: "MapNova2OJP"
OJPFare2Nova --> "https proxy": OJPFareDelivery
"https proxy" --> tyk: OJPFareDelivery
tyk --> Client: OJPFareDelivery
@enduml
- The TripResult used in the OJP fare service should not be based on short-term real-time information. So the TripRequest should usually contain a UseRealtime set to false.
The code is made available as MIT license. The generated code in the "nova" folder based on the WSDL is property of SBB (www.sbb.ch) and not part of the license.
If you need something about this project, just use the issue tracker: https://github.com/openTdataCH/ojp-nova/issues