You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Abstract client-side PHP implementation of the [json api specification](http://jsonapi.org/format/), based on the [PSR-7 HTTP message interface](http://www.php-fig.org/psr/psr-7/).
5
+
Abstract client-side PHP implementation of the [json api specification](http://jsonapi.org/format/).
6
6
7
7
## Installation
8
8
@@ -27,62 +27,24 @@ If needed you can also implement the interface by yourself to use any HTTP clien
27
27
## Usage
28
28
First you should read the docs at [enm/json-api-common](https://eosnewmedia.github.io/JSON-API-Common/) where all basic structures are defined.
29
29
30
-
Your API client for sending requests to a JSON API and get validated responses as JSON API documents is an instance of
31
-
`Enm\JsonApi\Client\JsonApiClient`, which requires a HTTP client (`Enm\JsonApi\HttpClient\HttpClientInterface`) to execute
| createJsonApiRequest(string $type, string $id = '') | JsonApiRequestInterface | Create a new JSON API request object, needed for a delete request. |
37
-
| createFetchRequest(string $type, string $id = '') | FetchRequestInterface | Create a new fetch request object, needed for fetch requests. |
38
-
| createSaveSingleResourceRequest(ResourceInterface $resource, bool $patch = false) | SaveRequestInterface | Create a new save request object, needed for create or patch requests. |
39
-
| fetch(FetchRequestInterface $request) | DocumentInterface | Execute a fetch request for one or many resources and transform the server response into a JSON API document. |
40
-
| save(SaveRequestInterface $request) | DocumentInterface | Execute a save (create or patch) request and transform the server response into a JSON API document. |
41
-
| delete(JsonApiRequestInterface $request) | DocumentInterface | Execute a delete request and transform the server response into a JSON API document. |
42
-
| fetchRelationship(string $relationship, FetchRequestInterface $request, bool $onlyIdentifiers = false) | DocumentInterface | Execute a fetch request for a relationship and transform the server response into a JSON API document. |
43
-
| follow(LinkInterface $link, array $headers = []) | DocumentInterface | Execute a fetch request which is defined by a JSON API link object and transform the server response into a JSON API document. |
44
-
30
+
Your API client is an instance of `Enm\JsonApi\Client\JsonApiClient`, which requires a HTTP client (`Enm\JsonApi\HttpClient\HttpClientInterface`) to execute requests.
45
31
46
32
```php
47
-
// configure http client and api endpoint
48
-
$guzzle = new Client(); // if you are using guzzle htttp
49
-
$baseUri = 'http://example.com/api' // the base uri for all api requests
50
33
51
-
// create the api client
52
-
$apiClient = new JsonApiClient($baseUri, new GuzzleAdapter($guzzle));
34
+
$client = new JsonApiClient(
35
+
'http://example.com/api',
36
+
new GuzzleAdapter(new Client()), // with guzzle in this example...
37
+
new Serializer(),
38
+
new Deserializer()
39
+
);
53
40
54
-
// create a fetch request to retrieve a single resource
0 commit comments