Open andersonkrs opened 7 months ago
The first pass on writing a generic NetHttp wrapper was a good start but it is time to evolve, the code needs some clean up.
The idea is to end with an API like this
class ApiClient < HttpClient::Base self.site = "https://jsonplaceholder.typicode.com" self.content_type = :json def fetch_post(id:) get("/posts/#{id}") end def create_post(title:, body:) post("/posts", body: { title: title, body: body, userId: 1 }) end response = ApiClient.create_post(title: "foo", body: "bar") response = ApiClient.fetch_post(id: 1)
The first pass on writing a generic NetHttp wrapper was a good start but it is time to evolve, the code needs some clean up.
The idea is to end with an API like this