Class MailTemplateController
- Namespace
- GastroSky.Controllers.V1
- Assembly
- GastroSky.dll
Mail template related endpoints. Not many users will have access to this.
[ApiController]
[Authorize]
[Route("api/v1/mail-templates")]
[Produces("application/json", new string[] { })]
public class MailTemplateController : GastroSkyControllerBase
- Inheritance
-
MailTemplateController
- Inherited Members
Constructors
MailTemplateController(GastroSkyDatabaseContext, IMapper, ILogger<PostController>)
Mail template related endpoints. Not many users will have access to this.
public MailTemplateController(GastroSkyDatabaseContext db, IMapper mapper, ILogger<PostController> logger)
Parameters
dbGastroSkyDatabaseContextmapperIMapperloggerILogger<PostController>
Methods
CreateMailTemplate(MailTemplateCreationRequestDto)
Creates a new mail template. Check out MailTemplate for more details.
[HttpPost]
[Route("")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:W")]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
[ProducesResponseType<ResponseBodyDto<MailTemplateResponseDto>>(201)]
public Task<IActionResult> CreateMailTemplate(MailTemplateCreationRequestDto dto)
Parameters
dtoMailTemplateCreationRequestDtoRequest DTO containing the mail template's content for the various supported languages. Check out the API DocFX documentation on MailTemplateCreationRequestDto for more information.
Returns
Remarks
Sample request:
POST /api/v1/mail-templates
{
"id": "GS_MailTemplate_DescriptiveID_Here",
"subjectEnglish": "Email subject here",
"subjectItalian": "Oggetto email qui dentro",
"subjectGerman": "E-Mail Betreff hier",
"subjectFrench": "Email Sujet super jet",
"htmlEnglish": "(English email body HTML here)",
"htmlItalian": "(Italian email body HTML here)",
"htmlGerman": "(German email body HTML here)",
"htmlFrench": "(French email body HTML here)",
"comment": "Not visible anywhere except in the mail templates admin dashboard. This should describe what the email template is and where it will be used and under what circumstances."
}
DeleteMailTemplate(string)
Deletes a mail template.
[HttpDelete]
[Route("{id}")]
[ProducesResponseType(204)]
[ProducesResponseType(404)]
[ProducesResponseType(500)]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:R")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:W")]
public Task<IActionResult> DeleteMailTemplate(string id)
Parameters
idstringThe mail template id.
Returns
Remarks
Only works if the mail template isn't one of the built-in templates and doesn't have the PreventDeletion column set to true.
GetBaseMailTemplate()
[HttpGet]
[Route("base")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:R")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:W")]
[ProducesResponseType<ResponseBodyDto<MailBaseTemplateResponseDto>>(200)]
public Task<IActionResult> GetBaseMailTemplate()
Returns
GetMailTemplate(string)
Gets a specific mail template. Check out MailTemplate for more details.
[HttpGet]
[Route("{id}")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:R")]
[ProducesResponseType(404)]
[ProducesResponseType<ResponseBodyDto<MailTemplateReducedResponseDto>>(200)]
public Task<IActionResult> GetMailTemplate(string id)
Parameters
idstringMail template ID. This is also the mail template's primary key in the DB.
Returns
GetMailTemplates(MailTemplateFilter?, PaginationFilter?)
Gets all mail templates available for sending email via the GastroSky backend.
[HttpGet]
[Route("")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:R")]
[ProducesResponseType<ResponseBodyDto<MailTemplateReducedResponseDto>>(200)]
public Task<IActionResult> GetMailTemplates(MailTemplateFilter? mailTemplateFilter = null, PaginationFilter? paginationFilter = null)
Parameters
mailTemplateFilterMailTemplateFilterQuery filter.
paginationFilterPaginationFilterPagination filter. PaginationFilter
Returns
Remarks
MailTemplateFilter::OrderByColumn can be either 0 to sort by ID column or 1 to order by last modification timestamp (UTC).
Exceptions
- ArgumentOutOfRangeException
Thrown if the provided sorting order inside the
mailTemplateFilterparameter is an invalid value.
ModifyMailTemplate(MailTemplateCreationRequestDto)
Modifies an existing mail template. Check out MailTemplate for more details.
[HttpPut]
[Route("")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:R")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:W")]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
[ProducesResponseType(500)]
[ProducesResponseType<ResponseBodyDto<MailTemplateResponseDto>>(200)]
public Task<IActionResult> ModifyMailTemplate(MailTemplateCreationRequestDto dto)
Parameters
dtoMailTemplateCreationRequestDtoRequest DTO containing the mail template's content for the various supported languages. Check out the API DocFX documentation on MailTemplateCreationRequestDto for more information.
Returns
Remarks
Sample request:
PUT /api/v1/mail-templates
{
"id": "GS_MailTemplate_DescriptiveID_Here",
"subjectEnglish": "Email subject here",
"subjectItalian": "Oggetto email qui dentro",
"subjectGerman": "E-Mail Betreff hier",
"subjectFrench": "Email Sujet super jet",
"htmlEnglish": "(English email body HTML here)",
"htmlItalian": "(Italian email body HTML here)",
"htmlGerman": "(German email body HTML here)",
"htmlFrench": "(French email body HTML here)",
"comment": "Not visible anywhere except in the mail templates admin dashboard. This should describe what the email template is and where it will be used and under what circumstances."
}
UpdateBaseMailTemplate(MailBaseTemplateModificationRequestDto)
[HttpPut]
[Route("base")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:R")]
[Authorize(Policy = "https://api.gastrosky.ch/identity/claims/resources/mail-templates:W")]
[ProducesResponseType<ResponseBodyDto<MailBaseTemplateResponseDto>>(200)]
public Task<IActionResult> UpdateBaseMailTemplate(MailBaseTemplateModificationRequestDto dto)