I want to use best practice to map data from API to my entity.
My conditions are: external API response as array, and need to save it to my Magento entity, but response array have different key names, that my entity has.
So I create a hardcoded mapper like
$data[] = [
'cheque_id' => $externalApiData['Id'],
'cheque_date' => $externalApiData['Date'],
'bonus' => $externalApiData['Bonuses'],
];
After that it’s easy to populate object by data using MagentoFrameworkApiDataObjectHelper::populateWithArray()
Maybe someone propose best solutions how to map it or give code example.