Skip to content

Products

Accessed via sdk.products on an AspiaSpace instance.

Service wrapper for customer product endpoints.

Source code in src/aspiaspace/services/products.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class ProductsService:
    """
    Service wrapper for customer product endpoints.
    """

    def __init__(self, client):
        self._client = client

    def alt(self, uuid: str, date: str):
        """Retrieve alternative product data for a customer product.

        Args:
            uuid (str): aspia_uuid of polygon.
            date (str): date to query.

        Raises:
            ValueError: If date format is wrong.
            ValueError: If UUID is missing.

        Returns:
            ALT table (pandas.DataFrame): DataFrame of ALT results
        """
        if not uuid:
            raise ValueError("uuid is required")

        if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", date):
            raise ValueError("date must be in format 'yyyy-mm-dd'")

        logger.debug(
            "Fetching alternative customer product for uuid=%s",
            uuid,
        )


        headers = {}
        headers["Accept"] = "text/csv"

        response = self._client._request(
            "GET",
            f"/customer/product/alt/{uuid}",
            params={"date": date},
            headers=headers,
        )

        if not response or not response.strip():
            logger.error("No data on date")
            return None

        return read_csv(StringIO(response),sep=",")

alt(uuid, date)

Retrieve alternative product data for a customer product.

Parameters:

Name Type Description Default
uuid str

aspia_uuid of polygon.

required
date str

date to query.

required

Raises:

Type Description
ValueError

If date format is wrong.

ValueError

If UUID is missing.

Returns:

Type Description

ALT table (pandas.DataFrame): DataFrame of ALT results

Source code in src/aspiaspace/services/products.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def alt(self, uuid: str, date: str):
    """Retrieve alternative product data for a customer product.

    Args:
        uuid (str): aspia_uuid of polygon.
        date (str): date to query.

    Raises:
        ValueError: If date format is wrong.
        ValueError: If UUID is missing.

    Returns:
        ALT table (pandas.DataFrame): DataFrame of ALT results
    """
    if not uuid:
        raise ValueError("uuid is required")

    if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", date):
        raise ValueError("date must be in format 'yyyy-mm-dd'")

    logger.debug(
        "Fetching alternative customer product for uuid=%s",
        uuid,
    )


    headers = {}
    headers["Accept"] = "text/csv"

    response = self._client._request(
        "GET",
        f"/customer/product/alt/{uuid}",
        params={"date": date},
        headers=headers,
    )

    if not response or not response.strip():
        logger.error("No data on date")
        return None

    return read_csv(StringIO(response),sep=",")