Source code for maptekblastlogic.models.charge_plan_deck_model

from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar, cast

from attrs import define as _attrs_define

from ..types import UNSET, Unset

T = TypeVar("T", bound="ChargePlanDeckModel")


[docs] @_attrs_define class ChargePlanDeckModel: """Details of how a deck is planned to be loaded.""" product_id: int | Unset = UNSET """ The ID of the product to use in this deck. """ order: int | Unset = UNSET """ The order this deck sits in this hole. Decks are numbered from the bottom up, with the bottom deck having order '1'. """ length: float | Unset = UNSET """ The length of this deck measured along the length of the hole (Meters). """ mass: float | None | Unset = UNSET """ For products where the mass is known, the total mass of the deck (Kilograms). """ quantity: float | None | Unset = UNSET """ For packaged products, the number of packages or units used in this deck. """
[docs] def to_dict(self) -> dict[str, Any]: product_id = self.product_id order = self.order length = self.length mass: float | None | Unset if isinstance(self.mass, Unset): mass = UNSET else: mass = self.mass quantity: float | None | Unset if isinstance(self.quantity, Unset): quantity = UNSET else: quantity = self.quantity field_dict: dict[str, Any] = {} field_dict.update({}) if product_id is not UNSET: field_dict["productId"] = product_id if order is not UNSET: field_dict["order"] = order if length is not UNSET: field_dict["length"] = length if mass is not UNSET: field_dict["mass"] = mass if quantity is not UNSET: field_dict["quantity"] = quantity return field_dict
[docs] @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) product_id = d.pop("productId", UNSET) order = d.pop("order", UNSET) length = d.pop("length", UNSET) def _parse_mass(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) mass = _parse_mass(d.pop("mass", UNSET)) def _parse_quantity(data: object) -> float | None | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(float | None | Unset, data) quantity = _parse_quantity(d.pop("quantity", UNSET)) charge_plan_deck_model = cls( product_id=product_id, order=order, length=length, mass=mass, quantity=quantity, ) return charge_plan_deck_model