heyitsmass / BayView

The next generation reservation tracking and notification system
https://bayview.dev
MIT License
1 stars 2 forks source link

API Interface (bAyPI) #36

Closed heyitsmass closed 1 year ago

heyitsmass commented 1 year ago

An excessive amount of data is provided from disney API routes. An interface API that simplifies the endpoints down to just the items we need and provides us alternative query methods for accessing necessary data. Including an interface API also allows server side data caching of non essential data for faster query times.

For example:

https://endpoint.com/passes/blockout-dates/api/get-availability/?product-types={productTypes}&destinationId=WDW&numMonths={numMonths}

can be broken down into simply /blackout-dates/<facility>?passes=<passId>

Our route now provides a facility discriminator and can filter passes by facility and return only that information.

heyitsmass commented 1 year ago

Passes route

@app.route("/passes", methods=["GET"])
def get_passes():

    res = session.get(dataUrl)

    if not res.status_code == 200:
        return res.json(), res.status_code

    data = res.json()
    passIds = []
    passes = {}

    for _pass in data["supported-passes"]:
        supportedPass = SupportedPass(**_pass)
        passIds.append(supportedPass.passId)
        passes[supportedPass.passId] = supportedPass._asdict()

    return {"passIds": passIds, "passes": passes}, 200

typedef:

    interface SupportedPass {
        availNumMonths?: number
        displayName: string
        displayOrder: number
        icon: string
        iconEndColor: string
        iconStartColor: string
        isSupported: bool
        passId: string
        configInstanceId: string
    }

    type Response = { 
        passIds: string[]
        passes: SupportedPass[]
    }