I am trying to make an API that will Get a list of people depending on what you search by - PhoneNumber, Email, Name
My issue is I am not sure how to Route the API to do something like this...
[HttpGet, Route("SearchBy/{**searchByType**}/people")]
[NoNullArguments]
[Filterable]
public IHttpActionResult FindPeople([FromUri] string searchByType, object queryValue)
{
var response = new List<SearchSummary>();
switch (searchByType)
{
case "PhoneNumber":
response = peopleFinder.FindPeople((PhoneNumber)queryValue);
break;
case "Email":
response = peopleFinder.FindPeople((Email)queryValue);
break;
case "Name":
response = peopleFinder.FindPeople((Name) queryValue);
break;
}
return Ok(response);
}
Do I create a SearchBy object and pass in a member from that or maybe use an enum or constant somehow?