module IdCardPrinterService
    class SamplePdfProcessor

        def initialize(employer)
            @employer = employer
            @card_setup = @employer.id_card_setup
        end

        def call
            group_cards_pdf = CombinePDF.new
            IdCard::PrintData.where(employer_name: @card_setup.print_name).each do |card|
                url = IdCardPrinterService::SampleJasperUrlGenerator.new(@employer, card.sample_key, card.sample_plan_title).call
                puts url
                card_pdf = IdCardPrinterService::JasperPdfGenerator.new(url).call
                
                group_cards_pdf << card_pdf
            end

            # todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
            # group_cards_pdf.save("tmp/#{@employer.name}_print_cards_#{todays_date}.pdf")

            group_cards_pdf
        end
    end
end