Class VoucherifyMockUtil

java.lang.Object
org.bhn.promotion.voucherify.utils.VoucherifyMockUtil

public class VoucherifyMockUtil extends Object
This class contains Voucherify Util methods
  • Method Details

    • voucherifyValidationResponse

      public static ValidationResponseDto voucherifyValidationResponse(String filePath)
      This class creates Validation response object from json
      Parameters:
      filePath - Json Response file
      Returns:
      ValidationResponseDto Validations Response object
    • voucherifyQualificationResponse

      public static CheckPromotionEligibilityResponseDto voucherifyQualificationResponse(String filePath)
      This class creates Eligibility response object from json
      Parameters:
      filePath - Json Response file
      Returns:
      CheckPromotionEligibilityResponseDto Eligibility Response object
    • voucherifyRedemptionResponse

      public static RedeemPromotionResponseDto voucherifyRedemptionResponse(String filePath)
      This class creates Redemption response object from json
      Parameters:
      filePath - Json Response file
      Returns:
      RedeemPromotionResponseDto Redemption Response object
    • rollbackRollbackResponse

      public static RedemptionRollbackResponseDto rollbackRollbackResponse(String filePath)
      This class creates Rollback response object from json
      Parameters:
      filePath - Json Response file
      Returns:
      RedemptionRollbackResponseDto Rollback Response object
    • getTokenFromResultUrl

      public static String getTokenFromResultUrl(String resultUrl)
      Extracts the token from the result URL.
      Parameters:
      resultUrl - the URL from which to extract the token.
      Returns:
      the extracted token, or null if the token cannot be found.
    • setParametersBasedOnExportType

      public static void setParametersBasedOnExportType(String exportType, io.voucherify.client.model.ExportsCreateRequestBodyParameters parameters, List<String> voucherFields, List<String> vouhcerifyOrderFields)
      Sets parameters in the given ExportsCreateRequestBodyParameters based on the export type.
      Parameters:
      exportType - the type of export (e.g., VOUCHER or ORDER).
      parameters - the parameters object to set fields in.
      voucherFields - the list of fields for voucher exports.
      vouhcerifyOrderFields - the list of fields for order exports.
    • generateFilePath

      public static String generateFilePath(String exportType)
      Generates a file path for the export file based on the export type.
      Parameters:
      exportType - the type of export (e.g., VOUCHER or ORDER).
      Returns:
      the generated file path as a String.
    • convertStringToEnum

      public static void convertStringToEnum(String exportType, String sortingParameterName, io.voucherify.client.model.ExportsCreateRequestBody createRequestBody, List<String> voucherFields, List<String> vouhcerifyOrderFields)
      Converts the export type and sorting parameter name to the corresponding enums and sets them in the provided ExportsCreateRequestBody.
      Parameters:
      exportType - the type of export (e.g., VOUCHER or ORDER).
      sortingParameterName - the name of the sorting parameter.
      createRequestBody - the request body to set parameters in.
      voucherFields - the list of fields for voucher exports.
      vouhcerifyOrderFields - the list of fields for order exports.
    • generateCSVFromDownloadExport

      public static File generateCSVFromDownloadExport(String filePath, String downloadExportResponseData, String promoReportNewFields, String promoOrderFields, String exportType)
      Generates a CSV file from the downloaded export data.
      Parameters:
      filePath - the path where the CSV file will be generated.
      downloadExportResponseData - the data returned from the download export response.
      promoReportNewFields - the new fields for the promo report.
      promoOrderFields - the fields for the order report.
      exportType - the type of export (e.g., VOUCHER or ORDER).
      Returns:
      the generated CSV file.
    • getHttpHeadersConsumer

      public static Consumer<org.springframework.http.HttpHeaders> getHttpHeadersConsumer(String appId, String token)
      Returns a consumer that sets HTTP headers for API requests.
      Parameters:
      appId - the application ID.
      token - the application token.
      Returns:
      a consumer that adds the necessary headers to the HTTP request.
    • readFromJson

      public static InputStream readFromJson(String filePath)
      Reads a JSON file from the resources directory and returns its input stream.
      Parameters:
      filePath - the name of the JSON file to read, located in the `/mockJson/` directory within the resources.
      Returns:
      an InputStream for the specified JSON file, or null if the file cannot be found.
      Throws:
      NullPointerException - if the provided filePath is null.