Source Parsers

If you're pulling information in from an API, you may need to provide special headers to your API requests or use a certain part of the response body as your 'feed items'. This can't be done with the built-in 'source parsers', however you can build your own, extending on YumYum's built-in code.

Source Parsers look like so:

3namespace App;
5use DoubleThreeDigital\YumYum\Feeds\Sources\JSON;
6use Illuminate\Support\Collection;
7use Illuminate\Support\Facades\Http;
9class CustomJsonSource extends JSON
11 public function handle(): Collection
12 {
13 $response = Http::get($this->source['url']);
15 return collect($response->json()['data']); // Here we're grabbing 'feed items' from inside the response's `data` array.
16 }

The above example extends on the built-in JSON source parser.

The handle method is where all the important code should go. From it, you should return a collection of 'feed items' which will one by one be sent to Destination Transformers before being saved.