All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.global.api.builders.TransactionReportBuilder Maven / Gradle / Ivy

There is a newer version: 14.2.3
Show newest version
package com.global.api.builders;

import com.global.api.entities.enums.*;
import com.global.api.entities.reporting.DataServiceCriteria;
import com.global.api.entities.reporting.SearchCriteria;
import com.global.api.entities.reporting.SearchCriteriaBuilder;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

public class TransactionReportBuilder extends ReportBuilder {
    private String deviceId;
    private Date endDate;
    private Date startDate;
    private String transactionId;
    @Getter @Setter private int page = 1;       // 1: DEFAULT PARAM VALUE
    @Getter @Setter private int pageSize = 5;   // 5: DEFAULT PARAM VALUE
    @Getter @Setter private SortDirection order;
    @Getter @Setter private TransactionSortProperty transactionOrderBy;
    @Getter @Setter private DepositSortProperty depositOrderBy;
    @Getter @Setter private DisputeSortProperty disputeOrderBy;
    @Getter @Setter private StoredPaymentMethodSortProperty storedPaymentMethodOrderBy;
    @Getter @Setter private SortDirection storedPaymentMethodOrder;
    @Getter @Setter private ActionSortProperty actionOrderBy;
    @Getter @Setter private PayByLinkSortProperty payByLinkOrderBy;
    @Getter @Setter private String payByLinkId;

    private SearchCriteriaBuilder _searchBuilder;

    public TransactionReportBuilder(ReportType type, Class clazz) {
        super(type, clazz);
    }

    public SearchCriteriaBuilder getSearchBuilder() {
        if (_searchBuilder == null) {
            _searchBuilder = new SearchCriteriaBuilder(this);
        }
        return _searchBuilder;
    }

    public String getDeviceId() {
        return getSearchBuilder().getUniqueDeviceId();
    }
    public Date getEndDate() {
        return getSearchBuilder().getEndDate();
    }
    public Date getStartDate() {
        return getSearchBuilder().getStartDate();
    }
    public String getTransactionId() {
        return transactionId;
    }
    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }

    public TransactionReportBuilder withActionId(String value) {
        getSearchBuilder().setActionId(value);
        return this;
    }

    public TransactionReportBuilder withDepositReference(String value) {
        getSearchBuilder().setDepositReference(value);
        return this;
    }

    public TransactionReportBuilder withDeviceId(String value) {
        getSearchBuilder().setUniqueDeviceId(value);
        return this;
    }

    public TransactionReportBuilder withDisputeId(String value) {
        getSearchBuilder().setDisputeId(value);
        return this;
    }

    public TransactionReportBuilder withEndDate(Date value) {
        getSearchBuilder().setEndDate(value);
        return this;
    }
    public TransactionReportBuilder withStartDate(Date value) {
        getSearchBuilder().setStartDate(value);
        return this;
    }
    public TransactionReportBuilder withTimeZoneConversion(TimeZoneConversion value) {
        setTimeZoneConversion(value);
        return this;
    }
    public TransactionReportBuilder withTransactionId(String value) {
        this.transactionId = value;
        return this;
    }
    public  SearchCriteriaBuilder where(SearchCriteria criteria, T value) {
        return getSearchBuilder().and(criteria, value);
    }

    public  SearchCriteriaBuilder where(DataServiceCriteria criteria, T value) {
        return getSearchBuilder().and(criteria, value);
    }

    public TransactionReportBuilder withPaging(int page, int pageSize)
    {
        this.page = page;
        this.pageSize = pageSize;
        return this;
    }

    public TransactionReportBuilder withSettlementDisputeId(String value) {
        getSearchBuilder().setSettlementDisputeId(value);
        return this;
    }

    public TransactionReportBuilder withStoredPaymentMethodId(String value) {
        getSearchBuilder().setStoredPaymentMethodId(value);
        return this;
    }

    public TransactionReportBuilder withBankPaymentId(String bankPaymentId) {
        getSearchBuilder().setBankPaymentId(bankPaymentId);
        return this;
    }

    public TransactionReportBuilder withPayByLinkId(String payByLinkId) {
        getSearchBuilder().setPayByLinkId(payByLinkId);
        this.payByLinkId = payByLinkId;
        return this;
    }

    public TransactionReportBuilder orderBy(TransactionSortProperty orderBy, SortDirection direction)
    {
        transactionOrderBy = orderBy;
        order = (direction != null) ? direction : SortDirection.Ascending;
        return this;
    }

    public TransactionReportBuilder orderBy(DepositSortProperty orderBy, SortDirection direction) {
        depositOrderBy = orderBy;
        order = (direction != null) ? direction : SortDirection.Ascending;
        return this;
    }

    public TransactionReportBuilder orderBy(DisputeSortProperty orderBy, SortDirection direction) {
        disputeOrderBy = orderBy;
        order = (direction != null) ? direction : SortDirection.Ascending;
        return this;
    }

    public TransactionReportBuilder orderBy(StoredPaymentMethodSortProperty orderBy, SortDirection direction) {
        storedPaymentMethodOrderBy = orderBy;
        order = (direction != null) ? direction : SortDirection.Ascending;
        return this;
    }

    public TransactionReportBuilder orderBy(ActionSortProperty orderBy, SortDirection direction) {
        actionOrderBy = orderBy;
        order = (direction != null) ? direction : SortDirection.Ascending;
        return this;
    }

    public TransactionReportBuilder orderBy(PayByLinkSortProperty orderBy, SortDirection direction) {
        payByLinkOrderBy = orderBy;
        order = (direction != null) ? direction : SortDirection.Ascending;
        return this;
    }

    public void setupValidations() {
        this.validations.of(ReportType.TransactionDetail)
                .check("transactionId").isNotNull();

        this.validations.of(ReportType.Activity).check("transactionId").isNull();
        this.validations.of(ReportType.DocumentDisputeDetail)
                .check("_searchBuilder").propertyOf(String.class, "disputeDocumentId").isNotNull();
        this.validations.of(ReportType.PayByLinkDetail).check("payByLinkId").isNotNull();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy