Weak hands cannot be planted, meager skills have no foundation. Shallow wisdom is futile, how can one hope for a good name?扰扰从役倦，屑屑身事微。少壮轻年月，迟暮惜光辉。
<html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><?php

namespace Hostinger\Reach\Jobs;

use Hostinger\Reach\Api\Handlers\ReachApiHandler;
use Hostinger\Reach\Integrations\ImportManager;

class ImportJob extends AbstractBatchedJob {

    public const JOB_NAME = 'import';

    public ImportManager $import_manager;

    public function __construct( ActionScheduler $action_scheduler, ReachApiHandler $reach_api_handler, ImportManager $import_manager ) {
        parent::__construct( $action_scheduler, $reach_api_handler );
        $this->import_manager = $import_manager;
    }

    public function get_name(): string {
        return self::JOB_NAME;
    }

    protected function get_batch_size(): int {
        return 50;
    }

    protected function get_batch( int $batch_number, array $args ): array {
        $limit       = $this->get_batch_size();
        $integration = $args['integration'];
        $form_id     = $args['form_id'] ?? null;
        return $this->import_manager->get_contacts( $integration, $form_id, $limit, ( $batch_number - 1 ) * $limit );
    }

