import json
import base64

from typing import Optional


class FinishPaymentData(object):
    def __init__(
        self,
        pos_id,             # type: str
        order_id,           # type: str
        fiscal_date,        # type: str
        fiscal_time,        # type: str
        status,             # type: str
        tender_details,     # type: str
        tender_id=""        # type: Optional[str]
    ):
        # type: (...) -> None

        self.pos_id = int(pos_id)
        self.order_id = int(order_id)
        self.fiscal_date = fiscal_date
        self.fiscal_time = fiscal_time
        self.status = int(status)
        self.tender_details = json.loads(base64.b64decode(tender_details) or "{}")
        self.tender_id = tender_id

    def __repr__(self):
        return """FinishPaymentData(
            pos_id={}, order_id={}, fiscal_date="{}", fiscal_time="{}", status={}, tender_details="{}", tender_id={}
        )""".format(
            self.pos_id,
            self.order_id,
            self.fiscal_date,
            self.fiscal_time,
            self.status,
            json.dumps(self.tender_details),
            self.tender_id
        )

    def __str__(self):
        return self.__repr__()
