PHP code example of dartui / ewus

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

    

dartui / ewus example snippets


use Dartui\Ewus\Facade as Ewus;

class Foo {
	public function pesel() {
		// 1st param (int)      patient PESEL
		// 2nd param (int|bool) cache duration (in hours)
		// 3rd param (bool)     force request to eWUŚ (even if 2nd param is set to non-false value)
		$pesel = Ewus::pesel( '00000000000', 6 );
		
		if ( $pesel->hasError() ) {
			// do something with $pesel->getError()
		} elseif ( $pesel->hasInsurance() ) {
			$first_name   = $pesel->getFirstName();
			$last_name    = $pesel->getLastName();
			$operation_id = $pesel->getOperationID();
		}
	}

	// new password will be automatically stored in .ewus file
	public function password() {
		$new_password = 'secret';

		if ( Ewus::password( $new_password ) ) {
			echo 'Success!';
		} else {
			echo 'Error';
		}
	}
}

Dartui\Ewus\ServiceProvider::class
shell
php artisan vendor:publish --provider=Dartui\\Ewus\\ServiceProvider