public function selfFromResponse(array $response)
    {
        $this->fill($response);

        foreach ($this->getSingleNestedEntities() as $key => $value) {
            if (isset($response[$key])) {
                $entityName = $value;
                $this->$key = new $entityName($this->connection, $response[$key]);
            }
        }

        foreach ($this->getMultipleNestedEntities() as $key => $value) {
            if (isset($response[$key])) {
                $entityName = $value['entity'];
                /** @var self $instantiatedEntity */
                $instantiatedEntity = new $entityName($this->connection);
                $this->$key = $instantiatedEntity->collectionFromResult($response[$key]);
            }
        }

        return $this;
    }
public function selfFromResponse(array $response)
    {
        $this->fill($response);

        foreach ($this->getSingleNestedEntities() as $key => $value) {
            if (isset($response[$key])) {
                $entityName = $value;
                $this->$key = new $entityName($this->connection, $response[$key]);
            }
        }

        foreach ($this->getMultipleNestedEntities() as $key => $value) {
            if (isset($response[$key])) {
                $entityName = $value['entity'];
                /** @var self $instantiatedEntity */
                $instantiatedEntity = new $entityName($this->connection);
                $this->$key = $instantiatedEntity->collectionFromResult($response[$key]);
            }
        }

        return $this;
    }
public function selfFromResponse ( array $ response ) { $ this -> fill ( $ response ) ; foreach ( $ this -> getSingleNestedEntities ( ) as $ key => $ value ) { if ( isset ( $ response [ $ key ] ) ) { $ entityName = $ value ; $ this -> $ key = new $ entityName ( $ this -> connection , $ response [ $ key ] ) ; } } foreach ( $ this -> getMultipleNestedEntities ( ) as $ key => $ value ) { if ( isset ( $ response [ $ key ] ) ) { $ entityName = $ value [ 'entity' ] ; /** @var self $instantiatedEntity */ $ instantiatedEntity = new $ entityName ( $ this -> connection ) ; $ this -> $ key = $ instantiatedEntity -> collectionFromResult ( $ response [ $ key ] ) ; } } return $ this ; }
Recreate this object with the response from the API.

@param array $response

@return $this
Recreate this object with the response from the API .