PHP code example of salvatoredeploy / cafeapi
1. Go to this page and download the library: Download salvatoredeploy/cafeapi library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
salvatoredeploy / cafeapi example snippets
alvatoreDeploy\CafeApi\Me;
$me = new Me(
"suaapi.url.com",
"[email protected] ",
"suasenha"
);
//me
$user = $me->me();
//update
$user->update([
"first_name" => "Robson",
"last_name" => "Leite",
"genre" => "male",
"datebirth" => "1980-01-02",
"document" => "888888888"
]);
//photo
$user->photo($_FILES["photo"]);
//test and result
if ($user->error()) {
$user->error(); //object
} else {
$user->response(); //object
}
alvatoreDeploy\CafeApi\Invoices;
$invoices = new Invoices(
"suaapi.url.com",
"[email protected] ",
"suasenha"
);
//index
$index = $invoices->index(null);
//index filter
$index = $invoices->index([
"wallet_id" => 23,
"type" => "fixed_income",
"status" => "paid",
"page" => 2
]);
//create
$invoices->create([
"wallet_id" => 23,
"category_id" => 3,
"description" => "Pagamento Cartão",
"type" => "expense",
"value" => "25000.20",
"due_at" => "2019-10-02",
"repeat_when" => "single",
"period" => "month",
"enrollments" => "1",
]);
//read
$invoices->read(91);
//update
$invoiceId = 91;
$invoices->update($invoiceId, [
"wallet_id" => 23,
"category_id" => 3,
"description" => "Pagamento Cartão",
"value" => "25000.20",
"due_day" => 25,
"status" => "paid"
]);
//delete
$invoices->delete(91);
//test and result
if ($invoices->error()) {
$invoices->error(); //object
} else {
$invoices->response(); //object
}