Interface integration contract - muhamed-hassan/messaging-poc GitHub Wiki

AnalyticsController::prepareReportRequest()

  • Controller: AnalyticsController
  • POST /v1/analytics/cash-out-report
  • Request:
    • Body: {year: unsigned int32}
      • Constraints:
        • year
          • is invalid => allowed range is [(currentYear - 5), currentYear] AKA only 5 years backwards is allowed
    • Headers:
      • Content-Type: application/json
  • Response:
    • HttpStatus: 202
  • Semi data storage WRITE:
    • Produce message containing cash-out report request

Endpoint request example:

curl --verbose --data '{ "year": "2023" }' --header "Content-Type: application/json" --request POST http://localhost:8080/v1/analytics/cash-out-report

Endpoint response example:

> POST /v1/analytics/cash-out-report HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.83.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 18
>

< HTTP/1.1 202 Accepted
< Server: Apache-Coyote/1.1
< Content-Length: 0
< Date: Sat, 07 Jan 2023 12:13:13 GMT

AnalyticsController::getCashOutReport()

  • Controller: AnalyticsController
  • GET /v1/analytics/cash-out-report/{year}
    • year => unsigned int32
      • is invalid => allowed range is [(currentYear - 5), currentYear] AKA only 5 years backwards is allowed
  • Request:
    • Headers:
      • Accept: application/json
  • Response:
    • Body: {summation: float, monthlySpendings: [{amount: float, month: text}, ...]}
    • HttpStatus: 200
  • Data storage READ:
    • Get cash-out report using a year

Endpoint request example:

curl --verbose --header "Accept: application/json" --request GET http://localhost:8080/v1/analytics/cash-out-report/2023

Endpoint response example:

> GET /v1/analytics/cash-out-report/2023 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.83.1
> Accept: application/json
>

< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Sat, 07 Jan 2023 12:15:44 GMT
< {"summation":30766.0,"monthlySpendings":[{"amount":777.0,"month":"January"},{"amount":999.0,"month":"February"},{"amount":5000.0,"month":"March"},{"amount":4500.0,"month":"April"},{"amount":3500.0,"month":"May"},{"amount":2000.0,"month":"June"},{"amount":2200.0,"month":"July"},{"amount":1500.0,"month":"August"},{"amount":1800.0,"month":"September"},{"amount":1750.0,"month":"October"},{"amount":2850.0,"month":"November"},{"amount":3890.0,"month":"December"}]}