<?php

declare(strict_types=1);

namespace Square\Models;

class TerminalCheckout implements \JsonSerializable
{
    /**
     * @var string|null
     */
    private $id;

    /**
     * @var Money
     */
    private $amountMoney;

    /**
     * @var string|null
     */
    private $referenceId;

    /**
     * @var string|null
     */
    private $note;

    /**
     * @var DeviceCheckoutOptions
     */
    private $deviceOptions;

    /**
     * @var string|null
     */
    private $deadlineDuration;

    /**
     * @var string|null
     */
    private $status;

    /**
     * @var string|null
     */
    private $cancelReason;

    /**
     * @var string[]|null
     */
    private $paymentIds;

    /**
     * @var string|null
     */
    private $createdAt;

    /**
     * @var string|null
     */
    private $updatedAt;

    /**
     * @param Money $amountMoney
     * @param DeviceCheckoutOptions $deviceOptions
     */
    public function __construct(Money $amountMoney, DeviceCheckoutOptions $deviceOptions)
    {
        $this->amountMoney = $amountMoney;
        $this->deviceOptions = $deviceOptions;
    }

    /**
     * Returns Id.
     *
     * A unique ID for this `TerminalCheckout`
     */
    public function getId(): ?string
    {
        return $this->id;
    }

    /**
     * Sets Id.
     *
     * A unique ID for this `TerminalCheckout`
     *
     * @maps id
     */
    public function setId(?string $id): void
    {
        $this->id = $id;
    }

    /**
     * Returns Amount Money.
     *
     * Represents an amount of money. `Money` fields can be signed or unsigned.
     * Fields that do not explicitly define whether they are signed or unsigned are
     * considered unsigned and can only hold positive amounts. For signed fields, the
     * sign of the value indicates the purpose of the money transfer. See
     * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-
     * monetary-amounts)
     * for more information.
     */
    public function getAmountMoney(): Money
    {
        return $this->amountMoney;
    }

    /**
     * Sets Amount Money.
     *
     * Represents an amount of money. `Money` fields can be signed or unsigned.
     * Fields that do not explicitly define whether they are signed or unsigned are
     * considered unsigned and can only hold positive amounts. For signed fields, the
     * sign of the value indicates the purpose of the money transfer. See
     * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-
     * monetary-amounts)
     * for more information.
     *
     * @required
     * @maps amount_money
     */
    public function setAmountMoney(Money $amountMoney): void
    {
        $this->amountMoney = $amountMoney;
    }

    /**
     * Returns Reference Id.
     *
     * An optional user-defined reference ID which can be used to associate
     * this TerminalCheckout to another entity in an external system. For example, an order
     * ID generated by a third-party shopping cart. Will also be associated with any payments
     * used to complete the checkout.
     */
    public function getReferenceId(): ?string
    {
        return $this->referenceId;
    }

    /**
     * Sets Reference Id.
     *
     * An optional user-defined reference ID which can be used to associate
     * this TerminalCheckout to another entity in an external system. For example, an order
     * ID generated by a third-party shopping cart. Will also be associated with any payments
     * used to complete the checkout.
     *
     * @maps reference_id
     */
    public function setReferenceId(?string $referenceId): void
    {
        $this->referenceId = $referenceId;
    }

    /**
     * Returns Note.
     *
     * An optional note to associate with the checkout, as well any payments used to complete the checkout.
     */
    public function getNote(): ?string
    {
        return $this->note;
    }

    /**
     * Sets Note.
     *
     * An optional note to associate with the checkout, as well any payments used to complete the checkout.
     *
     * @maps note
     */
    public function setNote(?string $note): void
    {
        $this->note = $note;
    }

    /**
     * Returns Device Options.
     */
    public function getDeviceOptions(): DeviceCheckoutOptions
    {
        return $this->deviceOptions;
    }

    /**
     * Sets Device Options.
     *
     * @required
     * @maps device_options
     */
    public function setDeviceOptions(DeviceCheckoutOptions $deviceOptions): void
    {
        $this->deviceOptions = $deviceOptions;
    }

    /**
     * Returns Deadline Duration.
     *
     * The duration as an RFC 3339 duration, after which the checkout will be automatically canceled.
     * TerminalCheckouts that are PENDING will be automatically CANCELED and have a cancellation reason
     * of “TIMED\_OUT”.
     *
     * Default: 5 minutes from creation
     *
     * Maximum: 5 minutes
     */
    public function getDeadlineDuration(): ?string
    {
        return $this->deadlineDuration;
    }

    /**
     * Sets Deadline Duration.
     *
     * The duration as an RFC 3339 duration, after which the checkout will be automatically canceled.
     * TerminalCheckouts that are PENDING will be automatically CANCELED and have a cancellation reason
     * of “TIMED\_OUT”.
     *
     * Default: 5 minutes from creation
     *
     * Maximum: 5 minutes
     *
     * @maps deadline_duration
     */
    public function setDeadlineDuration(?string $deadlineDuration): void
    {
        $this->deadlineDuration = $deadlineDuration;
    }

    /**
     * Returns Status.
     *
     * The status of the `TerminalCheckout`.
     * Options: PENDING, IN\_PROGRESS, CANCELED, COMPLETED
     */
    public function getStatus(): ?string
    {
        return $this->status;
    }

    /**
     * Sets Status.
     *
     * The status of the `TerminalCheckout`.
     * Options: PENDING, IN\_PROGRESS, CANCELED, COMPLETED
     *
     * @maps status
     */
    public function setStatus(?string $status): void
    {
        $this->status = $status;
    }

    /**
     * Returns Cancel Reason.
     */
    public function getCancelReason(): ?string
    {
        return $this->cancelReason;
    }

    /**
     * Sets Cancel Reason.
     *
     * @maps cancel_reason
     */
    public function setCancelReason(?string $cancelReason): void
    {
        $this->cancelReason = $cancelReason;
    }

    /**
     * Returns Payment Ids.
     *
     * A list of payments created by this `TerminalCheckout`.
     *
     * @return string[]|null
     */
    public function getPaymentIds(): ?array
    {
        return $this->paymentIds;
    }

    /**
     * Sets Payment Ids.
     *
     * A list of payments created by this `TerminalCheckout`.
     *
     * @maps payment_ids
     *
     * @param string[]|null $paymentIds
     */
    public function setPaymentIds(?array $paymentIds): void
    {
        $this->paymentIds = $paymentIds;
    }

    /**
     * Returns Created At.
     *
     * The time when the `TerminalCheckout` was created as an RFC 3339 timestamp.
     */
    public function getCreatedAt(): ?string
    {
        return $this->createdAt;
    }

    /**
     * Sets Created At.
     *
     * The time when the `TerminalCheckout` was created as an RFC 3339 timestamp.
     *
     * @maps created_at
     */
    public function setCreatedAt(?string $createdAt): void
    {
        $this->createdAt = $createdAt;
    }

    /**
     * Returns Updated At.
     *
     * The time when the `TerminalCheckout` was last updated as an RFC 3339 timestamp.
     */
    public function getUpdatedAt(): ?string
    {
        return $this->updatedAt;
    }

    /**
     * Sets Updated At.
     *
     * The time when the `TerminalCheckout` was last updated as an RFC 3339 timestamp.
     *
     * @maps updated_at
     */
    public function setUpdatedAt(?string $updatedAt): void
    {
        $this->updatedAt = $updatedAt;
    }

    /**
     * Encode this object to JSON
     *
     * @return mixed
     */
    public function jsonSerialize()
    {
        $json = [];
        $json['id']               = $this->id;
        $json['amount_money']     = $this->amountMoney;
        $json['reference_id']     = $this->referenceId;
        $json['note']             = $this->note;
        $json['device_options']   = $this->deviceOptions;
        $json['deadline_duration'] = $this->deadlineDuration;
        $json['status']           = $this->status;
        $json['cancel_reason']    = $this->cancelReason;
        $json['payment_ids']      = $this->paymentIds;
        $json['created_at']       = $this->createdAt;
        $json['updated_at']       = $this->updatedAt;

        return array_filter($json, function ($val) {
            return $val !== null;
        });
    }
}
