I am trying to think of the best way to handle this. I have a Get, Post and Delete endpoint I need to use. The Get endpoint I have a transport object that has all the fields I need to display for the user in one Model for example:
public class CustomerRequest
{
public string CustomerAccount { get; set; }
public string CustomerLocation { get; set; }
public string CustomerGroup { get; set; }
public string CustomerType { get; set; }
public DateTime CustomerEndDate { get; set; }
public string CustomerAddedBy { get; set; }
public DateTime CustomerAddedDate { get; set; }
}
So for the Get endpoint I need all of these fields but then I have a Post to insert new ones and a Delete no update.
For the Post I really only need all the field 'except' the CustomerAddedBy and CustomerAddedDate.
For the Delete it is actually a composite key of CustomerAccount, CustomerEndDate
What is the best practice for this as I am weary of creating different request transport models such as a CustomerRequest, CustomerAddRequest, CustomerDeleteRequest which each is actually an IEnumerable of these object. Is there a better way I was thinking
if I could use for the delete a IEnumerable Tuple but that then does not show the property names in Swagger etc.
None
0 Points
2 Posts
Proper Endpoint Design Question
Feb 05, 2021 02:55 PM|beantownace|LINK
Hello all,
I am trying to think of the best way to handle this. I have a Get, Post and Delete endpoint I need to use. The Get endpoint I have a transport object that has all the fields I need to display for the user in one Model for example:
public class CustomerRequest
{
public string CustomerAccount { get; set; }
public string CustomerLocation { get; set; }
public string CustomerGroup { get; set; }
public string CustomerType { get; set; }
public DateTime CustomerEndDate { get; set; }
public string CustomerAddedBy { get; set; }
public DateTime CustomerAddedDate { get; set; }
}
So for the Get endpoint I need all of these fields but then I have a Post to insert new ones and a Delete no update.
For the Post I really only need all the field 'except' the CustomerAddedBy and CustomerAddedDate.
For the Delete it is actually a composite key of CustomerAccount, CustomerEndDate
What is the best practice for this as I am weary of creating different request transport models such as a CustomerRequest, CustomerAddRequest, CustomerDeleteRequest which each is actually an IEnumerable of these object. Is there a better way I was thinking if I could use for the delete a IEnumerable Tuple but that then does not show the property names in Swagger etc.
Thanks for any advice on design.