1. Go to this page and download the library: Download nusii/nusii-php 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/ */
nusii / nusii-php example snippets
use Nusii\Nusii;
$nusii = new Nusii('your-api-key');
// List your clients
$clients = $nusii->clients()->list();
foreach ($clients as $client) {
echo $client['name'] . "\n";
}
$nusii = new Nusii('your-api-key', baseUrl: 'http://localhost:3000');
// List all sections
$sections = $nusii->sections()->list();
// List sections for a specific proposal
$sections = $nusii->sections()->list(proposalId: 456);
// List sections for a specific template
$sections = $nusii->sections()->list(templateId: 789);
// Include line items in the response
$sections = $nusii->sections()->list(proposalId: 456, '
// List line items for a section
$items = $nusii->lineItems()->listBySection(sectionId: 10);
// Get a single line item
$item = $nusii->lineItems()->get(50);
// Create a line item for a section
$item = $nusii->lineItems()->createForSection(sectionId: 10, attributes: [
'name' => 'Design Work',
'quantity' => 10,
'amount' => 7500, // in cents
'cost_type' => 'per', // "fixed", "recurring", "per" or "range"
'per_type' => 'hour',
'position' => 1,
]);
// Create a price range line item ("$5,000 – $8,000").
// "amount" is the low end and "maximum_amount" the high end, both in cents.
// Requires the price ranges feature to be enabled for your account.
$item = $nusii->lineItems()->createForSection(sectionId: 10, attributes: [
'name' => 'Discovery & UX research',
'cost_type' => 'range',
'amount' => 500000,
'maximum_amount' => 800000,
]);
echo $item['maximum_amount_in_cents']; // 800000
echo $item['maximum_amount_formatted']; // "$8,000.00"
// Update a line item
$item = $nusii->lineItems()->update(50, [
'name' => 'Updated Design Work',
'quantity' => 20,
]);
// Delete a line item
$nusii->lineItems()->delete(50);
// List your account's templates
$templates = $nusii->templates()->list();
// List Nusii's public templates instead
$publicTemplates = $nusii->templates()->list(publicTemplates: true);
// Get a single template
$template = $nusii->templates()->get(5);
echo $template['name']; // "Web Project Template"
// List all activities
$activities = $nusii->proposalActivities()->list();
// Filter by proposal
$activities = $nusii->proposalActivities()->list(proposalId: 456);
// Filter by client
$activities = $nusii->proposalActivities()->list(clientId: 123);
// Get a single activity
$activity = $nusii->proposalActivities()->get(1);
echo $activity['activity_type']; // "viewed", "accepted", "rejected"
echo $activity['proposal_title']; // "Website Redesign"
echo $activity['client_email']; // "[email protected]"
// List users on the account
$users = $nusii->users()->list();
foreach ($users as $user) {
echo $user['email'];
echo $user['name'];
}
// List available themes
$themes = $nusii->themes()->list();
foreach ($themes as $theme) {
echo $theme['id'];
echo $theme['name']; // "Classic", "Modern", etc.
}
// List webhook endpoints
$webhooks = $nusii->webhookEndpoints()->list();
// Get a single webhook endpoint
$webhook = $nusii->webhookEndpoints()->get(1);
// Create a webhook endpoint
$webhook = $nusii->webhookEndpoints()->create([
'target_url' => 'https://example.com/webhooks/nusii',
'events' => [
'proposal_created',
'proposal_accepted',
'proposal_rejected',
'proposal_sent',
],
]);
// Delete a webhook endpoint
$nusii->webhookEndpoints()->delete(1);
$page = 1;
do {
$response = $nusii->clients()->list(page: $page, perPage: 50);
foreach ($response as $client) {
// Process each client
}
$page++;
} while ($response->hasNextPage());
use Nusii\Exceptions\AuthenticationException;
use Nusii\Exceptions\NotFoundException;
use Nusii\Exceptions\ValidationException;
use Nusii\Exceptions\RateLimitException;
use Nusii\Exceptions\ServerException;
use Nusii\Exceptions\NusiiException;
try {
$client = $nusii->clients()->get(99999);
} catch (AuthenticationException $e) {
// 401 - Invalid API key
echo $e->getMessage();
} catch (NotFoundException $e) {
// 404 - Resource not found
echo $e->getMessage();
} catch (ValidationException $e) {
// 400, 403, 422 - Validation or permission errors
echo $e->getMessage();
echo $e->getCode(); // HTTP status code
print_r($e->responseBody); // Raw response body
} catch (RateLimitException $e) {
// 429 - Rate limit exceeded (100 requests per 30 seconds)
echo $e->retryAfter; // Seconds to wait before retrying
} catch (ServerException $e) {
// 500, 503 - Server errors
echo $e->getMessage();
} catch (NusiiException $e) {
// Catch-all for any other API errors
echo $e->getMessage();
}