Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

perevoshchikov/jsonbox

Repository files navigation

Anper\Jsonbox

Software License Latest Version on Packagist Build Status

PHP wrapper / Client SDK for jsonbox

Install

$ composer require anper/jsonbox

Usage

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');

Test

$ composer test

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

About

PHP wrapper / Client SDK for https://jsonbox.io

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages