<?php

namespace Ups_transit\UPStransitStruct;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for TimeInTransitResponse UPStransitStruct
 * @package Ups_transit
 * @subpackage Structs
 */
class Ups_transitTimeInTransitResponse extends AbstractStructBase
{
    /**
     * The Response
     * Meta information extracted from the WSDL
     * - ref: common:Response
     * @var \Ups_transit\UPStransitStruct\Ups_transitResponseType
     */
    public $Response;
    /**
     * The TransitResponse
     * Meta information extracted from the WSDL
     * - choice: TransitResponse | CandidateResponse
     * - choiceMaxOccurs: 1
     * - choiceMinOccurs: 1
     * - minOccurs: 0
     * @var \Ups_transit\UPStransitStruct\Ups_transitTransitResponseType
     */
    public $TransitResponse;
    /**
     * The CandidateResponse
     * Meta information extracted from the WSDL
     * - choice: TransitResponse | CandidateResponse
     * - choiceMaxOccurs: 1
     * - choiceMinOccurs: 1
     * - minOccurs: 0
     * @var \Ups_transit\UPStransitStruct\Ups_transitCandidateResponseType
     */
    public $CandidateResponse;
    /**
     * Constructor method for TimeInTransitResponse
     * @uses Ups_transitTimeInTransitResponse::setResponse()
     * @uses Ups_transitTimeInTransitResponse::setTransitResponse()
     * @uses Ups_transitTimeInTransitResponse::setCandidateResponse()
     * @param \Ups_transit\UPStransitStruct\Ups_transitResponseType $response
     * @param \Ups_transit\UPStransitStruct\Ups_transitTransitResponseType $transitResponse
     * @param \Ups_transit\UPStransitStruct\Ups_transitCandidateResponseType $candidateResponse
     */
    public function __construct(\Ups_transit\UPStransitStruct\Ups_transitResponseType $response = null, \Ups_transit\UPStransitStruct\Ups_transitTransitResponseType $transitResponse = null, \Ups_transit\UPStransitStruct\Ups_transitCandidateResponseType $candidateResponse = null)
    {
        $this
            ->setResponse($response)
            ->setTransitResponse($transitResponse)
            ->setCandidateResponse($candidateResponse);
    }
    /**
     * Get Response value
     * @return \Ups_transit\UPStransitStruct\Ups_transitResponseType|null
     */
    public function getResponse()
    {
        return $this->Response;
    }
    /**
     * Set Response value
     * @param \Ups_transit\UPStransitStruct\Ups_transitResponseType $response
     * @return \Ups_transit\UPStransitStruct\Ups_transitTimeInTransitResponse
     */
    public function setResponse(\Ups_transit\UPStransitStruct\Ups_transitResponseType $response = null)
    {
        $this->Response = $response;
        return $this;
    }
    /**
     * Get TransitResponse value
     * @return \Ups_transit\UPStransitStruct\Ups_transitTransitResponseType|null
     */
    public function getTransitResponse()
    {
        return isset($this->TransitResponse) ? $this->TransitResponse : null;
    }
    /**
     * This method is responsible for validating the value passed to the setTransitResponse method
     * This method is willingly generated in order to preserve the one-line inline validation within the setTransitResponse method
     * This has to validate that the property which is being set is the only one among the given choices
     * @param mixed $value
     * @return string A non-empty message if the values does not match the validation rules
     */
    public function validateTransitResponseForChoiceConstraintsFromSetTransitResponse($value)
    {
        $message = '';
        if (is_null($value)) {
            return $message;
        }
        $properties = [
            'CandidateResponse',
        ];
        try {
            foreach ($properties as $property) {
                if (isset($this->{$property})) {
                    throw new \InvalidArgumentException(sprintf('The property TransitResponse can\'t be set as the property %s is already set. Only one property must be set among these properties: TransitResponse, %s.', $property, implode(', ', $properties)), __LINE__);
                }
            }
        } catch (\InvalidArgumentException $e) {
            $message = $e->getMessage();
        }
        return $message;
    }
    /**
     * Set TransitResponse value
     * This property belongs to a choice that allows only one property to exist. It is
     * therefore removable from the request, consequently if the value assigned to this
     * property is null, the property is removed from this object
     * @throws \InvalidArgumentException
     * @param \Ups_transit\UPStransitStruct\Ups_transitTransitResponseType $transitResponse
     * @return \Ups_transit\UPStransitStruct\Ups_transitTimeInTransitResponse
     */
    public function setTransitResponse(\Ups_transit\UPStransitStruct\Ups_transitTransitResponseType $transitResponse = null)
    {
        // validation for constraint: choice(TransitResponse, CandidateResponse)
        if ('' !== ($transitResponseChoiceErrorMessage = self::validateTransitResponseForChoiceConstraintsFromSetTransitResponse($transitResponse))) {
            throw new \InvalidArgumentException($transitResponseChoiceErrorMessage, __LINE__);
        }
        if (is_null($transitResponse) || (is_array($transitResponse) && empty($transitResponse))) {
            unset($this->TransitResponse);
        } else {
            $this->TransitResponse = $transitResponse;
        }
        return $this;
    }
    /**
     * Get CandidateResponse value
     * @return \Ups_transit\UPStransitStruct\Ups_transitCandidateResponseType|null
     */
    public function getCandidateResponse()
    {
        return isset($this->CandidateResponse) ? $this->CandidateResponse : null;
    }
    /**
     * This method is responsible for validating the value passed to the setCandidateResponse method
     * This method is willingly generated in order to preserve the one-line inline validation within the setCandidateResponse method
     * This has to validate that the property which is being set is the only one among the given choices
     * @param mixed $value
     * @return string A non-empty message if the values does not match the validation rules
     */
    public function validateCandidateResponseForChoiceConstraintsFromSetCandidateResponse($value)
    {
        $message = '';
        if (is_null($value)) {
            return $message;
        }
        $properties = [
            'TransitResponse',
        ];
        try {
            foreach ($properties as $property) {
                if (isset($this->{$property})) {
                    throw new \InvalidArgumentException(sprintf('The property CandidateResponse can\'t be set as the property %s is already set. Only one property must be set among these properties: CandidateResponse, %s.', $property, implode(', ', $properties)), __LINE__);
                }
            }
        } catch (\InvalidArgumentException $e) {
            $message = $e->getMessage();
        }
        return $message;
    }
    /**
     * Set CandidateResponse value
     * This property belongs to a choice that allows only one property to exist. It is
     * therefore removable from the request, consequently if the value assigned to this
     * property is null, the property is removed from this object
     * @throws \InvalidArgumentException
     * @param \Ups_transit\UPStransitStruct\Ups_transitCandidateResponseType $candidateResponse
     * @return \Ups_transit\UPStransitStruct\Ups_transitTimeInTransitResponse
     */
    public function setCandidateResponse(\Ups_transit\UPStransitStruct\Ups_transitCandidateResponseType $candidateResponse = null)
    {
        // validation for constraint: choice(TransitResponse, CandidateResponse)
        if ('' !== ($candidateResponseChoiceErrorMessage = self::validateCandidateResponseForChoiceConstraintsFromSetCandidateResponse($candidateResponse))) {
            throw new \InvalidArgumentException($candidateResponseChoiceErrorMessage, __LINE__);
        }
        if (is_null($candidateResponse) || (is_array($candidateResponse) && empty($candidateResponse))) {
            unset($this->CandidateResponse);
        } else {
            $this->CandidateResponse = $candidateResponse;
        }
        return $this;
    }
}
