I think it’s a really nice way of building APIs. The Github enum makes it very clear which endpoints are available, and the form of their parameters. By defining these things once, we can make it much harder for users of this API to make mistakes. For example, it’s not possible to pass in a
nilusername, because the
UserProfiletakes a non-optional string. If we wanted to add optional parameters, we have to be explicit about that.
The other nice thing is that all of the above code is independent of any networking library.
Stay up-to-date by subscribing to the Comments RSS Feed for this post.