Download the PHP package incraigulous/rest-repositories without Composer
On this page you can find all versions of the php package incraigulous/rest-repositories. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download incraigulous/rest-repositories
More information about incraigulous/rest-repositories
Files in incraigulous/rest-repositories
Package rest-repositories
Short Description Fetch data from any rest API with a common interface.
License MIT
Informations about the package rest-repositories
Rest Repositories
Fetch data from any rest API with a common interface. Api results are returned wrapped in easy-to-work-with, fluent collection and object wrappers.
In a nutshell
You should be able to fetch data from any webservice and then access it using the following API:
or
This keeps you from having to create a separate mental map for each web service you work with.
Repositories
It's the job of the repository to abstract working with your webservice to a common interface. Extend Incraigulous\RestRepositories\Single
, Incraigulous\RestRepositories\Listing
or Incraigulous\RestRepositories\Resource
for minimal setup.
Resources
A resource is for API resources with full read/write capability. The resource object has the following methods:
To create a new resource extend Incraigulous\RestRepositories\Resource
:
For example:
Listings
A listing is for API resources with full read only capability. The resource object has the following methods:
To create a new listing extend Incraigulous\RestRepositories\Listing
:
Singles
A single is for API resources for a single listing endpoint. The resource object has only the get
method.:
To create a new single extend Incraigulous\RestRepositories\Single
:
Creating a base repository for a webservice
Creating a repository
Getting the original data
Responses are wrapped in Collection and Object wrappers by default and data keys are stripped out. To access response meta data like pagination or links, you can retrieve the original object like so:
SDKs
It's the job of an SDK class to make requests to a webservice. SDKs should implement Incraigulous\RestRepositories\Contracts\SdkInterface
. To make this easy, a base Incraigulous\RestRepositories\Sdks\HttpSdk
class is provided.
Using the HttpSdk class on the fly
Without authentication
With authentication
Even Better: Creating your own SDK class
Without authentication
With authentication
Testing
All versions of rest-repositories with dependencies
schulzefelix/laravel-data-transfer-object Version ^1.0
illuminate/support Version >=5.5.0
guzzlehttp/guzzle Version ^7.4