Skip to content

Commit

Permalink
Merge pull request #48 from ADORSYS-GIS/46-create-the-deposit-account…
Browse files Browse the repository at this point in the history
…-rest-module-in-ledgers-thereby-limiting-interface-to-the-needed-endpoints-e8

Trimming the resp api to required endpoints
  • Loading branch information
NkwaTambe authored Oct 29, 2024
2 parents 49466e8 + 9a0f0b9 commit a6b1fbf
Show file tree
Hide file tree
Showing 12 changed files with 411 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<version>6.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>de.adorsys.ledgers.deposit.api</groupId>
<artifactId>ledgers-deposit-account-rest-api</artifactId>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,33 @@

package de.adorsys.ledgers.deposit.api.resource;

import de.adorsys.ledgers.deposit.api.domain.account.AccountDetailsTO;
import de.adorsys.ledgers.deposit.api.domain.payment.AmountTO;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import de.adorsys.ledgers.deposit.api.domain.account.*;
import io.swagger.v3.oas.annotations.*;
import io.swagger.v3.oas.annotations.responses.*;
import io.swagger.v3.oas.annotations.tags.*;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;

import static de.adorsys.ledgers.deposit.api.utils.Constants.ACCOUNT_ID;
import static de.adorsys.ledgers.deposit.api.utils.Constants.USER_ID;
import static de.adorsys.ledgers.deposit.api.utils.Constants.*;


@Tag(name = "LDG022 - Accounts (Deposit Account)", description = "Provides access to the deposit account resource for members.")
@Tag(name = "LDG??? - Accounts (Deposit Account)", description = "Provides access to the deposit account resource management interface")
public interface AccountMgmResourceAPI {

String BASE_PATH = "/AccountManagement";



/**
* Creates a new deposit account for a user specified by ID
* Account is created for the same branch as user
*
* @param userId user for who account is created
* @param accountDetailsTO account details
* @return Void
*/
@Operation(summary = "Registers a new Deposit Account for a user with specified ID",
description = "Registers a new deposit account and assigns account access OWNER to the current user.")
@Operation(summary = "Registers a new Deposit Account for the public key authenticating this request",
description = "Registers a new Deposit Account for the public key authenticating this request")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Account creation successful"),
@ApiResponse(responseCode = "404", description = "User with this ID not found"),
@ApiResponse(responseCode = "409", description = "Account with given IBAN already exists.")
@ApiResponse(responseCode = "200", description = "Account creation successful")
})
@PostMapping
ResponseEntity<Boolean> createDepositAccountForUser(@RequestParam(name = USER_ID) String userId,
ResponseEntity<AccountDetailsTO> createDepositAccount(@RequestHeader(AUTHORIZATION) String authorizationHeader,
@RequestBody AccountDetailsTO accountDetailsTO);


@GetMapping("/{accountId}")
ResponseEntity<AccountDetailsTO> getAccountDetailsById(@Parameter(name = ACCOUNT_ID) @PathVariable(ACCOUNT_ID) String accountId);

/**
* Operation deposits cash to the deposit account
*
* @param accountId Account ID in Ledgers
* @param amount Amount to be deposited
* @return Void
*/
@Operation(summary = "Deposit Cash",
description = "Operation for a member to register cash in the deposit account")

@ApiResponses(value = {
@ApiResponse(responseCode = "202", description = "Operation was successful")
})
@PostMapping("/{accountId}/cash")
ResponseEntity<Void> depositCash(@PathVariable(ACCOUNT_ID) String accountId, @RequestBody AmountTO amount);

@Operation(summary = "Load Extended Account Details by AccountId",
description = "Returns extended account details information for the given account id. "
+ "User must have access to the target account. This is also accessible to other token types like tpp token (DELEGATED_ACESS)")

@PostMapping("/{accountId}/status")
ResponseEntity<Boolean> changeStatus(@PathVariable(ACCOUNT_ID) String accountId);}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,68 @@

package de.adorsys.ledgers.deposit.api.resource;

import de.adorsys.ledgers.deposit.api.domain.account.AccountBalanceTO;
import de.adorsys.ledgers.deposit.api.domain.account.TransactionTO;
import de.adorsys.ledgers.deposit.api.domain.account.AccountDetailsTO;
import de.adorsys.ledgers.util.domain.CustomPageImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import de.adorsys.ledgers.deposit.api.domain.account.*;
import de.adorsys.ledgers.util.domain.*;
import io.swagger.v3.oas.annotations.*;
import io.swagger.v3.oas.annotations.media.*;
import io.swagger.v3.oas.annotations.responses.*;
import io.swagger.v3.oas.annotations.tags.*;
import org.springframework.format.annotation.*;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;
import java.time.*;
import java.util.*;

import static de.adorsys.ledgers.deposit.api.utils.Constants.ACCOUNT_ID;
import static de.adorsys.ledgers.deposit.api.utils.Constants.DATE_FROM_QUERY_PARAM;
import static de.adorsys.ledgers.deposit.api.utils.Constants.DATE_TO_QUERY_PARAM;
import static de.adorsys.ledgers.deposit.api.utils.Constants.LOCAL_DATE_YYYY_MM_DD_FORMAT;
import static de.adorsys.ledgers.deposit.api.utils.Constants.PAGE;
import static de.adorsys.ledgers.deposit.api.utils.Constants.SIZE;
import static de.adorsys.ledgers.deposit.api.utils.Constants.TRANSACTION_ID;
import static de.adorsys.ledgers.deposit.api.utils.Constants.*;


@Tag(name = "LDG003 - Accounts", description = "Provides access to a deposit account. This interface does not provide any endpoint to list all accounts.")
@Tag(name = "LDG??? - Accounts", description = "Provides access to a deposit account.")
public interface AccountRestAPI {
String BASE_PATH = "/accounts";


@GetMapping("/{accountId}")
@Operation(summary = "Load Account by AccountId",
description = "Returns account details information for the given account id. "
+ "User must have access to the target account. This is also accessible to other token types like tpp token (DELEGATED_ACESS)")
description = "Returns account details information for the given account id. ")

@ApiResponses(value = {
@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = AccountDetailsTO.class)),
description = "Account details.")
})
ResponseEntity<AccountDetailsTO> getAccountDetailsById(@Parameter(name = ACCOUNT_ID) @PathVariable(ACCOUNT_ID) String accountId);

@GetMapping("/{accountId}/balances")
@Operation(summary = "Read balances",
description = "Returns balances of the deposit account with the given accountId. "
+ "User must have access to the target account. This is also accessible to other token types like tpp token (DELEGATED_ACESS)")

description = "Returns balances of the deposit account with the given accountId.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = AccountBalanceTO.class)), description = "List of accounts balances for the given account.")
})

ResponseEntity<List<AccountBalanceTO>> getBalances(@Parameter(name = ACCOUNT_ID) @PathVariable(ACCOUNT_ID) String accountId);

@GetMapping(path = "/{accountId}/transactions", params = {DATE_FROM_QUERY_PARAM, DATE_TO_QUERY_PARAM})
@Operation(summary = "Find Transactions By Date", description = "Returns all transactions for the given account id")

ResponseEntity<List<TransactionTO>> getTransactionByDates(
@Parameter(name = ACCOUNT_ID)
@PathVariable(ACCOUNT_ID) String accountId,
@RequestParam(name = DATE_FROM_QUERY_PARAM, required = false) @DateTimeFormat(pattern = LOCAL_DATE_YYYY_MM_DD_FORMAT) LocalDate dateFrom,
@RequestParam(name = DATE_TO_QUERY_PARAM) @DateTimeFormat(pattern = LOCAL_DATE_YYYY_MM_DD_FORMAT) LocalDate dateTo);
@RequestParam(name = DATE_FROM_QUERY_PARAM, required = false) @DateTimeFormat(pattern = LOCAL_DATE_YYYY_MM_DD_FORMAT) LocalDateTime dateFrom,
@RequestParam(name = DATE_TO_QUERY_PARAM) @DateTimeFormat(pattern = LOCAL_DATE_YYYY_MM_DD_FORMAT) LocalDateTime dateTo);

@GetMapping(path = "/{accountId}/transactions/page", params = {DATE_FROM_QUERY_PARAM, DATE_TO_QUERY_PARAM, PAGE, SIZE})
@Operation(summary = "Find Transactions By Date", description = "Returns transactions for the given account id for certain dates, paged view")

ResponseEntity<CustomPageImpl<TransactionTO>> getTransactionByDatesPaged(
@Parameter(name = ACCOUNT_ID)
@PathVariable(name = ACCOUNT_ID) String accountId,
@RequestParam(name = DATE_FROM_QUERY_PARAM, required = false) @DateTimeFormat(pattern = LOCAL_DATE_YYYY_MM_DD_FORMAT) LocalDate dateFrom,
@RequestParam(name = DATE_TO_QUERY_PARAM) @DateTimeFormat(pattern = LOCAL_DATE_YYYY_MM_DD_FORMAT) LocalDate dateTo,
@RequestParam(name = DATE_FROM_QUERY_PARAM, required = false) @DateTimeFormat(pattern = LOCAL_DATE_YYYY_MM_DD_FORMAT) LocalDateTime dateFrom,
@RequestParam(name = DATE_TO_QUERY_PARAM) @DateTimeFormat(pattern = LOCAL_DATE_YYYY_MM_DD_FORMAT) LocalDateTime dateTo,
@RequestParam(PAGE) int page,
@RequestParam(SIZE) int size);

@GetMapping("/{accountId}/transactions/{transactionId}")
@Operation(summary = "Load Transaction", description = "Returns the transaction with the given account id and transaction id.")

ResponseEntity<TransactionTO> getTransactionById(
@Parameter(name = ACCOUNT_ID)
@PathVariable(name = ACCOUNT_ID) String accountId,
@Parameter(name = TRANSACTION_ID)
@PathVariable(name = TRANSACTION_ID) String transactionId);}
@PathVariable(name = TRANSACTION_ID) String transactionId);

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public abstract class Constants {

public static final String ACCOUNT_ID = "accountId";
public static final String USER_ID = "userId";
public static final String AUTHORIZATION = "Authorization";

public static final String TRANSACTION_ID = "transactionId";

Expand Down
Loading

0 comments on commit a6b1fbf

Please sign in to comment.