Skip to content

Commit 8f4cf7a

Browse files
authored
Merge pull request #34 from Spoje-NET/33-dry-run-a-sync
#33 - Dry Run suport for Sync
2 parents 382c3b6 + b9a1bac commit 8f4cf7a

File tree

5 files changed

+439
-209
lines changed

5 files changed

+439
-209
lines changed

.vscode/launch.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
// Pro informace o možných atributech použijte technologii IntelliSense.
3+
// Umístěním ukazatele myši zobrazíte popisy existujících atributů.
4+
// Další informace najdete tady: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Debug DryRun example",
9+
"type": "php",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/Examples/DryRun.php",
12+
"cwd": "${fileDirname}",
13+
"externalConsole": false,
14+
"port": 9003
15+
},
16+
{
17+
"name": "Launch built-in server and debug",
18+
"type": "php",
19+
"request": "launch",
20+
"runtimeArgs": [
21+
"-S",
22+
"localhost:8000",
23+
"-t",
24+
"."
25+
],
26+
"port": 9003,
27+
"serverReadyAction": {
28+
"action": "openExternally"
29+
}
30+
},
31+
{
32+
"name": "Debug current script in console",
33+
"type": "php",
34+
"request": "launch",
35+
"program": "${file}",
36+
"cwd": "${fileDirname}",
37+
"externalConsole": false,
38+
"port": 9003
39+
},
40+
{
41+
"name": "Listen for Xdebug",
42+
"type": "php",
43+
"request": "launch",
44+
"port": 9003
45+
},
46+
47+
]
48+
}

Examples/DryRun.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,36 @@
44
* AbraFlexi - Example how to dry-run request
55
*
66
* @author Vítězslav Dvořák <[email protected]>
7-
* @copyright (G) 2018 Vitex Software
7+
* @copyright (G) 2018-2023 Vitex Software
88
*/
99

1010
namespace Example\AbraFlexi;
1111

1212
include_once './config.php';
13-
include_once '../vendor/autoload.php';
1413

14+
/**
15+
* Instance of AbraFlexi Invoice in dry-run mode with random code
16+
*/
1517

16-
$invoice = new \AbraFlexi\FakturaVydana();
18+
$invoice = new \AbraFlexi\FakturaVydana([
19+
'kod'=>'DRY_RUN_TEST',
20+
'typDokl' => 'code:FAKTURA',
21+
'poznam' => 'Test ' . time(),
22+
'varSym' => time()], ['dry-run' => true]);
1723

18-
$invoice->defaultUrlParams['dry-run'] = 'true';
24+
/**
25+
* Save invoice to AbraFlexi
26+
*/
27+
try {
28+
$resultInsert = $invoice->insertToAbraFlexi();
29+
} catch (\AbraFlexi\Exception $exc) {
30+
echo $exc->getMessage();
31+
//For example we can get here: "AbraFlexi\FakturaVydana: Pole 'Variabilní symbol' musí být vyplněno. [DRY_RUN_TEST]"
32+
}
1933

20-
$resultHere = $invoice->insertToFlexiBee(['typDokl' => 'code:FAKTURA']);
34+
/**
35+
* Save to AbraFlexi and load result
36+
*/
37+
$resultSync = $invoice->sync();
2138

22-
echo json_encode($resultHere, JSON_PRETTY_PRINT);;
39+
echo $resultSync ? 'OK' : 'Failed';

0 commit comments

Comments
 (0)