Skip to content

Commit 04acd03

Browse files
test: add examples and tests for SMS and digital signature modules
1 parent 0ba4045 commit 04acd03

2 files changed

Lines changed: 91 additions & 47 deletions

File tree

readme.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ A questo punto, in base agli scopes indicati vengono creati i seguenti oggetti:
3838

3939
```php
4040
// Ogni oggetto verrá creato solo se disponibile nello scope.
41-
$openapi->ufficiopostale
42-
$openapi->comuni
43-
$openapi->imprese
44-
$openapi->visengine
45-
$openapi->marcheTemporali
46-
$openapi->geocoding
47-
$openapi->SMS
48-
$openapi->firmaDigitale
49-
$openapi->pecMassiva
41+
$openapi->ufficiopostale;
42+
$openapi->comuni;
43+
$openapi->imprese;
44+
$openapi->visengine;
45+
$openapi->marcheTemporali;
46+
$openapi->geocoding;
47+
$openapi->SMS;
48+
$openapi->firmaDigitale;
49+
$openapi->pecMassiva;
5050
```
5151
che possono essere usati al seguente modo:
5252

@@ -64,7 +64,7 @@ $scopes = [
6464
'GET:imprese.altravia.com/advance',
6565
];
6666

67-
$openapi = new OpenApi\OpenApi($scopes, 'my_username','my_api_key', 'production');
67+
$openapi = new OpenApi\OpenApi($scopes, 'my_username','my_api_key', 'test');
6868

6969
// Comuni: prendi informazioni sul cap 00132
7070
$cap = $openapi->comuni->getCitiesByCap('00132');
@@ -76,14 +76,24 @@ $impresa = $openapi->imprese->getByPartitaIva('12485671007');
7676
$track = $this->openapi->ufficiopostale->track('123456789');
7777
```
7878

79-
# Modulo ufficio postale
80-
## Creare raccomandata
79+
## Modulo ufficio postale
80+
### Creare raccomandata
8181

8282

83-
# Modulo visure
83+
## Modulo visure
84+
### Utilizzo
85+
Il modulo espone i seguenti metodi:
86+
* `sendRequest`
87+
* `getRequestByIdVisura`
88+
* `getRequestByData`
89+
* `getDocument`
90+
* `setRicerca`
8491

85-
# Modulo imprese
86-
## Utilizzo
92+
### `sendRequest($VisRequest)`
93+
94+
95+
## Modulo imprese
96+
### Utilizzo
8797
Il modulo imprese espone i seguenti metodi:
8898
* `getByPartitaIva`
8999
* `getClosed`
@@ -93,3 +103,4 @@ Il modulo imprese espone i seguenti metodi:
93103

94104
Per `getBySearch` e `getByPartitaIva` è richiesto accesso allo scope `/advance`
95105

106+
## Modulo SMS

tests/ClientTest.php

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use OpenApi\classes\utility\UfficioPostale\Objects\Recipient;
44
use OpenApi\classes\utility\UfficioPostale\Objects\Sender;
5+
use OpenApi\classes\utility\VisEngine\VisRequest;
56
use OpenApi\OpenApi;
67
use PHPUnit\Framework\TestCase;
78
use Symfony\Component\Dotenv\Dotenv;
@@ -26,20 +27,25 @@ public function __construct() {
2627

2728
// Dichiaro gli scopes necessari
2829
$this->scopes = [
29-
"GET:ws.ufficiopostale.com/telegrammi",
30+
"GET:ws.ufficiopostale.com/raccomandate",
3031
"GET:imprese.altravia.com/autocomplete",
31-
"GET:imprese.openapi.it/base",
32-
"GET:imprese.openapi.it/advance",
33-
"GET:imprese.openapi.it/pec",
34-
"GET:imprese.openapi.it/autocomplete",
35-
"GET:imprese.openapi.it/closed",
36-
"GET:imprese.openapi.it/gruppoiva",
32+
"GET:imprese.altravia.com/base",
33+
"GET:imprese.altravia.com/advance",
34+
"GET:imprese.altravia.com/pec",
35+
"GET:imprese.altravia.com/autocomplete",
36+
"GET:imprese.altravia.com/closed",
37+
"GET:imprese.altravia.com/gruppoiva",
3738
"GET:comuni.openapi.it/cap",
3839
"GET:comuni.openapi.it/istat",
3940
"GET:comuni.openapi.it/regioni",
4041
"GET:comuni.openapi.it/province",
4142
"GET:ws.ufficiopostale.com/tracking",
42-
"POST:geocoding.realgest.it/geocode"
43+
"POST:geocoding.realgest.it/geocode",
44+
"POST:ws.messaggisms.com/messages",
45+
"GET:ws.messaggisms.com/messages",
46+
"PUT:ws.messaggisms.com/messages",
47+
"GET:ws.firmadigitale.com/richiesta",
48+
"POST:ws.firmadigitale.com/richiesta",
4349
];
4450

4551
$this->openapi = new OpenApi($this->scopes, $this->username, $this->api_key, 'test');
@@ -56,36 +62,63 @@ public function testComuni() {
5662
$this->assertIsArray($cap);
5763
}
5864

65+
// public function testImprese() {
66+
// $impresa = $this->openapi->imprese->getByPartitaIva('00966950230');
67+
// $autocomplete = $this->openapi->imprese->getBySearch('*multiservizi*', 'RM');
68+
// $this->assertEquals($impresa->provincia, 'RM');
69+
// $this->assertIsArray($autocomplete);
70+
// }
71+
5972
// public function testGeocoding() {
6073
// // Prendi informazioni sul cap 00132
6174
// $cap = $this->openapi->geocoding->geocode('Via Cristoforo Colombo, Roma RM');
6275
// $this->assertIsArray($cap);
6376
// }
6477

65-
public function testUfficioPostale() {
66-
$track = $this->openapi->ufficiopostale->track($_ENV['TRACK_TEST']);
67-
$this->assertEquals(true, $track->success);
68-
var_dump($track);
69-
70-
$raccomandata = $this->openapi->ufficiopostale->createRaccomandata();
71-
var_dump($raccomandata);
72-
73-
$data = new stdClass();
74-
$sender = new Sender([
75-
'firstName' => 'John',
76-
'secondName' => 'Doe',
77-
'companyName' => 'example-spa',
78-
]);
79-
80-
$recipient = new Recipient([
81-
'firstName' => 'John',
82-
'secondName' => 'Doe',
83-
'companyName' => 'example-spa',
84-
]);
85-
86-
$data->sender = $sender;
87-
$data->recipient = $recipient;
78+
// public function testUfficioPostale() {
79+
// $track = $this->openapi->ufficiopostale->track($_ENV['TRACK_TEST']);
80+
// $this->assertEquals(true, $track->success);
81+
// var_dump($track);
82+
83+
// $raccomandata = $this->openapi->ufficiopostale->createRaccomandata();
84+
// var_dump($raccomandata);
85+
86+
// $data = new stdClass();
87+
// $sender = new Sender([
88+
// 'firstName' => 'John',
89+
// 'secondName' => 'Doe',
90+
// 'companyName' => 'example-spa',
91+
// ]);
92+
93+
// $recipient = new Recipient([
94+
// 'firstName' => 'John',
95+
// 'secondName' => 'Doe',
96+
// 'companyName' => 'example-spa',
97+
// ]);
98+
99+
// $data->sender = $sender;
100+
// $data->recipient = $recipient;
88101

89-
$raccomandata->creaRaccomandataByData();
102+
// $raccomandata->creaRaccomandataByData($data);
103+
// }
104+
105+
// public function testSms() {
106+
// $singleSms = $this->openapi->SMS->sendOne('prova', '3939989741', 'messaggio di prova', null, 1, null, true);
107+
// $this->assertIsArray($singleSms);
108+
// var_dump($singleSms);
109+
// }
110+
111+
// public function testVisura() {
112+
// // $visura = new VisRequest('eccbc87e4b5ce2fe28308fd9f2a7baf3');
113+
// $response = $this->openapi->visengine->getRequestByIdVisura('eccbc87e4b5ce2fe28308fd9f2a7baf3');
114+
// $this->assertNotEmpty($response);
115+
// var_dump($response);
116+
// }
117+
118+
public function testFirmaDigitale() {
119+
$data = json_decode(file_get_contents(__DIR__.'/esempio_firma.json'), true);
120+
$data['codice_prodotto'] = 'FIR';
121+
$response = $this->openapi->firmaDigitale->requestProduct($data);
122+
$this->assertNotEmpty($response);
90123
}
91124
}

0 commit comments

Comments
 (0)