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