<?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 User
{
    static public $isValidate = false;

    static public $_TSPEC = array(
        1 => array(
            'var' => 'id',
            'isRequired' => false,
            'type' => TType::I64,
        ),
        2 => array(
            'var' => 'roleId',
            'isRequired' => false,
            'type' => TType::I64,
        ),
        3 => array(
            'var' => 'categoryId',
            'isRequired' => false,
            'type' => TType::I64,
        ),
        4 => array(
            'var' => 'status',
            'isRequired' => false,
            'type' => TType::I32,
        ),
        5 => array(
            'var' => 'name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        6 => array(
            'var' => 'email',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        7 => array(
            'var' => 'points',
            'isRequired' => false,
            'type' => TType::I32,
        ),
    );

    /**
     * @var int
     */
    public $id = null;
    /**
     * @var int
     */
    public $roleId = null;
    /**
     * @var int
     */
    public $categoryId = null;
    /**
     * @var int
     */
    public $status = null;
    /**
     * @var string
     */
    public $name = null;
    /**
     * @var string
     */
    public $email = null;
    /**
     * @var int
     */
    public $points = null;

    public function __construct($vals = null)
    {
        if (is_array($vals)) {
            if (isset($vals['id'])) {
                $this->id = $vals['id'];
            }
            if (isset($vals['roleId'])) {
                $this->roleId = $vals['roleId'];
            }
            if (isset($vals['categoryId'])) {
                $this->categoryId = $vals['categoryId'];
            }
            if (isset($vals['status'])) {
                $this->status = $vals['status'];
            }
            if (isset($vals['name'])) {
                $this->name = $vals['name'];
            }
            if (isset($vals['email'])) {
                $this->email = $vals['email'];
            }
            if (isset($vals['points'])) {
                $this->points = $vals['points'];
            }
        }
    }

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


    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->roleId);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 3:
                    if ($ftype == TType::I64) {
                        $xfer += $input->readI64($this->categoryId);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 4:
                    if ($ftype == TType::I32) {
                        $xfer += $input->readI32($this->status);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 5:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 6:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->email);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 7:
                    if ($ftype == TType::I32) {
                        $xfer += $input->readI32($this->points);
                    } 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('User');
        if ($this->id !== null) {
            $xfer += $output->writeFieldBegin('id', TType::I64, 1);
            $xfer += $output->writeI64($this->id);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->roleId !== null) {
            $xfer += $output->writeFieldBegin('roleId', TType::I64, 2);
            $xfer += $output->writeI64($this->roleId);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->categoryId !== null) {
            $xfer += $output->writeFieldBegin('categoryId', TType::I64, 3);
            $xfer += $output->writeI64($this->categoryId);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->status !== null) {
            $xfer += $output->writeFieldBegin('status', TType::I32, 4);
            $xfer += $output->writeI32($this->status);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->name !== null) {
            $xfer += $output->writeFieldBegin('name', TType::STRING, 5);
            $xfer += $output->writeString($this->name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->email !== null) {
            $xfer += $output->writeFieldBegin('email', TType::STRING, 6);
            $xfer += $output->writeString($this->email);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->points !== null) {
            $xfer += $output->writeFieldBegin('points', TType::I32, 7);
            $xfer += $output->writeI32($this->points);
            $xfer += $output->writeFieldEnd();
        }
        $xfer += $output->writeFieldStop();
        $xfer += $output->writeStructEnd();
        return $xfer;
    }
}
