I'm writing an interface to bundle two underlying APIs into one new. The APIs provide data about archived invoices.
All three APIs (the two old ones and my new one) have different data structures.
<INVOICE_NO> (old XML),
"number" (old JSON),
"formatted_number" (new JSON) all mean the same field.
I've created a class for each API and let Spring's
RestTemplate handle the parsing/ formatting of the responses.
Now, after receiving a
ClassA object from the first API and a
ClassB object from the second API, I have to convert them to
ClassC objects and return them in it's format.
My first approach was to create two constructors for
ClassC which either take an object of type
ClassA or an object of type
ClassB as argument.
But now, I'm not sure if that's the right thing to do because I'm coupling two data transfer objects.
Would it be better to create an
InvoiceConverter class or even something else?