package invoice.after;

/**
 * Emite facturas: les da formato y las envía. Depende de la interfaz Channel,
 * no de un canal concreto; el canal entra por el constructor.
 */
public class InvoiceService {

    private final InvoiceFormatter formatter;
    private final Channel channel;

    public InvoiceService(InvoiceFormatter formatter, Channel channel) {
        this.formatter = formatter;
        this.channel = channel;
    }

    public void issue(Invoice invoice) {
        channel.send(invoice.customer(), formatter.format(invoice));
    }
}
