← Back to Upcase

Considering pattern for saving object into external services


(Yevgeniy Viktorov) #1

Hello,

here is use case:

The system contains order entity that need be saved into external accounting systems via JSON API.

Here is some quick ideas which relies on the mapper pattern more or less:

gateway.create_order(OrderMapper.to_gateway(order)) # 1

gateway.create_order(order.to_gateway) # 2

order.save_to_gateway(gateway) # 3

Which one you’d prefer and why?
I’m also open for other ideas

Thanks in advance!