Update
This commit is contained in:
77
src/ShotJobBuilder.php
Normal file
77
src/ShotJobBuilder.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Crawlshot\Laravel;
|
||||
|
||||
class ShotJobBuilder
|
||||
{
|
||||
protected CrawlshotClient $client;
|
||||
protected string $url;
|
||||
protected array $options = [];
|
||||
|
||||
public function __construct(CrawlshotClient $client, string $url)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function webhookUrl(string $webhookUrl): self
|
||||
{
|
||||
$this->options['webhook_url'] = $webhookUrl;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function webhookEventsFilter(array $events): self
|
||||
{
|
||||
$this->options['webhook_events_filter'] = $events;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function viewportSize(int $width, int $height): self
|
||||
{
|
||||
$this->options['viewport_width'] = $width;
|
||||
$this->options['viewport_height'] = $height;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function quality(int $quality): self
|
||||
{
|
||||
$this->options['quality'] = $quality;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function timeout(int $seconds): self
|
||||
{
|
||||
$this->options['timeout'] = $seconds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function delay(int $milliseconds): self
|
||||
{
|
||||
$this->options['delay'] = $milliseconds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function blockAds(bool $block = true): self
|
||||
{
|
||||
$this->options['block_ads'] = $block;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function blockCookieBanners(bool $block = true): self
|
||||
{
|
||||
$this->options['block_cookie_banners'] = $block;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function blockTrackers(bool $block = true): self
|
||||
{
|
||||
$this->options['block_trackers'] = $block;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function create(): ShotResponse
|
||||
{
|
||||
$data = $this->client->createShot($this->url, $this->options);
|
||||
return new ShotResponse($data, $this->client);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user