Daily iOS
Architecture

API client abstraction

You have three network clients for the auth server, product server, and payment server that are similar but slightly different (different headers, encoding, error formats). How would you abstract them with protocols to remove the duplication?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Separate the request description (Endpoint) from the transport (HTTPClient). An Endpoint protocol defines path, method, headers, body, and response decoding, and per-server differences are expressed as Endpoint groups or interceptors (header injection, error mapping). The transport layer is one shared implementation.

Share a question