Use client class as argument for method in ESP and Arduino

I've got a library that connects to a server as a client to send a command. It is currently working on the ESP with the ESP8266WiFi.h library being used in the sketch and my library.
The .begin method in my library has a WiFiClient object reference as argument like this:

void begin(WiFiClient &clientref, IPAddress serverIP)

From that point onward the methods in the class will send the commands to that IP using that client object.

Now, if I wanted to use the code with the Ethernet shield on an Arduino it wouldn't work. It'd only take a bit of work but the client class would have to be redefined to suit that Ethernet library (e.i. EthernetClient).

I've seen libraries (e.g.ArduinoJson) that are able to "print" the command to both types of clients and even to a serial out. I've been reading for a while and there seems to be a Stream.h that could be involved, but I'm new to classes and I definitely don't know the inner workings of these libraries, so I'm a bit a lot lost!

So the questions:
1-Is it possible to do it (at least for the ESP and Ehternet shield)?
2-If it is, how could I do it? Is there a more "generic" client class I could use?

Please let me know if I'm not clear enough or if some code would make it clearer and I'll post it.

class WiFiClient : public Client, public SList<WiFiClient> {

Looks like Client would be the first choice. I don’t know what the other one is.

You need to look at the two client objects that you want to deal with. Determine what classes they are instances of. Determine what classes those classes derive from. Work up the inheritance list until you find a common base class.

If you don't find a common base class, you can't have one method that services both types of clients.