MangoPay/Libraries/ApiBase.php
protected function SaveObject($methodKey, $entity, $responseClassName = null, $secondEntityId = null)
    {
        $entityId = null;
        if (isset($entity->Id)){
            $entityId = $entity->Id;
        }

        if (is_null($secondEntityId)) {
            $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId);
        } else {
            $urlMethod = sprintf($this->GetRequestUrl($methodKey), $secondEntityId, $entityId);
        }

        $requestData = $this->BuildRequestData($entity);

        $rest = new RestTool(true, $this->_root);
        $response = $rest->Request($urlMethod, $this->GetRequestType($methodKey), $requestData);

        if (!is_null($responseClassName)) {
            return $this->CastResponseToEntity($response, $responseClassName);
        }

        return $response;
    }
protected function SaveObject($methodKey, $entity, $responseClassName = null, $secondEntityId = null)
    {
        $entityId = null;
        if (isset($entity->Id)){
            $entityId = $entity->Id;
        }

        if (is_null($secondEntityId)) {
            $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId);
        } else {
            $urlMethod = sprintf($this->GetRequestUrl($methodKey), $secondEntityId, $entityId);
        }

        $requestData = $this->BuildRequestData($entity);

        $rest = new RestTool(true, $this->_root);
        $response = $rest->Request($urlMethod, $this->GetRequestType($methodKey), $requestData);

        if (!is_null($responseClassName)) {
            return $this->CastResponseToEntity($response, $responseClassName);
        }

        return $response;
    }
protected function SaveObject ( $ methodKey , $ entity , $ responseClassName = null , $ secondEntityId = null ) { $ entityId = null ; if ( isset ( $ entity -> Id ) ) { $ entityId = $ entity -> Id ; } if ( is_null ( $ secondEntityId ) ) { $ urlMethod = sprintf ( $ this -> GetRequestUrl ( $ methodKey ) , $ entityId ) ; } else { $ urlMethod = sprintf ( $ this -> GetRequestUrl ( $ methodKey ) , $ secondEntityId , $ entityId ) ; } $ requestData = $ this -> BuildRequestData ( $ entity ) ; $ rest = new RestTool ( true , $ this -> _root ) ; $ response = $ rest -> Request ( $ urlMethod , $ this -> GetRequestType ( $ methodKey ) , $ requestData ) ; if ( ! is_null ( $ responseClassName ) ) { return $ this -> CastResponseToEntity ( $ response , $ responseClassName ) ; } return $ response ; }
Save object in API
@param string $methodKey Key with request data
@param object $entity Entity object to save
@param object $responseClassName Name of entity class from response
@return object Response data
Save object in API