     1: <?php
     2:
     3: namespace SMSApi\Api\Action\Phonebook;
     4:
     5: use SMSApi\Api\Action\AbstractAction;
     6: use SMSApi\Proxy\Uri;
     7:
     8: /**
     9:  * Class ContactGet
    10:  * @package SMSApi\Api\Action\Phonebook
    11:  */
    12: class ContactGet extends AbstractAction {
    13:
    14:     /**
    15:      * @param $data
    16:      * @return \SMSApi\Api\Response\ContactResponse
    17:      */
    18:     protected function response( $data ) {
    19:
    20:         return new \SMSApi\Api\Response\ContactResponse( $data );
    21:     }
    22:
    23:     /**
    24:      * @return Uri
    25:      */
    26:     public function uri() {
    27:
    28:         $query = "";
    29:
    30:         $this->withGroups();
    31:
    32:         $query .= $this->paramsLoginToQuery();
    33:
    34:         $query .= $this->paramsOther();
    35:
    36:         return new Uri( $this->proxy->getProtocol(), $this->proxy->getHost(), $this->proxy->getPort(), "/api/phonebook.do", $query );
    37:     }
    38:
    39:     /**
    40:      * @deprecated since v1.0.0
    41:      */
    42:     public function setContact( $number ) {
    43:         return $this->filterByPhoneNumber( $number );
    44:     }
    45:
    46:     /**
    47:      * Set filter by contact phone number.
    48:      *
    49:      * @param string|int $number phone number
    50:      * @return $this
    51:      */
    52:     public function filterByPhoneNumber( $number ) {
    53:         $this->params[ "get_contact" ] = $number;
    54:         return $this;
    55:     }
    56:
    57:
    58:     /**
    59:      * Add contact groups to response
    60:      *
    61:      * @return $this
    62:      */
    63:     private function withGroups() {
    64:         $this->params[ "with_groups" ] = 1;
    65:         return $this;
    66:     }
    67:
    68: }