PHP code example of networkrailbusinesssystems / bravo-api

1. Go to this page and download the library: Download networkrailbusinesssystems/bravo-api 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/ */

    

networkrailbusinesssystems / bravo-api example snippets


use NetworkRailBusinessSystems\BravoApi\BravoApi;
use NetworkRailBusinessSystems\BravoApi\RequestObjects\Project;

$bravoApi = new BravoApi();

$project = new Project();
$project->tender->title = 'My Project Title';

$response = $bravoApi->createProject($project);

echo $response->returnCode; // 0
echo $response->tenderCode; // 'tender_1000111
echo $response->tenderReferenceCode; // 1000111

$bravoApi = new BravoApi();

$project = new Project();
$project->tender->title = 'My Project Title';
$project->tender->sourceTemplateReferenceCode = 'project_1234';

$response = $bravoApi->createProject(
    project: $project, 
    fromTemplate: true
);

$bravoApi = new BravoApi();

$project = new Project();
$project->tender->title = 'My Project Title';

$response = $bravoApi->createProject(
    project: $project, 
    fromTemplate: false
);

use NetworkRailBusinessSystems\BravoApi\RequestObjects\User;
use \NetworkRailBusinessSystems\BravoApi\RequestObjects\Project;

$user = new User();

// Set the login as the user's email address
$user->login = '[email protected]';

// Or set the Bravo id and name if known
$user->id = '1234';
$user->name = 'Joe Bloggs';

$project = new Project();
$project->tender->projectOwner = $user;

use \NetworkRailBusinessSystems\BravoApi\RequestObjects\Category;
use \NetworkRailBusinessSystems\BravoApi\RequestObjects\Project;

$category = new Category();
$category->categoryName = 'A Test Category';
$category->categoryCode = '01.01.01.99';

$project = new Project();
$project->categoryList->category[] = $category;

use NetworkRailBusinessSystems\BravoApi\BravoApi;
use NetworkRailBusinessSystems\BravoApi\RequestObjects\Project;

$bravoApi = new BravoApi();

$project = new Project();

$project->tender->title = 'My Project Title';

$response = $bravoApi->updateProject($project);

echo $response->returnCode; // 0
echo $response->tenderCode; // 'tender_1000111
echo $response->tenderReferenceCode; // 1000111

use NetworkRailBusinessSystems\BravoApi\BravoApi;

$bravoApi = new BravoApi();
$response = $bravoApi->searchProjects('title==test');

echo $response->projectList->project->first()->tender->title; // Test

use NetworkRailBusinessSystems\BravoApi\BravoApi;

$bravoApi = new BravoApi();
$response = $bravoApi->getProject('tender_10001');

echo $response->projectList->project->first()->tender->title; // Test