PHP wrapper / Client SDK for jsonbox
$ composer require anper/jsonbox
use Anper\Jsonbox\Jsonbox;
$jsonbox = Jsonbox::factory('box-id');
Create
// Create a record
$response = $jsonbox->create(['name' => 'Arya Stark']);
// Create multiple records
$response = $jsonbox->create([
['name' => 'Daenerys Targaryen'],
['name' => 'Arya Stark'],
]);
// Create a collection
$response = $jsonbox->colletion('users')
->create(/* like one record or multiple records */);
Read
// Read a record
$response = $jsonbox->record('5d776a25fd6d3d6cb1d45c51')->read();
// Read a collection
$response = $jsonbox->collection('users')->read();
// Read all
$response = $jsonbox->read();
Filtering
$filter = new \Anper\Jsonbox\Filter();
$filter->equalTo('name', 'Arya Stark');
// Filter all
$response = $jsonbox->read($filter);
// Filter collection
$response = $jsonbox->collection('users')->read($filter);
Update
// Update a record
$response = $jsonbox->record('5d776a25fd6d3d6cb1d45c51')
->update(['name' => 'Arya Stark']);
// Update multiple records (async request for every record)
$response = $jsonbox->update([
'5d776b75fd6d3d6cb1d45c52' => ['name' => 'Daenerys Targaryen'],
'5d776b75fd6d3d6cb1d45c53' => ['name' => 'Arya Stark'],
]);
Delete
// Delete a record
$response = $jsonbox->record('5d776a25fd6d3d6cb1d45c51')->delete();
// Delete multiple records (async request for every record)
$response = $jsonbox->delete([
'5d776b75fd6d3d6cb1d45c52',
'5d776b75fd6d3d6cb1d45c53',
]);
// Delete by filter
$response = $jsonbox->delete($filter);
Protected Box
// An API-KEY should be a valid GUID/UUID
$protectedJsonbox = $jsonbox->withApiKey('API_KEY');
$ composer test
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.