"""Store / OrgUnit operations for D365 CSU."""

from __future__ import annotations

from typing import Any

from d365_csu.client import CSUClient


def search_org_units(
    client: CSUClient,
    *,
    top: int = 50,
    skip: int = 0,
) -> Any:
    """Search for stores / org units."""
    body = {
        "OrgUnitSearchCriteria": {},
        **client.build_query_result_settings(top, skip),
    }
    return client.post("OrgUnits/Search", body)


def get_org_unit(client: CSUClient, org_unit_number: str) -> Any:
    """Get a specific org unit / store."""
    return client.get(f"OrgUnits({org_unit_number})")


def get_till_layout(client: CSUClient) -> Any:
    """Get the till / POS layout for the current org unit."""
    return client.post("OrgUnits/GetTillLayout", {})
