Fruga-Budget / Fruga-be

0 stars 0 forks source link

JSON Contract #2

Closed NicoShanstrom closed 3 months ago

NicoShanstrom commented 3 months ago

POST Request to /users/:user_id/advices (user does not meet 50/30/20 rule) Headers: Content-Type: application/json Accept: application/json Request Body: { "needs": 3000, "wants": 1500, "savings": 500, "total_income": 5000 }

Successful Response: Status Code: 201 Created Content-Type: application/json Response Body: { "data": { "id": "1", "type": "advice", "attributes": { "needs": 3000, "wants": 1500, "savings": 500, "total_income": 5000, "recommendation": "Your monthly budget breakdown does not meet the 50/30/20 rule. Consider tracking each of your needs and wants to explore how you can reach the following recommendation. Here is a recommendation on how you can shift your budget around to meet the rule: Allocate $2500 for needs, $1500 for wants, and $1000 for savings." } } }

POST Request to /users/:user_id/advices (user meets 50/30/20 rule) Headers: Content-Type: application/json Accept: application/json Request Body: { "needs": 2500, "wants": 1500, "savings": 1000, "total_income": 5000 }

Successful Response: Status Code: 201 Created Content-Type: application/json Response Body: { "data": { "id": "2", "type": "advice", "attributes": { "needs": 2500, "wants": 1500, "savings": 1000, "total_income": 5000, "recommendation": "Congratulations your monthly budget breakdown meets the 50/30/20 rule! Consider tracking each need and want to explore where you can save even more!" } } }

Error Response (400 Level) POST Request to /users/:user_id/advices Headers: Content-Type: application/json Accept: application/json Body: { "needs": "", "wants": 1500, "savings": 500, "total_income": 5000 } Response Headers: Content-Type: application/json Response Body: { "errors": [ { "status": "400", "title": "Invalid Request", "detail": "Needs can't be blank" } ] }