Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bigoen/api-bridge
Bridges for api projects.
https://github.com/bigoen/api-bridge
api api-bridge http-client json jsonld xml
Last synced: 2 days ago
JSON representation
Bridges for api projects.
- Host: GitHub
- URL: https://github.com/bigoen/api-bridge
- Owner: bigoen
- License: mit
- Created: 2020-09-05T15:40:19.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T12:49:38.000Z (9 months ago)
- Last Synced: 2024-11-08T04:11:08.012Z (7 days ago)
- Topics: api, api-bridge, http-client, json, jsonld, xml
- Language: PHP
- Homepage:
- Size: 48.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Api Bridge
==
Install:
```
composer require bigoen/api-bridge
```SimpleClient
==
Create model:
```php
setBaseUrl("http://example.com")
->setClass(Example::class)
->setThrowClass(Error:class)
->setOptions([
// Set http client request options.
]);// all objects.
$client->setPath("/api/examples")->getAll();// get object with id.
$client->setPath("/api/examples/{id}")->setId(1)->get();// post object.
$model = new Example();
$model->name = 'Test';
$model->email = '[email protected]';
$postModel = $client->setPath("/api/examples")->post($model);// put object.
$model = $client->setPath("/api/examples/{id}")->setId(1)->get();
$model->name = 'New Name';
$model = $client->setPath("/api/examples/{id}")->put($model);// delete object.
$isDelete = $client->setPath("/api/examples/{id}")->setId(1)->delete();
```JsonldClient
==
Create model:
```php
setBaseUrl("http://example.com")
->setClass(Example::class)
->setOptions([
// Set http client request options.
]);// all objects.
$pageOne = $client->setPath("/api/examples")->getAll();
// get next page objects.
$pageTwo = $client->setPath($pageOne->nextPagePath)->getAll();// get object with id.
$client->setPath("/api/examples/{id}")->setId(1)->get();// post object.
$model = new Example();
$model->name = 'Test';
$model->email = '[email protected]';
$postModel = $client->setPath("/api/examples")->post($model);// put object.
$model = $client->setPath("/api/examples/{id}")->setId(1)->get();
$model->name = 'New Name';
$model = $client->setPath("/api/examples/{id}")->put($model);// delete object.
$isDelete = $client->setPath("/api/examples/{id}")->setId(1)->delete();
```Convert api values in tree. Details: https://github.com/bigoen/api-bridge-converter