def searchByCode(cls, credentials, transactionCode):
     LogPagSeguro.info("PagSeguroTransactionSearchService.SearchByCode(%s) - begin" % transactionCode);
     connectionData = PagSeguroConnectionData(credentials, cls.serviceName)
     try:
         connection = PagSeguroHttpConnection()
         connection.get(cls.buildSearchUrlByCode(connectionData, transactionCode),connectionData.getServiceTimeout(), connectionData.getCharset())
         httpStatus = PagSeguroHttpStatus(connection.getStatus())
         httpStatusType = httpStatus.getType()
         if httpStatusType == 'OK':
             x = connection.getResponse()
             transaction = PagSeguroTransactionParser.readTransaction(x)
             LogPagSeguro.info("PagSeguroTransactionSearchService.SearchByCode(transactionCode=%s) - end %s" % (transactionCode, transaction))
         elif httpStatusType == 'BAD_REQUEST':
             errors = PagSeguroTransactionParser.readErrors(connection.getResponse())
             e = PagSeguroServiceException(httpStatus, errors)
             LogPagSeguro.info("PagSeguroTransactionSearchService.SearchByCode(transactionCode=%s) - error %s" % (transactionCode, e.getOneLineMessage()))
             raise e
         else:
             e = PagSeguroServiceException(httpStatus)
             LogPagSeguro.info("PagSeguroTransactionSearchService.SearchByCode(transactionCode=%s) - error %s" % (transactionCode, e.getOneLineMessage()))
             raise e
         if transaction:
             return transaction
         return False
     except:
         LogPagSeguro.error("Exception:")
         raise NameError("Error:")
 def searchByDate(cls, credentials, pageNumber, maxPageResults, initialDate, finalDate = None):
     LogPagSeguro.info("PagSeguroTransactionSearchService.SearchByDate(initialDate=%s, finalDate=%s) - begin" % (PagSeguroHelper.formatDate(initialDate), PagSeguroHelper.formatDate(finalDate)))
     connectionData = PagSeguroConnectionData(credentials, cls.serviceName)
     searchParams = {'initialDate': PagSeguroHelper.formatDate(initialDate),
                     'pageNumber': pageNumber,
                     'maxPageResults': maxPageResults }
     if finalDate:
         searchParams['finalDate'] = PagSeguroHelper.formatDate(searchParams['finalDate'])
     else:
         searchParams['finalDate'] = None
     
     try:
         connection = PagSeguroHttpConnection()
         connection.get(cls.buildSearchUrlByDate(connectionData, searchParams),connectionData.getServiceTimeout(), connectionData.getCharset())
         httpStatus = PagSeguroHttpStatus(connection.getStatus())
         httpStatusType = httpStatus.getType()
         if httpStatusType == 'OK':
             searchResult = PagSeguroTransactionParser.readSearchResult(connection.getResponse())
             LogPagSeguro.info("PagSeguroTransactionSearchService.SearchByDate(initialDate=%s,finalDate=%s) - end %s" % (PagSeguroHelper.formatDate(initialDate),PagSeguroHelper.formatDate(finalDate), searchResult))
         elif httpStatusType == 'BAD_REQUEST':
             errors = PagSeguroTransactionParser.readErrors(connection.getResponse())
             e = PagSeguroServiceException(httpStatus, errors)
             LogPagSeguro.info("PagSeguroTransactionSearchService.SearchByDate(initialDate=%s,finalDate=%s) - error %s" % (PagSeguroHelper.formatDate(initialDate),PagSeguroHelper.formatDate(finalDate), e.getOneLineMessage()))
             raise e
         else:
             e = PagSeguroServiceException(httpStatus)
             LogPagSeguro.info("PagSeguroTransactionSearchService.SearchByDate(initialDate=%s,finalDate=%s) - error %s" % (PagSeguroHelper.formatDate(initialDate),PagSeguroHelper.formatDate(finalDate), e.getOneLineMessage()))
             raise e
         if searchResult:
             return searchResult
         return False
     except e:
         LogPagSeguro.error("Exception: %s" % e.getMessage())
         raise e
 def checkTransaction(cls, credentials, notificationCode):
     LogPagSeguro.info("PagSeguroNotificationService.CheckTransaction(notificationCode=%s) - begin" % notificationCode)
     connectionData = PagSeguroConnectionData(credentials, cls.serviceName)
     try:
         connection = PagSeguroHttpConnection()
         connection.get(cls.buildTransactionNotificationUrl(connectionData, notificationCode),connectionData.getServiceTimeout(),connectionData.getCharset())
         httpStatus = PagSeguroHttpStatus(connection.getStatus())
         httpStatusType = httpStatus.getType()
         if httpStatusType == 'OK':
             response = connection.getResponse()
             transaction = PagSeguroTransactionParser.readTransaction(response)
             #LogPagSeguro.info("PagSeguroNotificationService.CheckTransaction(notificationCode=%s) - end %s" % (notificationCode, transaction))
         elif httpStatusType == 'BAD_REQUEST':
             errors = PagSeguroTransactionParser.readErrors(connection.getResponse())
             e = PagSeguroServiceException(httpStatus, errors)
             LogPagSeguro.info("PagSeguroNotificationService.CheckTransaction(notificationCode=%s) - error %s" % (notificationCode, e.getOneLineMessage()))
             raise e
         else:
             e = PagSeguroServiceException(httpStatus)
             LogPagSeguro.info("PagSeguroNotificationService.CheckTransaction(notificationCode=%s) - error %s" % (notificationCode, e.getOneLineMessage()))
             raise e
         if transaction:
             return transaction
         return None
     except e:
         LogPagSeguro.error("Exception: %s" % e.getMessage())
         raise e