Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,11 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.15</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,18 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;

@Configuration
@EnableSwagger2
public class ApplicationConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.paths(PathSelectors.any())
.build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("BANKING APPLICATION REST API")
.description("API for Banking Application.")
.version("1.0.0").build();
public OpenAPI customOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("BANKING APPLICATION REST API")
.version("1.0.0")
.description("API for Banking Application."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,60 +17,34 @@
import com.coding.exercise.bankapp.domain.TransferDetails;
import com.coding.exercise.bankapp.service.BankingServiceImpl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@RestController
@RequestMapping("accounts")
@Api(tags = { "Accounts and Transactions REST endpoints" })
public class AccountController {

@Autowired
private BankingServiceImpl bankingService;

@GetMapping(path = "/{accountNumber}")
@ApiOperation(value = "Get account details", notes = "Find account details by account number")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> getByAccountNumber(@PathVariable Long accountNumber) {

return bankingService.findByAccountNumber(accountNumber);
}

@PostMapping(path = "/add/{customerNumber}")
@ApiOperation(value = "Add a new account", notes = "Create an new account for existing customer.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> addNewAccount(@RequestBody AccountInformation accountInformation,
@PathVariable Long customerNumber) {

return bankingService.addNewAccount(accountInformation, customerNumber);
}

@PutMapping(path = "/transfer/{customerNumber}")
@ApiOperation(value = "Transfer funds between accounts", notes = "Transfer funds between accounts.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> transferDetails(@RequestBody TransferDetails transferDetails,
@PathVariable Long customerNumber) {

return bankingService.transferDetails(transferDetails, customerNumber);
}

@GetMapping(path = "/transactions/{accountNumber}")
@ApiOperation(value = "Get all transactions", notes = "Get all Transactions by account number")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public List<TransactionDetails> getTransactionByAccountNumber(@PathVariable Long accountNumber) {

return bankingService.findTransactionsByAccountNumber(accountNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,71 +16,39 @@
import com.coding.exercise.bankapp.domain.CustomerDetails;
import com.coding.exercise.bankapp.service.BankingServiceImpl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@RestController
@RequestMapping("customers")
@Api(tags = { "Customer REST endpoints" })
public class CustomerController {

@Autowired
private BankingServiceImpl bankingService;

@GetMapping(path = "/all")
@ApiOperation(value = "Find all customers", notes = "Gets details of all the customers")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public List<CustomerDetails> getAllCustomers() {

return bankingService.findAll();
}

@PostMapping(path = "/add")
@ApiOperation(value = "Add a Customer", notes = "Add customer and create an account")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> addCustomer(@RequestBody CustomerDetails customer) {

return bankingService.addCustomer(customer);
}

@GetMapping(path = "/{customerNumber}")
@ApiOperation(value = "Get customer details", notes = "Get Customer details by customer number.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = CustomerDetails.class, responseContainer = "Object"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public CustomerDetails getCustomer(@PathVariable Long customerNumber) {

return bankingService.findByCustomerNumber(customerNumber);
}

@PutMapping(path = "/{customerNumber}")
@ApiOperation(value = "Update customer", notes = "Update customer and any other account information associated with him.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> updateCustomer(@RequestBody CustomerDetails customerDetails,
@PathVariable Long customerNumber) {

return bankingService.updateCustomer(customerDetails, customerNumber);
}

@DeleteMapping(path = "/{customerNumber}")
@ApiOperation(value = "Delete customer and related accounts", notes = "Delete customer and all accounts associated with him.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> deleteCustomer(@PathVariable Long customerNumber) {

return bankingService.deleteCustomer(customerNumber);
Expand Down