-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add pickebike_basel proxy * simplify code
- Loading branch information
1 parent
d54cf1a
commit 71d6eee
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/converters/gbfs_pickebike_basel_change_pricing_plan_id.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ HTTP_TO_HTTPS_HOSTS: | |
- stables.donkey.bike | ||
- data.lime.bike | ||
- mds.bird.co | ||
- gbfs.prod.sharedmobility.ch |