hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
181 stars 105 forks source link

[FEAT]: Send Subscription Cancellation Confirmation - Backend #98

Closed Ayobamidele closed 1 week ago

Ayobamidele commented 1 month ago

Description


Implement a feature to send Subscription Cancellation Confirmation to users. This endpoint should immediately update users about the Subscription Cancellation Confirmation details in the system. Upon being successfully sent, it will return the message confirming it is being delivered with a '200' status. If an error occurs, an appropriate error status will be returned.

Acceptance Criteria


Purpose


Users get a record/notification of their subscription cancellation confirmation

Requirements


Endpoints

 [POST] /api/v1/user/subscription/notification/cancellation/{id}

Requests

POST /api/v1/user/subscription/notification/cancellation/{id}
Content-Type: application/json
Authorization: Bearer <access_token>

{
    "id": 1
}

Successful Response

     {
           "message": "Sent Subscription Cancellation Confirmation notification successfully",
           "name": "str",
           "subscription": {
               "id": "int",
               "plan": "str",
               "cancellation_date": "str"
           }
       }

Error Response

401 Unauthorized

{
  "status":  "Unauthorized",
  "message":  "Unauthorized. Please log in."
  “status-code”: 401
}

400 Bad Request

{
  "status":  "Bad Request",
  "message":  "Please check the submitted data"
  “status-code”: 400
}

404 No subscription matches id.

{
  "success": false,
  "message": "No Subscription Found",
  "status_code": 404
}

500 Internal Server Error

{
  "success": false,
  "message": "string",
  "status_code": 500
}

Database design

schema

Table name: Subscription

id:

constraints: string(uuid), unique, primary-key, not null

user_id:

constraints: integer, not null

plan:

constraints: string, not null, length(150)

is_active:

 constraint: boolean

cancelled_at:

constraints: string, date timestamp

createdAt:

constraints: string, date timestamp

Tasks:

Testing:

markessien commented 1 month ago

This focuses on the email when that is the least of the issues with cancelling a sub

Ayobamidele commented 1 month ago

Updated to not focus on the email

phurhard commented 1 month ago

Are the other endpoints under subscription having same URI collection??

Ayobamidele commented 1 month ago

Yes, Sir.

phurhard commented 1 month ago

@Shullyd7 please check the Uri or this and #168 which one makes more sense

Shullyd7 commented 1 month ago

@phurhard the one in #168 is cleaner and makes more sense

Ayobamidele commented 1 month ago

@Shullyd7 please what are some correction i should make?

Shullyd7 commented 1 month ago

id should be a path variable, not query parameter @Ayobamidele

Ayobamidele commented 1 month ago

@Shullyd7 Thanks Shully, I've made the changes.

Ayobamidele commented 1 month ago

Team DataFlow SlackID @is_oluwadara - nest_js @bami - Fast API

max-out-oluwadara commented 1 month ago

Team DataFlow SlackID @is_oluwadara - nest_js @bami - Fast API