Skip to content

Commit

Permalink
Bug fixes for Chevrolet inventory searches (#66)
Browse files Browse the repository at this point in the history
* Adding some Chevrolet inventory fields which it turns out are needed

* Adding logic to deal with Temporarily Unavailable vehicle inventory
  • Loading branch information
Ben-Chapman authored Nov 13, 2022
1 parent 24510ec commit 78d813f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
11 changes: 10 additions & 1 deletion api/src/blueprints/chevrolet.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ def get_chevrolet_inventory():
'values': [params['zip']],
'key': 'zipcode',
},
]
],
"sort": [
{
"field": "distance",
"order": "ASC"
}
],
"pageInfo": {
"rows": 1000
},
}

if validate_request(params.items()):
Expand Down
4 changes: 2 additions & 2 deletions api/src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def signal_handler(sig, frame):
sys.exit(0)

if __name__ == "__main__":
# os.environ["SSL_CERT_FILE"] = os.path.expanduser("~/.proxyman/proxyman-ca.pem")
# os.environ["REQUESTS_CA_BUNDLE"] = os.path.expanduser("~/.proxyman/proxyman-ca.pem")
os.environ["SSL_CERT_FILE"] = os.path.expanduser("~/.proxyman/proxyman-ca.pem")
os.environ["REQUESTS_CA_BUNDLE"] = os.path.expanduser("~/.proxyman/proxyman-ca.pem")

signal.signal(signal.SIGINT, signal_handler)

Expand Down
19 changes: 16 additions & 3 deletions app/src/manufacturers/chevrolet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { convertToCurrency, titleCase } from "../helpers/libs"
import { chevroletInventoryMapping, chevroletVinMapping } from "./chevroletMappings"

const apiBase = 'https://api.theevfinder.com'
// const apiBase = 'https://chevfix---api-rylxnyu4dq-uc.a.run.app/'
const apiBase = 'http://localhost:8081'

/**
* Fetches vehicle inventory from the manufacturer's API.
Expand Down Expand Up @@ -80,7 +81,19 @@ function formatChevroletInventoryResults(input) {
_vehicle[key] = enhancedResult[key]
}
})

// Some inventory is marked as "Temporarily Unavailable", which is exposed through
// a recall key, and not vehicleAvailabilityStatus. Dealing with that here
if (vehicle.recall) {
_vehicle['deliveryDate'] = vehicle.recall?.displayStatus
}

// Populate inventoryStatus which is exposed as the Availability filter
_vehicle['inventoryStatus'] = _vehicle['deliveryDate']

results.push(_vehicle)


})
return results
}
Expand Down Expand Up @@ -110,14 +123,14 @@ export async function getChevroletVinDetail(vin) {
'dealerName': vinData.data.dealer?.name,
'dealerPostalCode': vinData.data.dealer?.postalCode,
'totalVehiclePrice': convertToCurrency(
vinData.data.prices?.summary.find(item => item.type == 'total_vehicle_price').value.toString()
vinData.data.prices?.summary.find(item => item.type == 'total_vehicle_price').value.toString() ?? '0'
),
'trimName': vinData.data.trim?.name,
'extColorOptionCode': vinData.data.extColor?.optionCode,
'extColorDescription': vinData.data.extColor?.description,
'intColorOptionCode': vinData.data.intColor?.optionCode,
'intColorDescription': vinData.data.intColor?.description,
'epaElectricRange': vinData.data.keyFeatures.find(item => item.iconKey == 'icon-epa-electric-range').value.match(/\d+ miles/i)[0] ?? '',
'epaElectricRange': vinData.data.keyFeatures.find(item => item.iconKey == 'icon-epa-electric-range')?.value.match(/\d+ miles/i)[0] ?? 'Unavailable',
}

Object.keys(enhancedResult).forEach(vinKey => {
Expand Down

0 comments on commit 78d813f

Please sign in to comment.