OceanNetworksCanada / api-python-client

Provides easy access to ONC data in Python
https://oceannetworkscanada.github.io/api-python-client/
Apache License 2.0
10 stars 9 forks source link

Add helper methods to combine getXXXByLocation and getXXXByDevice into getXXX #33

Closed kan-fu closed 4 months ago

kan-fu commented 6 months ago

We have several api endpoints (scalardata , rawdata, and archivefile) that support both byLocation and byDevice. The required format of the params are different.

Whether byLocation or byDevice is intended can be inferred from the the given params. Just like how the getSensorCategoryCodes is implemented.

def getSensorCategoryCodes(self, filters: dict):
        filters["returnOptions"] = "excludeScalarData"
        if "deviceCode" in filters:
            return self.getDirectByDevice(filters, False)["sensorData"]
        else:
            return self.getDirectByLocation(filters, False)["sensorData"]