diff --git a/.gitattributes b/.gitattributes index 342564d..0c5aaa4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,6 @@ .gitattributes export-ignore .gitignore export-ignore +/appveyor.yml export-ignore /.travis.yml export-ignore /.scrutinizer.yml export-ignore /build export-ignore diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..305d846 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,64 @@ +build: false +clone_depth: 50 +platform: + - x64 +environment: + matrix: + - dependencies: lowest + php_version: 7.0 + - dependencies: highest + php_version: 7.0 + - dependencies: lowest + php_version: 7.1 + - dependencies: highest + php_version: 7.1 + + project_directory: c:\projects\slevomat-eet-client + composer_directory: c:\tools\composer + composer_executable: c:\tools\composer\composer.phar + php_archive_directory: c:\tools\php-archive + php_directory: c:\tools\php +matrix: + fast_finish: true +clone_folder: c:\projects\slevomat-eet-client +cache: + - c:\tools\composer + - c:\tools\php-archive + - '%LOCALAPPDATA%\Composer' +init: + - ps: $Env:PATH = $Env:php_directory + ';' + $Env:composer_directory + ';' + $Env:PATH + - ps: $Env:ANSICON = '121x90 (121x90)' +install: + # Download requested PHP version + - ps: If ((Test-Path $Env:php_archive_directory) -eq $False) { New-Item -Path $Env:php_archive_directory -ItemType 'directory' } + - ps: $requested_php_version = %{If ($Env:dependencies -eq 'lowest') { $Env:php_version + '.0' } Else { (((choco search php --exact --all-versions -r | Select-String -pattern $Env:php_version) -replace '[php|]', '') | %{ New-Object System.Version $_ } | Sort-Object | Select-Object -Last 1).ToString() }} + - ps: $php_version_url = %{If ($Env:dependencies -eq 'lowest') { 'http://windows.php.net/downloads/releases/archives/php-' + $requested_php_version + '-nts-Win32-VC14-' + $Env:platform + '.zip' } Else { 'http://windows.php.net/downloads/releases/php-' + $requested_php_version + '-nts-Win32-VC14-' + $Env:platform + '.zip' }} + - ps: $php_version_file = $Env:php_archive_directory + '\php-' + $requested_php_version + '.zip' + - ps: If ((Test-Path $php_version_file) -eq $False) { appveyor-retry appveyor DownloadFile $php_version_url -FileName $php_version_file } + + # Prepare PHP + - ps: New-Item -Path $Env:php_directory -ItemType 'directory' + - ps: cd $Env:php_directory + - ps: 7z x $php_version_file + - ps: Copy-Item php.ini-production -Destination php.init + - ps: Add-Content -Path php.ini -Value 'date.timezone="UTC"' + - ps: Add-Content -Path php.ini -Value 'extension_dir=ext' + - ps: Add-Content -Path php.ini -Value 'extension=php_curl.dll' + - ps: Add-Content -Path php.ini -Value 'extension=php_mbstring.dll' + - ps: Add-Content -Path php.ini -Value 'extension=php_openssl.dll' + - ps: Add-Content -Path php.ini -Value 'extension=php_soap.dll' + - ps: php --version + + # Prepare composer + - ps: If ((Test-Path $Env:composer_directory) -eq $False) { New-Item -Path $Env:composer_directory -ItemType 'directory' } + - ps: If ((Test-Path $Env:composer_executable) -eq $False) { appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar -FileName $Env:composer_executable } + - ps: Set-Content -Path ($Env:composer_directory + '\composer.bat') -Value ('@php ' + $Env:composer_executable + ' %*') + - composer self-update + + # Install dependencies + - ps: cd $Env:project_directory + - IF %dependencies%==lowest composer update --prefer-lowest --prefer-stable --no-interaction --no-progress + - IF %dependencies%==highest composer update --prefer-stable --no-interaction --no-progress +test_script: + - ps: cd $Env:project_directory + - vendor\bin\phing diff --git a/readme.md b/readme.md index 38d8d6f..e70c293 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,7 @@ # Client for EET - Elektronická evidence tržeb [![Build Status](https://img.shields.io/travis/slevomat/eet-client/master.svg?style=flat-square)](https://travis-ci.org/slevomat/eet-client) +[![Build status](https://img.shields.io/appveyor/ci/slevomat/eet-client/master.svg?style=flat-square)](https://ci.appveyor.com/project/slevomat/eet-client/branch/master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/slevomat/eet-client.svg?style=flat-square)](https://scrutinizer-ci.com/g/slevomat/eet-client/?branch=master) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/slevomat/eet-client.svg?style=flat-square)](https://scrutinizer-ci.com/g/slevomat/eet-client/?branch=master) [![Latest Stable Version](https://img.shields.io/packagist/v/slevomat/eet-client.svg?style=flat-square)](https://packagist.org/packages/slevomat/eet-client) @@ -27,14 +28,14 @@ $crypto = new CryptographyService('cesta k privátnímu klíči', 'cesta k veře $configuration = new Configuration( 'DIČ poplatníka', 'Identifikace provozovny ', - 'Identifikace pokladního zařízení', + 'Identifikace pokladního zařízení', EvidenceEnvironment::get(EvidenceEnvironment::PLAYGROUND), // nebo EvidenceEnvironment::get(EvidenceEnvironment::PRODUCTION) pro komunikaci s produkčním systémem false // zda zasílat účtenky v ověřovacím módu ); $client = new Client($crypto, $configuration, new GuzzleSoapClientDriver(new \GuzzleHttp\Client())); $receipt = new Receipt( - true, + true, 'CZ683555118', '0/6460/ZQ42', new \DateTimeImmutable('2016-11-01 00:30:12'), @@ -45,7 +46,7 @@ try { $response = $client->send($receipt); echo $response->getFik(); } catch (\SlevomatEET\FailedRequestException $e) { - echo $e->getRequest()->getPkpCode(); // if request fails you need to print the PKP and BKP codes to receipt + echo $e->getRequest()->getPkpCode(); // if request fails you need to print the PKP and BKP codes to receipt } catch (\SlevomatEET\InvalidResponseReceivedException $e) { echo $e->getResponse()->getRequest()->getPkpCode(); // on invalid response you need to print the PKP and BKP too } @@ -85,8 +86,8 @@ try { ### Client driver -Odeslání požadavku na servery EET neprobíhá přímo přes SoapClient integrovaný v PHP, ale pomocí rozhraní `SoapClientDriver`. Hlavním důvodem je -nemožnost nastavení timeoutu požadavků integrovaného SoapClienta. +Odeslání požadavku na servery EET neprobíhá přímo přes SoapClient integrovaný v PHP, ale pomocí rozhraní `SoapClientDriver`. Hlavním důvodem je +nemožnost nastavení timeoutu požadavků integrovaného SoapClienta. -Součástí knihovny je implentace rozhraní s pomocí [guzzlehttp/guzzle](https://packagist.org/packages/guzzlehttp/guzzle). Výchozí timeout této implementace +Součástí knihovny je implentace rozhraní s pomocí [guzzlehttp/guzzle](https://packagist.org/packages/guzzlehttp/guzzle). Výchozí timeout této implementace je 2.5 sekundy, nastavitelný parametrem konstruktoru.