<?php

namespace App\Helpers\FirstParty\DFS;

class DFSOnPage
{
    // https://docs.dataforseo.com/v3/backlinks/id_list/?bash
    public static function listId($from_days, $to_days = 0, $limit = 1000, $offset = 0)
    {

        $query = [
            'datetime_from' => now()->subDays($from_days)->format('Y-m-d H:i:s P'),
            'datetime_to' => now()->subDays($to_days)->format('Y-m-d H:i:s P'),
        ];

        if ($limit != 1000) {
            $query['limit'] = $limit;
        }
        if ($offset != 0) {
            $query['offset'] = $offset;
        }

        $response = DFSCommon::apiCall('POST', 'on_page/id_list', $query);

        return $response;
    }

    // https://docs.dataforseo.com/v3/on_page/task_post/
    public static function taskPost($target, $max_crawl_pages = 1)
    {

        $query = [
            'target' => $target,
            'max_crawl_pages' => $max_crawl_pages,
        ];

        $response = DFSCommon::apiCall('POST', 'on_page/task_post', $query);

        return $response;
    }
}
