PHP code example of nouvu / leeloo

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

    

nouvu / leeloo example snippets




new \PDO( ... ); # a tool for working with database (example)


/*
	https://github.com/MouseZver/Query-Storage-Bank
*/
$storage = new \Nouvu\Database\QueryStorageBank( $pdo );

$storage -> setEvent( 'leeloo_insert', static function ( $db, array $items ): void
{
	$stmt = $db -> prepare( 'INSERT INTO `leeloo_queue_cron` ( `method`, `data`, `response`, `priority` ) VALUES ( ?,?,?,? )' );
	
	foreach ( $items AS $data )
	{
		$stmt -> execute( $data );
	}
} );

$storage -> setEvent( 'leeloo_delete', static function ( $db, array $ids ): void
{
	$db -> query( sprintf ( 'DELETE FROM `leeloo_queue_cron` WHERE id IN ( %s )', implode ( ',', $ids ) ) );
} );

$storage -> setEvent( 'leeloo_update', static function ( $db, array $items ): void
{
	$stmt = $db -> prepare( 'UPDATE `leeloo_queue_cron` SET `again` = `again` + 1, `response` = ? WHERE `id` = ?' );
	
	foreach ( $items AS $data )
	{
		$stmt -> execute( $data );
	}
} );



$config = [
	'token' => '********************************************',
	'tags' => [
		'Happy_Event_7June2021' => '******ad20e82b2644******',
		/* ... name => hash */
	],
	'templates' => [
		'after_register' => '******174e0fbb000d******',
		/* ... name => hash */
	],
	'order' => [
		'paymentCreditsId' => '******c02eb3c7000d******',
		'offer' => [
			'online_trading_offer'	=> '******eb14c1880011******',
			/* ... name => hash */
		],
	]
];

/*
	@leeloo<array> - array containing authorization data and other tags, templates, etc.
	@storage<Nouvu\Database\QueryStorageBank>
	@send<bool> - send directly(true) or to a queue(false)( recommended ).
*/
$leeloo = new \Nouvu\Leeloo\Api( $config, $storage, true );

/*
    @person_id<string> - leeloo person_id people
    @tag<string> - name tag ( no hash )
*/
$leeloo -> addTagPeople( string $person_id, string $tag ): \Nouvu\Leeloo\Api

/*
    @person_id - leeloo person_id people
    @tag - name tag ( no hash )
*/
$leeloo -> removeTagPeople( string $person_id, string $tag ): \Nouvu\Leeloo\Api

/*
    @person_id - leeloo $account_id
    @template - name template ( no hash )
*/
$leeloo -> sendTemplate( string $account_id, string $template ): void

/*
    @account_id - leeloo account_id
    @message - message text
    @sending - send directly(true) or to a queue(false)
*/
$leeloo -> sendMessage( string $account_id, string $message, bool $sending = true ): void

/*
    @account_id - leeloo account_id
    @message - message text
    @sending - send directly(true) or to a queue(false)
*/
$leeloo_order_id = $leeloo -> orderPending( string $email, string $phone, string $personId, string $offer ): ?string

/*
    @leeloo_order_id - leeloo order id
    @price - example: '100' (actual price that you receive from account)
    @currency - example: 'RUB'
    @comments - userComments example: 'actual date dont match'
*/
$leeloo -> orderCompleted( string $leeloo_order_id, int | float $price, string $currency = 'USD', string $comments = 'card' ): void

/*
    @leeloo_order_id - leeloo order id
    @price - example: '100' (actual price that you receive from account)
    @currency - example: 'RUB'
    @comments - userComments example: 'actual date dont match'
*/
$leeloo -> orderFailed( string $leeloo_order_id, int | float $price, string $currency = 'USD', string $comments = 'card' ): void