<?php

namespace Shm\ShmPayment\TBankPayment\TBankCollections;

use Shm\Collection\Collection;
use Shm\Shm;

use Shm\ShmTypes\StructureType;

class TPayments extends Collection
{

    public function schema(): StructureType
    {
        $schema = Shm::structure([

            "amount" => Shm::float()->title("Сумма платежа, руб")->inAdmin()->inTable(),




            "orderId" => Shm::string()->title("ID заказа")->inAdmin()->inTable(),
            "description" => Shm::string()->title("Описание платежа")->inAdmin()->inTable(),
            "phone" => Shm::string()->title("Телефон")->inAdmin()->inTable(),
            "email" => Shm::string()->title("Email")->inAdmin()->inTable(),
            "owner" => Shm::ID(),
            "ownerCollection" => Shm::string(),
            "initRequest" => Shm::json()->title("Запрос инициализации платежа")->inAdmin(),
            "autoRefunded" => Shm::bool()->title("Автоматический возврат")->inAdmin(),
            "notifications" => Shm::arrayOf(Shm::json())->title("Уведомления"),
            "initResult" => Shm::json()->title("Результат инициализации платежа")->inAdmin(),
            "paymentId" => Shm::string()->title("ID платежа")->inAdmin(),
            "status" => Shm::string()->title("Статус платежа")->inAdmin(),
            "chargeResult" => Shm::json()->title("Результат оплаты по сохраненной карте")->inAdmin(),
            "cancelResult" => Shm::arrayOf(Shm::structure([
                "request" => Shm::json()->title("Запрос отмены платежа")->inAdmin(),
                "result" => Shm::json()->title("Результат отмены платежа")->inAdmin(),
                "created_at" => Shm::int()->title("Дата создания запроса")->inAdmin(),
            ]))->title("Результаты отмен платежа")->inAdmin(),

        ]);

        $schema->title("Платежи эквайринга ТБанк");
        return $schema;
    }
}
