I have an enum in client code describing a list of endpoints in the API:
enum Requests { GetUsers, GetProducts, ... }
I want to send requests to server having these values, like connection.sendRequest(Requests.GetUsers)
.
Now, in the sendRequest()
function I want the enum value to be converted to something like '/users'
.
Can I attach methods to each enum similar to this below?
enum Requests {
GetUsers.toString: '/users',
GetPendingDomains: '/prodcuts'
}