Dimensions

Creating a Dimension

This shows how to create a new dimension (e.g., a department).

1# main.py
2
3dimension_name = f"SDK Department {time_now}"
4dimension_unique_key = f"dept-sdk-{time_now}"
5
6new_dimension = client.dimensions.post_dimensions_root(
7 ottimate_company_id=ottimate_company_id,
8 type="DEPARTMENT",
9 code="MKT",
10 dimension_type_code="DEPARTMENT",
11 name=dimension_name,
12 unique_key=dimension_unique_key,
13)
14ottimate_dimension_id = new_dimension.dimension.get("id")

Fetching Dimensions

You can fetch all dimensions for a company, or filter by type.

Fetching all dimensions:

1# Fetch all the dimensions
2dimensions = client.dimensions.get_dimensions_root(ottimate_company_id=ottimate_company_id)
3print(f"✅ Fetched {len(dimensions.dimensions)} dimensions for the company.")
4for dimension in dimensions.dimensions:
5 print(f" - Dimension: {dimension.name} | Ottimate Dimension ID : {dimension.id} | Type: {dimension.dimension_type} | ERP ID: {dimension.erp_dimension_id}")

Fetching dimensions of a specific type:

1# Fetch dimensions of type DEPARTMENT
2dimensions = client.dimensions.get_dimensions_root(ottimate_company_id=ottimate_company_id, type="DEPARTMENT")
3for dimension in dimensions.dimensions:
4 print(f" - Dimension: {dimension.name} | Ottimate Dimension ID : {dimension.id} | Type: {dimension.type} | ERP ID: {dimension.erp_dimension_id}")

Fetching a single dimension by ID:

1# Fetch a single dimension by ID
2dimension = client.dimensions.get_dimensions_id(id="<ottimate_dimension_id>").dimension
3print(f" - Dimension: {dimension.name} | Ottimate Dimension ID : {dimension.id}| Type: {dimension.type} | ERP ID: {dimension.erp_dimension_id}")