MangoPay/Libraries/ApiBase.php
protected function CreateObject($methodKey, $entity, $responseClassName = null, $entityId = null, $subEntityId = null, $idempotencyKey = null)
    {
        if (is_null($entityId)) {
            $urlMethod = $this->GetRequestUrl($methodKey);
        } elseif (is_null($subEntityId)) {
            $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId);
        } else {
            $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId, $subEntityId);
        }

        $requestData = null;
        if (!is_null($entity)) {
            $requestData = $this->BuildRequestData($entity);
        }

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

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

        return $response;
    }
protected function CreateObject($methodKey, $entity, $responseClassName = null, $entityId = null, $subEntityId = null, $idempotencyKey = null)
    {
        if (is_null($entityId)) {
            $urlMethod = $this->GetRequestUrl($methodKey);
        } elseif (is_null($subEntityId)) {
            $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId);
        } else {
            $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId, $subEntityId);
        }

        $requestData = null;
        if (!is_null($entity)) {
            $requestData = $this->BuildRequestData($entity);
        }

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

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

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