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

au.org.consumerdatastandards.client.cli.BankingDirectDebits Maven / Gradle / Ivy

/*
 * Consumer Data Standards
 * Sample CLI tool to Demonstrate the Consumer Data Right APIs
 *
 * NOTE: This class is auto generated by the codegen artefact
 * https://github.com/ConsumerDataStandardsAustralia/java-artefacts/codegen
 */
package au.org.consumerdatastandards.client.cli;

import au.org.consumerdatastandards.client.api.BankingDirectDebitsAPI;
import au.org.consumerdatastandards.client.cli.support.ApiUtil;
import au.org.consumerdatastandards.client.cli.support.JsonPrinter;
import au.org.consumerdatastandards.client.model.ParamAccountOpenStatus;
import au.org.consumerdatastandards.client.model.ParamProductCategory;
import au.org.consumerdatastandards.client.model.RequestAccountIds;
import au.org.consumerdatastandards.client.model.RequestAccountIdsData;
import au.org.consumerdatastandards.client.model.ResponseBankingDirectDebitAuthorisationList;
import au.org.consumerdatastandards.conformance.ConformanceError;
import au.org.consumerdatastandards.conformance.PayloadValidator;
import au.org.consumerdatastandards.support.ResponseCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.shell.standard.ShellCommandGroup;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;

import java.util.List;

@ShellComponent
@ShellCommandGroup("BankingDirectDebits")
public class BankingDirectDebits extends ApiCliBase {

    private static final Logger LOGGER = LoggerFactory.getLogger(BankingDirectDebits.class);

    private PayloadValidator payloadValidator = new PayloadValidator();
    private final BankingDirectDebitsAPI api = new BankingDirectDebitsAPI();

    @ShellMethod("List direct debits")
    public String listDirectDebits(@ShellOption(defaultValue = ShellOption.NULL) Boolean check,
        @ShellOption(defaultValue = ShellOption.NULL) String accountId,
        @ShellOption(defaultValue = ShellOption.NULL) Integer page,
        @ShellOption(defaultValue = ShellOption.NULL) Integer pageSize) throws Exception {

        LOGGER.info("List direct debits CLI initiated with accountId: {}, page: {}, page-size: {}",
            accountId,
            page,
            pageSize);

        api.setApiClient(ApiUtil.createApiClient(apiClientOptions));
        ResponseBankingDirectDebitAuthorisationList response = api.listDirectDebits(accountId, page, pageSize);
        if (apiClientOptions.isValidationEnabled() || (check != null && check)) {
            LOGGER.info("Payload validation is enabled");
            okhttp3.Call call = api.listDirectDebitsCall(accountId, page, pageSize, null);
            List conformanceErrors = payloadValidator
                .validateResponse(call.request().url().toString(), response, "listDirectDebits", ResponseCode.OK);
            if (!conformanceErrors.isEmpty()) {
                throwConformanceErrors(conformanceErrors);
            }
        }
        return JsonPrinter.toJson(response);
    }

    @ShellMethod("Obtain balances for multiple, filtered accounts")
    public String listDirectDebitsBulk(@ShellOption(defaultValue = ShellOption.NULL) Boolean check,
                                   @ShellOption(defaultValue = ShellOption.NULL) Boolean isOwned,
                                   @ShellOption(defaultValue = ShellOption.NULL) ParamAccountOpenStatus openStatus,
                                   @ShellOption(defaultValue = ShellOption.NULL) Integer page,
                                   @ShellOption(defaultValue = ShellOption.NULL) Integer pageSize,
                                   @ShellOption(defaultValue = ShellOption.NULL) ParamProductCategory productCategory) throws Exception {
        LOGGER.info("List direct debits bulk CLI initiated with is-owned: {}, open-status: {}, page: {}, page-size: {}, product-category: {}",
            isOwned,
            openStatus,
            page,
            pageSize,
            productCategory);

        api.setApiClient(ApiUtil.createApiClient(apiClientOptions));
        ResponseBankingDirectDebitAuthorisationList response =
            api.listDirectDebitsBulk(isOwned, openStatus, page, pageSize, productCategory);
        if (apiClientOptions.isValidationEnabled() || (check != null && check)) {
            LOGGER.info("Payload validation is enabled");
            okhttp3.Call call = api.listDirectDebitsBulkCall(isOwned, openStatus, page, pageSize, productCategory, null);
            List conformanceErrors = payloadValidator
                .validateResponse(call.request().url().toString(), response, "listDirectDebitsBulk", ResponseCode.OK);
            if (!conformanceErrors.isEmpty()) {
                throwConformanceErrors(conformanceErrors);
            }
        }
        return JsonPrinter.toJson(response);
    }
    
    @ShellMethod("List direct debits specific accounts")
    public String listDirectDebitsSpecificAccounts(@ShellOption(defaultValue = ShellOption.NULL) Boolean check,
        @ShellOption(defaultValue = ShellOption.NULL) List accountIds,
        @ShellOption(defaultValue = ShellOption.NULL) Integer page,
        @ShellOption(defaultValue = ShellOption.NULL) Integer pageSize) throws Exception {

        LOGGER.info("List direct debits specific accounts CLI initiated with accountIds: {}, page: {}, page-size: {}",
            accountIds,
            page,
            pageSize);

        api.setApiClient(ApiUtil.createApiClient(apiClientOptions));
        RequestAccountIdsData data = new RequestAccountIdsData();
        data.setAccountIds(accountIds);
        RequestAccountIds requestAccountIds = new RequestAccountIds();
        requestAccountIds.setData(data);
        ResponseBankingDirectDebitAuthorisationList response = api.listDirectDebitsSpecificAccounts(requestAccountIds, page, pageSize);
        if (apiClientOptions.isValidationEnabled() || (check != null && check)) {
            LOGGER.info("Payload validation is enabled");
            okhttp3.Call call = api.listDirectDebitsSpecificAccountsCall(requestAccountIds, page, pageSize, null);
            List conformanceErrors = payloadValidator
                .validateResponse(call.request().url().toString(), response, "listDirectDebitsSpecificAccounts", ResponseCode.OK);
            if (!conformanceErrors.isEmpty()) {
                throwConformanceErrors(conformanceErrors);
            }
        }
        return JsonPrinter.toJson(response);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy