Simplify support of multiple class objects in VoucherMailer
Problem
As part of https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5929#note_1180208624, the logic to find the email, name and company of the recipient as well as the log info in the VoucherMailer
was getting too complex. This is because there are now three classes (License
, Subscription
and Customer
) that are supported by the VoucherMailer
. In the linked thread there were a few options that were discussed. But one seemed like the way to go.
Proposal
All three classes, License
, Subscription
and Customer
, used in the VoucherMailer
should respond to the same methods. E.g. currently only License
and Customer
respond to an email
method and Subscription
has to use the sold_to_contact&.work_email
methods to get to the same info. If all three classes respond to the same method name, a single object could be provided to the VoucherMailer and removes all the current complexity by calling the method names that are supported by all three classes.
Result
Remove complexity around the logic to find the email, name and company of the recipient as well as the log info in the VoucherMailer
.