module IdCardPrinterService
    class PdfBatchProcessor

        def initialize(card_template, jasper_batch_id, layout)
            @card_template = card_template
            @jasper_batch_id = jasper_batch_id
            @layout = layout
        end

        def call
            # if @zip
            #     group_cards_pdf_array = []
            # else
            #     group_cards_pdf = CombinePDF.new
            # end
            url = IdCardPrinterService::JasperBatchUrlGenerator.new(@card_template, @jasper_batch_id, @layout).call
            puts url
            batch_pdf = IdCardPrinterService::JasperPdfGenerator.new(url).call


            # if @zip
            #     group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
            #         group_cards_pdf_array.each do |file|
            #             zio.put_next_entry(file[:name])
            #             zio.write(file[:data])
            #         end
            #     end
            # # else
            # #     todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
            # #     group_cards_pdf.save("tmp/#{@employer.name}_print_cards_#{todays_date}.pdf")
            # end

            batch_pdf
        end
    end
end