Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support rest.exe endpoints #134

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft

support rest.exe endpoints #134

wants to merge 38 commits into from

Conversation

derhuerst
Copy link
Member

@derhuerst derhuerst commented Sep 16, 2019

rest.exe HAFAS endpoints have their own URL and require authentication via a token uniquely issued to each customer/user. While they follow the semantics of the mgate.exe endpoints, their responses have entirely different field names and sometimes different nesting levels.

Currently, the mgate.exe field names are hard-coded into the formatting/parsing code of hafas-client (it allows limited customization by overriding formatting/parse functions). We have several ways to support the rest.exe protocol:

nr approach complexity per client duplicated semantics-related code coordinating overarching work
1 write an entirely new client without sharing code little a lot harder to coordinate
2 abstract formatting & parsing layer, used by both clients in one repo more, becuase intermediate format almost none as before
3 add rest.exe-specific formatting & parsing functions, some of them re-using the mgate.exe a bit more a bit as before

With all three options, one should be able to conveniently specify in an endpoint profile what protocol the endpoint speaks. Also, I should be able to override specific formatting/parsing functions, just like I currently am with mgate.exe.


I prefer option 2, but it requires significant refactoring work, and I'd also like to merge #132 first, so that we don't accidentally break the mgate.exe code. @juliuste What do you think?

I went ahead with option 3 in this PR, because it was the most straightforward way to write it step by step. This doesn't mean that we have to keep it this way though! Because we try to avoid breaking changes in hafas-client, it seems appropriate to fully cover at least one rest.exe endpoint before we merge/publish the code.

still to do:

  • cover all features of the API
  • squash/clean the commits
  • unify parse and parse-rest? (see above)
  • find a way to write a profile for rest.exe
  • some bugfixes
  • unit tests, end-to-end tests (see also add unit tests #132)
  • documentation
  • adapt the "writing a profile" guide
  • rename $TOKEN to $HAFAS_TOKEN? (breaking change)

@juliuste
Copy link
Member

juliuste commented Feb 25, 2020

(Will rebase to current master and publish a new tag 5.1.1-rest.alpha)

parse-rest/journey-leg.js Outdated Show resolved Hide resolved
@marzieh-kazemi
Copy link

id is missing on the trip returned by .trip(id).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants