Skip to content

Commit

Permalink
create field 'payment-terminal'
Browse files Browse the repository at this point in the history
'AVEC TPE' or 'TPE' is a french localization
  • Loading branch information
eskerda committed Jun 21, 2022
1 parent 5871e8b commit 7e38713
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion pybikes/gbfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def __init__(self, info):
self.extra['ebikes'] = int(info['num_ebikes_available'])

if 'rental_methods' in info:
self.extra['payment'] = list(map(unicode.lower, info['rental_methods']))
payment = list(map(unicode.lower, info['rental_methods']))
self.extra['payment'] = payment
self.extra['payment-terminal'] = 'creditcard' in payment


Gbfs.station_cls = GbfsStation
11 changes: 5 additions & 6 deletions pybikes/keolis.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, fields):
'slots': int(re.findall(u'Capacité : (\d+) vélos', text, re.UNICODE)[0]),
# All current stations (17) have a payment card reader
# See the data here: https://data.idelis.fr/explore/dataset/stations-velo-en-libre-service-idecycle/table/
'payment': 'AVEC_TPE'
'payment-terminal': True,
}
super(IDEcycleStation, self).__init__(name, latitude, longitude, bikes, free, extra)

Expand Down Expand Up @@ -83,10 +83,7 @@ def __init__(self, fields):
'address': fields['adresse'],
'last_update': fields['datemiseajour'],
'online': fields['etat'] == 'EN SERVICE',
# payment: AVEC TPE | SANS TPE
# as in, accepts bank cards or not
# convert it to AVEC_TPE | SANS_TPE as other keolis systems
'payment': fields['type'].replace(" ", "_"),
'payment-terminal': fields['type'] == 'AVEC TPE',
}
super(KeolisIleviaStation, self).__init__(name, latitude, longitude,
bikes, free, extra)
Expand Down Expand Up @@ -124,7 +121,9 @@ def __init__(self, fields):
'status': fields['etat'],
'uid': str(fields['idstation']),
'last_update': fields['lastupdate'],
'online': fields['etat'] == 'En fonctionnement'
'online': fields['etat'] == 'En fonctionnement',
# https://data.rennesmetropole.fr/explore/dataset/stations_vls/api/
'payment-terminal': True,
}
super(KeolisSTARStation, self).__init__(name, latitude, longitude,
bikes, free, extra)
Expand Down
2 changes: 2 additions & 0 deletions pybikes/velib.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def __init__(self, info):

# old 'banking' field
self.extra['banking'] = 'creditcard' in self.extra.get('payment', [])
# new payment-terminal field
self.extra['payment-terminal'] = self.extra['banking']

# electric bikes. So far I have not seen this field on other GBFS
# systems, so we must investigate. These according to specs go to a
Expand Down

3 comments on commit 7e38713

@Altonss
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eskerda Oh I just noticed you updated the card payment field, I guess projects using the API would need to update to the new syntax?

@eskerda
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing on the extra fields is assured to exist, so even though we sometimes do it, there's no reason to keep compatibility under it. That's the idea of having them under extra. I prefer if clients break because we removed a field that was wrong, than keeping it just because.

Another way to look at it:

  • idecycle pau is broken, so that does not count.
  • On keolis-STAR is a new field, so does not count either.
  • It's only breaking it for KeolisIlevia. So, if anyone is using that field, I am happy to re-add it if they add an issue here. But it seems like a very small error surface (1 network).

@Altonss
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idecycle pau is broken, so that does not count.

I will need to have a look at this one, thanks!

For the rest, we will just need to adapt to the new field, it easy :)

Please sign in to comment.