# This file was generated by liblab | https://liblab.com/

from __future__ import annotations
from typing import List
from .utils.json_map import JsonMap
from .base import BaseModel
from .identifier_value import IdentifierValue, IdentifierValueGuard
from .timesheet_status_enum import TimesheetStatusEnum
from .file_attachment_info import FileAttachmentInfo
from .timesheet_approver import TimesheetApprover
from .contract_type_enum import ContractTypeEnum


@JsonMap({})
class TimesheetWorksheet(BaseModel):
    """TimesheetWorksheet

    :param weeks: weeks
    :type weeks: float
    :param days: days
    :type days: float
    :param hours: hours
    :type hours: float
    :param minutes: minutes
    :type minutes: float
    """

    def __init__(self, weeks: float, days: float, hours: float, minutes: float):
        self.weeks = weeks
        self.days = days
        self.hours = hours
        self.minutes = minutes


@JsonMap({"id_": "id"})
class TimesheetReviewedBy(BaseModel):
    """TimesheetReviewedBy

    :param id_: id_
    :type id_: IdentifierValue
    :param full_name: full_name
    :type full_name: str
    :param reviewed_at: reviewed_at
    :type reviewed_at: str
    :param remarks: remarks
    :type remarks: str
    """

    def __init__(
        self, id_: IdentifierValue, full_name: str, reviewed_at: str, remarks: str
    ):
        self.id_ = IdentifierValueGuard.return_one_of(id_)
        self.full_name = full_name
        self.reviewed_at = reviewed_at
        self.remarks = remarks


@JsonMap({"id_": "id", "type_": "type"})
class TimesheetContract(BaseModel):
    """TimesheetContract

    :param id_: id_
    :type id_: str
    :param title: title
    :type title: str
    :param type_: Type of a contract
    :type type_: ContractTypeEnum
    """

    def __init__(self, id_: str, title: str, type_: ContractTypeEnum):
        self.id_ = id_
        self.title = title
        self.type_ = self._enum_matching(type_, ContractTypeEnum.list(), "type_")


@JsonMap({})
class TimesheetPaymentCycle(BaseModel):
    """TimesheetPaymentCycle

    :param start_date: Long date-time format following ISO-8601, defaults to None
    :type start_date: str, optional
    :param end_date: Long date-time format following ISO-8601, defaults to None
    :type end_date: str, optional
    """

    def __init__(self, start_date: str = None, end_date: str = None):
        if start_date is not None:
            self.start_date = start_date
        if end_date is not None:
            self.end_date = end_date


@JsonMap({"id_": "id"})
class TimesheetReportedBy(BaseModel):
    """TimesheetReportedBy

    :param id_: id_
    :type id_: IdentifierValue
    :param full_name: full_name
    :type full_name: str
    """

    def __init__(self, id_: IdentifierValue, full_name: str):
        self.id_ = IdentifierValueGuard.return_one_of(id_)
        self.full_name = full_name


@JsonMap({"id_": "id", "type_": "type"})
class Timesheet(BaseModel):
    """Timesheet

    :param id_: id_
    :type id_: IdentifierValue
    :param type_: Deprecated - it is always "work"
    :type type_: str
    :param status: Status of this entry.
    :type status: TimesheetStatusEnum
    :param description: description
    :type description: str
    :param date_submitted: Long date-time format following ISO-8601
    :type date_submitted: str
    :param currency_code: currency_code
    :type currency_code: str
    :param total_amount: is equal to quantity times rate of active work statement + bonus in this record
    :type total_amount: str
    :param quantity: quantity
    :type quantity: float
    :param created_at: created_at
    :type created_at: str
    :param scale: scale, defaults to None
    :type scale: str, optional
    :param custom_scale: custom_scale, defaults to None
    :type custom_scale: str, optional
    :param attachment: This object is used for linking file attachments to your records.
    :type attachment: FileAttachmentInfo
    :param worksheet: worksheet
    :type worksheet: TimesheetWorksheet
    :param reviewed_by: reviewed_by
    :type reviewed_by: TimesheetReviewedBy
    :param contract: contract
    :type contract: TimesheetContract
    :param payment_cycle: payment_cycle, defaults to None
    :type payment_cycle: TimesheetPaymentCycle, optional
    :param reported_by: reported_by
    :type reported_by: TimesheetReportedBy
    :param approvers: approvers
    :type approvers: List[TimesheetApprover]
    """

    def __init__(
        self,
        id_: IdentifierValue,
        type_: str,
        status: TimesheetStatusEnum,
        description: str,
        date_submitted: str,
        currency_code: str,
        total_amount: str,
        quantity: float,
        created_at: str,
        attachment: FileAttachmentInfo,
        worksheet: TimesheetWorksheet,
        reviewed_by: TimesheetReviewedBy,
        contract: TimesheetContract,
        reported_by: TimesheetReportedBy,
        approvers: List[TimesheetApprover],
        scale: str = None,
        custom_scale: str = None,
        payment_cycle: TimesheetPaymentCycle = None,
    ):
        self.id_ = IdentifierValueGuard.return_one_of(id_)
        self.type_ = type_
        self.status = self._enum_matching(status, TimesheetStatusEnum.list(), "status")
        self.description = description
        self.date_submitted = date_submitted
        self.currency_code = self._pattern_matching(
            currency_code, "^[A-Z]{3}$", "currency_code"
        )
        self.total_amount = total_amount
        self.quantity = quantity
        self.created_at = created_at
        if scale is not None:
            self.scale = scale
        if custom_scale is not None:
            self.custom_scale = custom_scale
        self.attachment = self._define_object(attachment, FileAttachmentInfo)
        self.worksheet = self._define_object(worksheet, TimesheetWorksheet)
        self.reviewed_by = self._define_object(reviewed_by, TimesheetReviewedBy)
        self.contract = self._define_object(contract, TimesheetContract)
        if payment_cycle is not None:
            self.payment_cycle = self._define_object(
                payment_cycle, TimesheetPaymentCycle
            )
        self.reported_by = self._define_object(reported_by, TimesheetReportedBy)
        self.approvers = self._define_list(approvers, TimesheetApprover)
