Recycle Bin

Recycle Bin #

The Recycle Bin is a utility that manages the removal and restoration of Resources from an Entity. A Resource is recycled when it is deleted. While in the Recycle Bin, a Resource hidden from the other Resources and therefore unavailable for use. All Resource types in the microbooks system can be recycled and once in the Recycle Bin, they can either be restored or destroyed. Destroyed Resources are lost completely and cannot be restored.

Properties #

Direct Properties #

Being a derived Resource, the Recycle Bin does not have any Direct Properties as it is only indirectly created by the deletion of another Resource.

Indirect Properties #

PropertyTypeDefinition
UserDictionaryThe user who deleted/restored/destroyed the resource
ResourceDictionaryThe Resource that was deleted/restored/destroyed

Basics #

As mentioned above, this Resource is created when another is deleted.

Variations #

The Recycled Bin Resource has no Variations.

Operations #

Restore #

When a Resource has been deleted, it is unavailable for use by the rest of the system but still it exists in a dormant state. This endpoint reactivates the deleted Resource putting it back into circulation.

Request #

curl --location --request POST 'https://api.microbooks.io/books/v1/recycled-resource/restore/1'
import requests

url = "https://api.microbooks.io/books/v1/recycled-resource/restore/1"
body = {}
headers = {"Authorization": "Bearer <bearer_token>"}

response = requests.request("POST", url, headers=headers, json=body)

print(response.text)
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://api.microbooks.io/books/v1/recycled-resource/restore/1',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{}'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = null;
$request = new Request('POST', 'https://api.microbooks.io/books/v1/recycled-resource/restore/1', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/recycled-resource/restore/1");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = null;
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Response #

{
    "status": "success",
    "message": "Non Current Asset: Ms. Elisabeth Murphy Sr. restored successfully",
    "resource": {
        "uuid": "d66fc8fc-c073-41c9-bb36-2ae70f0130da",
        "id": 1,
        "entity_id": 1,
        "category_id": 1,
        "currency_id": 1,
        "code": 9,
        "name": "Ms. Elisabeth Murphy Sr.",
        "description": null,
        "type": "Non Current Asset",
        "is_closed": false,
        "category": {
            "uuid": "6460d9b7-dbdc-4ce3-a9fe-f51c2fd94cd8",
            "id": 1,
            "entity_id": 1,
            "name": "voluptatum",
            "type": "Non Current Asset"
        }
    }
}

Destroy #

Calling the destroy endpoint permanently removes a recycled Resource from the system.

Request #

curl --location --request POST 'https://api.microbooks.io/books/v1/recycled-resource/destroy/1'
import requests

url = "https://api.microbooks.io/books/v1/recycled-resource/destroy/1"
body = {}
headers = {"Authorization": "Bearer <bearer_token>"}

response = requests.request("POST", url, headers=headers, json=body)

print(response.text)
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://api.microbooks.io/books/v1/recycled-resource/destroy/1',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{}'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = null;
$request = new Request('POST', 'https://api.microbooks.io/books/v1/recycled-resource/destroy/1', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/recycled-resource/destroy/1");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = null;
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Response #

{
    "status": "success",
    "message": "Receivable: Verona Treutel destroyed successfully",
    "resource": {
        "uuid": "b40d6438-55f9-4f9d-839e-033da881a253",
        "id": 2,
        "entity_id": 1,
        "category_id": 2,
        "currency_id": 1,
        "code": 9,
        "name": "Verona Treutel",
        "description": null,
        "type": "Receivable",
        "is_closed": false,
        "category": {
            "uuid": "f2016651-d640-4a68-9af7-5f6bf1a37988",
            "id": 2,
            "entity_id": 1,
            "name": "et",
            "type": "Receivable"
        }
    }
}

Errors #

Below are the Errors that are returned by the Recycle Bin Resource.

Detail CodeNameDefinition
101Missing EntityThe Recycle Bin Resource manages the recycling, restoration and destruction of other Resources in use on the platform and therefore requires an Existing Entity Resource to scope the above actions