<?php
namespace Fusio\Impl\Worker\Generated;

/**
 * Autogenerated by Thrift Compiler (0.14.2)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;

class App
{
    static public $isValidate = false;

    static public $_TSPEC = array(
        1 => array(
            'var' => 'id',
            'isRequired' => false,
            'type' => TType::I64,
        ),
        2 => array(
            'var' => 'userId',
            'isRequired' => false,
            'type' => TType::I64,
        ),
        3 => array(
            'var' => 'status',
            'isRequired' => false,
            'type' => TType::I32,
        ),
        4 => array(
            'var' => 'name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        5 => array(
            'var' => 'url',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        6 => array(
            'var' => 'appKey',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        7 => array(
            'var' => 'scopes',
            'isRequired' => false,
            'type' => TType::LST,
            'etype' => TType::STRING,
            'elem' => array(
                'type' => TType::STRING,
                ),
        ),
        8 => array(
            'var' => 'parameters',
            'isRequired' => false,
            'type' => TType::LST,
            'etype' => TType::STRING,
            'elem' => array(
                'type' => TType::STRING,
                ),
        ),
    );

    /**
     * @var int
     */
    public $id = null;
    /**
     * @var int
     */
    public $userId = null;
    /**
     * @var int
     */
    public $status = null;
    /**
     * @var string
     */
    public $name = null;
    /**
     * @var string
     */
    public $url = null;
    /**
     * @var string
     */
    public $appKey = null;
    /**
     * @var string[]
     */
    public $scopes = null;
    /**
     * @var string[]
     */
    public $parameters = null;

    public function __construct($vals = null)
    {
        if (is_array($vals)) {
            if (isset($vals['id'])) {
                $this->id = $vals['id'];
            }
            if (isset($vals['userId'])) {
                $this->userId = $vals['userId'];
            }
            if (isset($vals['status'])) {
                $this->status = $vals['status'];
            }
            if (isset($vals['name'])) {
                $this->name = $vals['name'];
            }
            if (isset($vals['url'])) {
                $this->url = $vals['url'];
            }
            if (isset($vals['appKey'])) {
                $this->appKey = $vals['appKey'];
            }
            if (isset($vals['scopes'])) {
                $this->scopes = $vals['scopes'];
            }
            if (isset($vals['parameters'])) {
                $this->parameters = $vals['parameters'];
            }
        }
    }

    public function getName()
    {
        return 'App';
    }


    public function read($input)
    {
        $xfer = 0;
        $fname = null;
        $ftype = 0;
        $fid = 0;
        $xfer += $input->readStructBegin($fname);
        while (true) {
            $xfer += $input->readFieldBegin($fname, $ftype, $fid);
            if ($ftype == TType::STOP) {
                break;
            }
            switch ($fid) {
                case 1:
                    if ($ftype == TType::I64) {
                        $xfer += $input->readI64($this->id);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 2:
                    if ($ftype == TType::I64) {
                        $xfer += $input->readI64($this->userId);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 3:
                    if ($ftype == TType::I32) {
                        $xfer += $input->readI32($this->status);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 4:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 5:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->url);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 6:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->appKey);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 7:
                    if ($ftype == TType::LST) {
                        $this->scopes = array();
                        $_size36 = 0;
                        $_etype39 = 0;
                        $xfer += $input->readListBegin($_etype39, $_size36);
                        for ($_i40 = 0; $_i40 < $_size36; ++$_i40) {
                            $elem41 = null;
                            $xfer += $input->readString($elem41);
                            $this->scopes []= $elem41;
                        }
                        $xfer += $input->readListEnd();
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 8:
                    if ($ftype == TType::LST) {
                        $this->parameters = array();
                        $_size42 = 0;
                        $_etype45 = 0;
                        $xfer += $input->readListBegin($_etype45, $_size42);
                        for ($_i46 = 0; $_i46 < $_size42; ++$_i46) {
                            $elem47 = null;
                            $xfer += $input->readString($elem47);
                            $this->parameters []= $elem47;
                        }
                        $xfer += $input->readListEnd();
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                default:
                    $xfer += $input->skip($ftype);
                    break;
            }
            $xfer += $input->readFieldEnd();
        }
        $xfer += $input->readStructEnd();
        return $xfer;
    }

    public function write($output)
    {
        $xfer = 0;
        $xfer += $output->writeStructBegin('App');
        if ($this->id !== null) {
            $xfer += $output->writeFieldBegin('id', TType::I64, 1);
            $xfer += $output->writeI64($this->id);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->userId !== null) {
            $xfer += $output->writeFieldBegin('userId', TType::I64, 2);
            $xfer += $output->writeI64($this->userId);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->status !== null) {
            $xfer += $output->writeFieldBegin('status', TType::I32, 3);
            $xfer += $output->writeI32($this->status);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->name !== null) {
            $xfer += $output->writeFieldBegin('name', TType::STRING, 4);
            $xfer += $output->writeString($this->name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->url !== null) {
            $xfer += $output->writeFieldBegin('url', TType::STRING, 5);
            $xfer += $output->writeString($this->url);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->appKey !== null) {
            $xfer += $output->writeFieldBegin('appKey', TType::STRING, 6);
            $xfer += $output->writeString($this->appKey);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->scopes !== null) {
            if (!is_array($this->scopes)) {
                throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
            }
            $xfer += $output->writeFieldBegin('scopes', TType::LST, 7);
            $output->writeListBegin(TType::STRING, count($this->scopes));
            foreach ($this->scopes as $iter48) {
                $xfer += $output->writeString($iter48);
            }
            $output->writeListEnd();
            $xfer += $output->writeFieldEnd();
        }
        if ($this->parameters !== null) {
            if (!is_array($this->parameters)) {
                throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
            }
            $xfer += $output->writeFieldBegin('parameters', TType::LST, 8);
            $output->writeListBegin(TType::STRING, count($this->parameters));
            foreach ($this->parameters as $iter49) {
                $xfer += $output->writeString($iter49);
            }
            $output->writeListEnd();
            $xfer += $output->writeFieldEnd();
        }
        $xfer += $output->writeFieldStop();
        $xfer += $output->writeStructEnd();
        return $xfer;
    }
}
