I am looking at a project that makes calls to an API (within C# code so this is taking place server-side). There are dozens of methods and so you might see something like
/API/GetValue1 , /API/Search/ , /API/AnotherThing, or /API/Something/DoSomethingElse/1234411(some ID)
For all of this right now it's hard-coded into each of the calls, and likely won't change, but you never know.
Can all of this be moved into a constants class and so I could replace the occurence of /API/GetValue1 with something like MyConstantClass.Value1 and it would automatically put that as the URL path for the endpoint?
That's what you should do. Create a static class to contain all of your API endpoints. Never use magic strings directly in code, because they are error-prone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With