Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Email Template Endpoints to Follow RESTful and Correct HTTP Methods #1278

Open
Jayflashy opened this issue Feb 28, 2025 · 0 comments · May be fixed by #1334
Open

FIX: Email Template Endpoints to Follow RESTful and Correct HTTP Methods #1278

Jayflashy opened this issue Feb 28, 2025 · 0 comments · May be fixed by #1334
Labels
bug Something isn't working

Comments

@Jayflashy
Copy link

Jayflashy commented Feb 28, 2025

Bug Description

The current API endpoints for email templates are not following standard RESTful conventions. Specifically, the HTTP methods used for several endpoints are non-standard for their intended operations. This PR updates the endpoints to follow RESTful conventions and fixes the HTTP methods for proper resource management.

Steps to Reproduce

  1. Review the existing email template API endpoints.
  2. Observe that non-standard HTTP methods are being used for certain operations:
    • POST for storing and deleting templates
    • POST for retrieving a template
    • PATCH for updating a template
  3. After applying the fix, the endpoints should use the appropriate HTTP methods (POST → GET → PATCH → DELETE).

Expected Behavior

  • The API should use the standard HTTP methods for each operation:
    • POST for creating a new resource (store template).
    • GET for retrieving resources (get a template or list of templates).
    • PATCH for updating a resource (update template).
    • DELETE for deleting a resource (delete template).
  • Endpoints should be properly structured according to RESTful conventions.

Current Behavior

  • The current endpoints are using non-standard methods:
    • POST for retrieving a template and deleting a template, which is not the correct HTTP method for these actions.
    • POST for storing a new template.
    • PATCH for updating a template, which is correct but needs to be better structured in the new route.
  • Inconsistencies exist in how resources are managed and requested.

Fixes Applied

  • Updated HTTP methods for various endpoints to follow RESTful conventions:

    • POSTPOST for storing a new template (unchanged).
    • GET for retrieving all templates (/api/v1/email/templates).
    • GET for retrieving a single template (/api/v1/email/templates/{templateName}).
    • PATCH for updating a template (/api/v1/email/templates/{templateName}).
    • DELETE for deleting a template (/api/v1/email/templates/{templateName}).
  • Changed the URL paths to better reflect RESTful resource naming conventions:

    • /api/v1/email/store-template/api/v1/email/templates
    • /api/v1/email/get-template/api/v1/email/templates/{templateName}
    • /api/v1/email/delete-template/api/v1/email/templates/{templateName}
    • /api/v1/email/get-all-templates/api/v1/email/templates

Screenshots/Logs

Image

Environment

  • OS: [e.g. Windows, macOS, Linux]
  • Browser/Device: [e.g. Chrome, Firefox, iPhone]
  • Version: [e.g. 22]

Additional Context

  • The endpoints now follow RESTful API conventions, improving consistency and making the API easier to understand and maintain.
  • The DELETE method is now correctly used for deleting templates.
  • The GET method is now used for retrieving a single template and all templates, following the correct conventions.
@Jayflashy Jayflashy added the bug Something isn't working label Feb 28, 2025
@Jayflashy Jayflashy linked a pull request Mar 1, 2025 that will close this issue
22 tasks
@Jayflashy Jayflashy changed the title [FIX] Change Delete Template Endpoint from POST to Use DELETE Method REFACTOR: Email Template Endpoints to Follow RESTful Conventions and Correct HTTP Methods Mar 1, 2025
@Jayflashy Jayflashy changed the title REFACTOR: Email Template Endpoints to Follow RESTful Conventions and Correct HTTP Methods FIX: Email Template Endpoints to Follow RESTful Conventions and Correct HTTP Methods Mar 1, 2025
@Jayflashy Jayflashy changed the title FIX: Email Template Endpoints to Follow RESTful Conventions and Correct HTTP Methods FIX: Email Template Endpoints to Follow RESTful and Correct HTTP Methods Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant