/**
  * @param PagSeguroCredentials $credentials
  * @param PagSeguroPaymentRequest $request
  * @return null|PagSeguroParserData
  * @throws Exception
  * @throws PagSeguroServiceException
  */
 public static function createPreApprovalRequest(PagSeguroCredentials $credentials, PagSeguroPreApprovalRequest $request)
 {
     LogPagSeguro::info("PagSeguroPreApprovalService.PreApprovalRequest(" . $request->toString() . ") - begin");
     self::$connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME);
     $data = array_merge(self::$connectionData->getCredentials()->getAttributesMap(), PagSeguroPreApprovalParser::getData($request));
     try {
         $connection = new PagSeguroHttpConnection();
         $connection->post(self::buildPreApprovalUrl(self::$connectionData), $data, self::$connectionData->getServiceTimeout(), self::$connectionData->getCharset());
         self::$service = "PreApprovalRequest";
         return self::getResult($connection);
     } catch (PagSeguroServiceException $err) {
         //Logging
         LogPagSeguro::error("PagSeguroServiceException: " . $err->getMessage());
         //Exception
         throw $err;
     } catch (Exception $err) {
         //Logging
         LogPagSeguro::error("Exception: " . $err->getMessage());
         //Exception
         throw $err;
     }
 }