Skip to content

Commit

Permalink
add pickebike_basel proxy (#131)
Browse files Browse the repository at this point in the history
* add pickebike_basel proxy

* simplify code
  • Loading branch information
ThorstenFroehlinghaus authored Nov 6, 2024
1 parent d54cf1a commit 71d6eee
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

The changelog lists relevant feature changes between each release. Search GitHub issues and pull requests for smaller issues.

## [unreleased]
- add converter for `gbfs.prod.sharedmobility.ch/v2/gbfs/pickebike_basel` feed: set valid pricing_plan_id

## 2024-09-17
- add converter for `apis.deutschebahn.com` feeds: remove capacity attribute
- change converter for `gbfs.nextbike.net` feeds: set `propulsion_type=human` if not defined
Expand Down
27 changes: 27 additions & 0 deletions app/converters/gbfs_pickebike_basel_change_pricing_plan_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from typing import List, Union

from app.base_converter import BaseConverter


class GbfsPickebikeBaselChangePricingPlanIdConverter(BaseConverter):
hostnames = ['gbfs.prod.sharedmobility.ch']

def convert(self, data: Union[dict, list], path: str) -> Union[dict, list]:
if not isinstance(data, dict):
return data
if not path.startswith('/v2/gbfs/pickebike_basel'):
return data

if '/free_bike_status' in path:
fields = data.get('data', {})
if not isinstance(fields, dict):
return data
vehicles = fields.get('bikes', [])
if not isinstance(vehicles, list):
return data
for vehicle in vehicles:
if vehicle.get('pricing_plan_id') == 'default_':
vehicle['pricing_plan_id'] = 'default_' + vehicle.get('vehicle_type_id', '')
return data

return data
1 change: 1 addition & 0 deletions config_dist_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ HTTP_TO_HTTPS_HOSTS:
- stables.donkey.bike
- data.lime.bike
- mds.bird.co
- gbfs.prod.sharedmobility.ch

0 comments on commit 71d6eee

Please sign in to comment.