Skip to content

Commit d08bb16

Browse files
- Bugfixing on API Ufficiopostale Raccomandata, PecMassiva, VisEngine
- API UfficioPostale: Posta Ordionaria, Posta Prioritaria, Telegramma - API Catasto
1 parent 6149da6 commit d08bb16

17 files changed

Lines changed: 1482 additions & 196 deletions

src/OpenApi.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ private function getListaModuli(){
114114

115115
$moduli['pec.openapi.it'] = "\\OpenApi\\classes\\Pec";
116116
$nomi['pec.openapi.it'] = "PEC";
117+
118+
$moduli['catasto.openapi.it'] = "\\OpenApi\\classes\\Catasto";
119+
$nomi['catasto.openapi.it'] = "catasto";
120+
117121
$moduli['ws.firmadigitale.com'] = "\\OpenApi\\classes\\FirmaDigitale";
118122
$nomi['ws.firmadigitale.com'] = "firmaDigitale";
119123
return array($moduli,$nomi);

src/classes/Catasto.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
namespace OpenApi\classes;
3+
class Catasto extends OpenApiBase {
4+
5+
/**
6+
* @param string $token Il token da utilizzare per il collegamento
7+
* @param array $scopes Array con la lista degli scope per cui il token è abilitato
8+
* @param object $cache Classe che gestisce la cahce, deve essere una classe che estende {@see OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
9+
*/
10+
function __construct(string $token, array $scopes, object $cache, string $prefix){
11+
parent::__construct($token, $scopes, $cache, $prefix);
12+
$this->basePath = "https://catasto.openapi.it";
13+
}
14+
15+
16+
function ufficiCatastali($ttl = 86400){
17+
$data = $this->connect("territorio", "GET", [], $ttl);
18+
return $data->data;
19+
}
20+
21+
function getComuni($provincia, $ttl = 86400){
22+
$data = $this->connect("territorio/$provincia", "GET", [], $ttl);
23+
return $data->data;
24+
}
25+
26+
function elencoImmobili($tipo_catasto, $provincia,$comune,$sezione, $foglio,$particella, $callback){
27+
$param = [
28+
"tipo_catasto" => $tipo_catasto,
29+
"provincia" => trim($provincia),
30+
"comune" => $comune,
31+
"sezione" => $sezione,
32+
"foglio" => $foglio,
33+
"particella" => $particella,
34+
35+
];
36+
if($callback != NULL){
37+
$param['callback'] = $callback;
38+
}
39+
$data = $this->connect("richiesta/elenco_immobili", "POST", $param);
40+
return $data->data;
41+
}
42+
43+
function getComune($provincia, $comune, $ttl = 86400){
44+
$comune = urlencode($comune);
45+
$data = $this->connect("territorio/$provincia/$comune", "GET", [], $ttl);
46+
return $data->data;
47+
}
48+
function prospettoCatastale($tipo_catasto, $provincia,$comune,$sezione, $foglio,$particella,$subalterno, $callback=NULL){
49+
$param = [
50+
"tipo_catasto" => $tipo_catasto,
51+
"provincia" => trim($provincia),
52+
"comune" => $comune,
53+
"sezione" => $sezione,
54+
"foglio" => $foglio,
55+
"particella" => $particella,
56+
"subalterno" => $subalterno,
57+
];
58+
if($callback != NULL){
59+
$param['callback'] = $callback;
60+
}
61+
$data = $this->connect("richiesta/prospetto_catastale", "POST", $param);
62+
return $data->data;
63+
}
64+
65+
function ricercaPersona($tipo_catasto,$cf_piva,$provincia,$callback = NULL){
66+
$param = [
67+
"tipo_catasto" => $tipo_catasto,
68+
"cf_piva" => trim($cf_piva),
69+
"provincia" => $provincia,
70+
];
71+
//var_dump($param);exit;
72+
if($callback != NULL){
73+
$param['callback'] = $callback;
74+
}
75+
$data = $this->connect("richiesta/ricerca_persona", "POST", $param);
76+
return $data->data;
77+
}
78+
79+
function ricercaNazionale($tipo_catasto,$cf_piva,$callback= NULL){
80+
$param = [
81+
"tipo_catasto" => $tipo_catasto,
82+
"cf_piva" => trim($cf_piva)
83+
];
84+
//var_dump($param);exit;
85+
if($callback != NULL){
86+
$param['callback'] = $callback;
87+
}
88+
$data = $this->connect("richiesta/ricerca_nazionale", "POST", $param);
89+
return $data->data;
90+
}
91+
92+
93+
94+
95+
}

src/classes/ImpreseOpenapi.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
1313
$this->basePath = "https://imprese.openapi.it";
1414
}
1515

16+
function getFormaGiuridica($codice, $ttr=86400){
17+
$codice = trim($codice);
18+
try{
19+
$data = $this->connect("forma_giuridica/$codice", "GET", [], $ttr);
20+
return $data->data;
21+
}catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
22+
23+
if($e->getHTTPCode() == 404){
24+
return null;
25+
}
26+
throw $e;
27+
28+
29+
exit;
30+
}
31+
}
32+
1633
/**
1734
*
1835
* Consente di recuperare i dati di una azienda a partire dalla partita IVA

src/classes/PecMassiva.php

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
<?php
2-
namespace OpenApi\classes;
3-
class PecMassiva extends OpenApiBase {
4-
5-
private string $username;
6-
private string $password;
7-
private bool $inizialized;
8-
9-
10-
11-
/**
12-
* @param string $token Il token da utilizzare per il collegamento
13-
* @param array $scopes Array con la lista degli scope per cui il token è abilitato
14-
* @param object $cache Classe che gestisce la cahce, deve essere una classe che estende {@see OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
15-
*/
16-
function __construct(string $token, array $scopes, object $cache, string $prefix){
17-
parent::__construct($token, $scopes, $cache, $prefix);
18-
$this->basePath = "https://ws.pecmassiva.com";
19-
$this->inizialized = FALSE;
20-
21-
}
22-
23-
function initialize(string $username, string $password){
24-
$this->username = $username;
25-
$this->password = $password;
26-
$this->inizialized = TRUE;
27-
}
28-
29-
function getStatus($messageId){
30-
if(!$this->inizialized){
31-
throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
32-
}
33-
34-
35-
try{
36-
$header[] = 'x-username: '.$this->username;
37-
$header[] = 'x-password: '.$this->password;
38-
return $this->connect("send/$messageId","GET",[],0,false,$header);
39-
40-
}catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
41-
if(isset($e->getServerResponse()->message_id)){
42-
throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
43-
}
44-
throw $e;
45-
46-
}
47-
}
48-
49-
function send($recipient, $subject, $body, $attachments = [], $sender = NULL){
50-
if(!$this->inizialized){
51-
throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
52-
}
53-
$sender = $sender ? $sender : $this->username;
54-
55-
$params['username'] = $this->username;
56-
$params['password'] = $this->password;
57-
$params['recipient'] = $recipient;
58-
$params['subject'] = $subject;
59-
$params['body'] = $body;
60-
if(count($attachments)>0){
61-
$params['attachments'] = $attachments;
62-
}
63-
$params['sender'] = $sender;
64-
try{
65-
return $this->connect("send","POST",$params);
66-
}catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
67-
if(isset($e->getServerResponse()->message_id)){
68-
throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
69-
}
70-
throw $e;
71-
72-
}
73-
74-
}
75-
76-
1+
<?php
2+
namespace OpenApi\classes;
3+
class PecMassiva extends OpenApiBase {
4+
5+
private string $username;
6+
private string $password;
7+
private bool $inizialized;
8+
9+
10+
11+
/**
12+
* @param string $token Il token da utilizzare per il collegamento
13+
* @param array $scopes Array con la lista degli scope per cui il token è abilitato
14+
* @param object $cache Classe che gestisce la cahce, deve essere una classe che estende {@see OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
15+
*/
16+
function __construct(string $token, array $scopes, object $cache, string $prefix){
17+
parent::__construct($token, $scopes, $cache, $prefix);
18+
$this->basePath = "https://ws.pecmassiva.com";
19+
$this->inizialized = FALSE;
20+
21+
}
22+
23+
function initialize(string $username, string $password){
24+
$this->username = $username;
25+
$this->password = $password;
26+
$this->inizialized = TRUE;
27+
}
28+
29+
function getStatus($messageId){
30+
if(!$this->inizialized){
31+
throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
32+
}
33+
34+
35+
try{
36+
$header[] = 'x-username: '.$this->username;
37+
$header[] = 'x-password: '.$this->password;
38+
return $this->connect("send/$messageId","GET",[],0,false,$header);
39+
40+
}catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
41+
if(isset($e->getServerResponse()->message_id)){
42+
throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
43+
}
44+
throw $e;
45+
46+
}
47+
}
48+
49+
function send($recipient, $subject, $body, $attachments = [], $sender = NULL){
50+
if(!$this->inizialized){
51+
throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
52+
}
53+
$sender = $sender ? $sender : $this->username;
54+
55+
$params['username'] = $this->username;
56+
$params['password'] = $this->password;
57+
$params['recipient'] = $recipient;
58+
$params['subject'] = $subject;
59+
$params['body'] = $body;
60+
if(count($attachments)>0){
61+
$params['attachments'] = $attachments;
62+
}
63+
$params['sender'] = $sender;
64+
try{
65+
return $this->connect("send","POST",$params);
66+
}catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
67+
if(isset($e->getServerResponse()->message_id)){
68+
throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
69+
}
70+
throw $e;
71+
72+
}
73+
74+
}
75+
76+
7777
}

0 commit comments

Comments
 (0)