Skip to content

RESTful API Lab 9

Lab#9 Cards MicroService


In this lab we will create a cards microservice, similar to the loans service.

Project Layout
Figure 1: Project Layout

Schema.sql, CardsConstants, ICardsService and CardsServiceImpl and CardsMapper files are given. Use port 9000 in the .yml file.

Creating a Card

Now a mobile number create a card. The mobile number supplied must be 10 digits long. A card cannot already exist for the customer with given mobile number.

Create a card - Success
Fig. 2 Create a card - Success

Create a card -  Card already exists for mobile no.
Fig. 3 Create a card - Card already exists for mobile no.

Create a card- mobile number too short
Fig. 4 Create a card- mobile number too short.

Creating a card – code in CardsServiceImpl
Fig. 5 Creating a card – code in CardsServiceImpl

The card is created using default values as shown and the number is generated as shown

Fetch card details

Fetching card details - success
Fig. 6 Fetching card details - success

Fetching card details - mobile number not 10 digits
Fig. 7 Fetching card details - mobile number not 10 digits

Fetching card – no card for given mobile number
Fig. 8 Fetching card – no card for given mobile number

Update Card details

Updating card – card details updated successfully
Fig. 9 Updating card – card details updated successfully

Fetch updated values – card details updated
Fig. 10 Fetch updated values – card details updated

Updating loan – validation errors in data
Fig. 11 Updating loan – validation errors in data

See CardsDto for error example

Handling errors in CardsDto
Fig. 12 Handling errors in CardsDto

Update card
Fig. 13 Update card - Mobile number not 10 digits

Update card
Fig. 14 Update card – Card number not found

DELETE Mapping

Deleting a card
Fig. 15 Deleting a card

Deleting a loan
Fig. 16 Deleting a loan – mobile number too short

Deleting a card
Fig. 17 Deleting a card – card with mobile number not found