Apr 18, 2019
0
Level 2
Create a custom API wrapper
This is not directly related to Laravel but I'm going to use in a Laravel application.
I need to create a wrapper to an API and I wanted to create something similar to Eloquent.
For example, this API has an endpoint called plans, I wanted to create a wrapper to be something like Laravel models and Eloquent works:
$plan = new Plan;
$plan->...;
$plan->save(); // it would call the post in the endpoint
// or ...
Plan::create([]);
Plan::get('pl-299541'); // it would call get in the endpoint
I want to use Guzzle to make the requests easier.
I was wondering, how can I make something (chaining, static calls, etc) like this (as Laravel does with Eloquent)?
Thank you.
Please or to participate in this conversation.