<?php

/**
 * Phonalisa REST API Model
 *
 * PHP version 5
 *
 * @category Phonalisa REST API Model
 * @package  Phonalisa
 * @author   Sebastian Kauder <sebastian.kauder@aerea.de>
 * @license  Phonalisa Europe GmbH Closed Source Software License
 * @link     http://www.phonalisa.de
 */
class Alarm extends PhonalisaRecord
{

    //phoneAlarm
    public $requestID;
    public $phoneNumber;
    public $targetType; // LANDLINE => PHONE_NUMBER = Landline; MOBILE => PHONE_NUMBER = Mobile
    public $callType;   // VOICERECORDING ; TEXTTOSPEECH
    public $recordingID;
    public $messageText;
    //eMailMessage
    public $messageSubject;
    public $targetEmailAddress;
    public $responseEmailAddress;
    public $recallPhoneNumber;
    public $subscriberID;
    public $subscriberPIN;
    //alarmResponse
    public $alarmTimeStamp;
    public $responseTimeStamp;
    public $response;
    //alarmID
    public $alarmListID;
    //alarmType
    public $alarmType;

    public static function myAttributes()
    {
        return array(
            'requestID' => 'requestID',
            'phoneNumber' => 'phoneNumber',
            'targetType' => 'targetType',
            'callType' => 'callType',
            'recordingID' => 'recordingID',
            'messageText' => 'messageText',
            'messageSubject' => 'messageSubject',
            'targetEmailAddress' => 'targetEmailAddress',
            'responseEmailAddress' => 'responseEmailAddress',
            'recallPhoneNumber' => 'recallPhoneNumber',
            'subscriberID' => 'subscriberID',
            'subscriberPIN' => 'subscriberPIN',
            'alarmTimeStamp' => 'alarmTimeStamp',
            'responseTimeStamp' => 'responseTimeStamp',
            'response' => 'response',
            'alarmListID' => 'alarmListID',
            'alarmType' => 'alarmType',
        );
    }

    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Inbox the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'alarm';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('requestID,'
                . 'phoneNumber,'
                . 'targetType,'
                . 'callType,'
                . 'recordingID,'
                . 'messageText,'
                . 'messageSubject,'
                . 'targetEmailAddress,'
                . 'responseEmailAddress,'
                . 'recallPhoneNumber,'
                . 'subscriberID,'
                . 'subscriberPIN,'
                . 'alarmTimeStamp,'
                . 'responseTimeStamp,'
                . 'response,'
                . 'alarmListID,'
                . 'alarmType',
                'safe'
            ),
            array('phoneNumber,'
                . 'recallPhoneNumber',
                'match',
                'pattern' => '/^([+]?[0-9 ]+)$/'
            ),
            array('targetEmailAddress,'
                . 'responseEmailAddress',
                'email'
            ),
            array('requestID,'
                . 'phoneNumber,'
                . 'targetType,'
                . 'callType,'
                . 'messageText',
                'required',
                'on' => 'phonealarm'
            ),
            array('requestID,'
                . 'phoneNumber,'
                . 'targetType,'
                . 'callType,'
                . 'recordingID,'
                . 'messageText',
                'required',
                'on' => 'voicerecording'
            ),
            array('requestID,'
                . 'phoneNumber,'
                . 'targetType,'
                . 'messageText',
                'required',
                'on' => 'smsalarm'
            ),
            array('requestID,'
                . 'targetEmailAddress,'
                . 'responseEmailAddress,'
                . 'messageSubject,'
                . 'messageText,'
                . 'recallPhoneNumber,'
                . 'subscriberID,'
                . 'subscriberPIN',
                'required',
                'on' => 'emailmessage'
            ),
        );
    }
    //phonalisaIsOK, errorID, errorMessage, errorSource,

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'requestID' => 'RequestID',
            'phoneNumber' => 'PhoneNumber',
            'targetType' => 'TargetType',
            'callType' => 'CallType',
            'recordingID' => 'RecordingID',
            'messageText' => 'MessageText',
            'messageSubject' => 'MessageSubject',
            'targetEmailAddress' => 'TargetEmailAddress',
            'responseEmailAddress' => 'ResponseEmailAddress',
            'recallPhoneNumber' => 'RecallPhoneNumber',
            'subscriberID' => 'SubscriberID',
            'subscriberPIN' => 'SubscriberPIN',
            'alarmTimeStamp' => 'AlarmTimeStamp',
            'responseTimeStamp' => 'ResponseTimeStamp',
            'response' => 'Response',
            'alarmListID' => 'AlarmListID',
            'alarmType' => 'AlarmType'
        );
    }
}
