From 63bf6af68cd45ad5c3343ee2ed3bce82be539bfd Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Thu, 16 Jul 2020 18:12:10 +0200
Subject: [PATCH 01/85] =?UTF-8?q?Primo=20commit=C3=AC=20Fatta=20la=20class?=
=?UTF-8?q?e=20che=20recupera=20il=20token=20ed=20istanzia=20le=20altre=20?=
=?UTF-8?q?classi?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
OpenApi.php | 319 ++++++++++++++++++++
classes/Imprese.php | 5 +
classes/OpenApiBase.php | 20 ++
classes/UfficioPostale.php | 10 +
classes/exception/OpenApiExceptionBase.php | 60 ++++
classes/exception/OpenApiTokenException.php | 16 +
classes/utility/DummyCache.php | 19 ++
readme.md | 24 ++
8 files changed, 473 insertions(+)
create mode 100644 OpenApi.php
create mode 100644 classes/Imprese.php
create mode 100644 classes/OpenApiBase.php
create mode 100644 classes/UfficioPostale.php
create mode 100644 classes/exception/OpenApiExceptionBase.php
create mode 100644 classes/exception/OpenApiTokenException.php
create mode 100644 classes/utility/DummyCache.php
create mode 100644 readme.md
diff --git a/OpenApi.php b/OpenApi.php
new file mode 100644
index 0000000..12bccc3
--- /dev/null
+++ b/OpenApi.php
@@ -0,0 +1,319 @@
+"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"] oppure "GET:ws.ufficiopostale.com/comuni NOTA: il dominio NON deve mai avere lo stage
+ * @param string $username Username openapi
+ * @param string $apikey ApiKey openapi
+ * @param mixed $environment='test' uno tra: dev, test (default), production
+ */
+ function __construct(array $scopes, string $username, string $apikey, $environment='test'){
+
+ $this->cache = new \OpenApi\classes\utility\DummyCache;
+ $this->header = null;
+ $this->rawResponse = null;
+ $realScopes = [];
+ $prefix = $environment=="production"?"":$environment.".";
+ $domains = [];
+ foreach($scopes as $s){
+ if(is_array($s)){
+ $domain = $s['domain'];
+ $realScope = $s['mode'].":".$prefix.$s['domain']."/".$s['method'];
+ }else{
+ $realScope = str_replace(":",":{$prefix}", $s) ;
+ $domain = explode(":", $s)[1];
+ $domain = explode("/", $domain)[0];
+ }
+ if(!in_array($domain, $domains)){
+ $domains[] = $domain;
+ }
+ if(!in_array($realScope,$realScopes)){
+ $realScopes[] = $realScope;
+ }
+ }
+ $this->username = $username;
+ $this->apikey = $apikey;
+ $this->prefix = $prefix;
+ $this->scopes = $realScopes;
+ $token = $this->getToken();
+
+
+ $moduli['ws.ufficiopostale.com'] = "\\OpenApi\\classes\\UfficioPostale";
+ $nomi['ws.ufficiopostale.com'] = "ufficiopostale";
+ $moduli['imprese.altravia.com'] = "\\OpenApi\\classes\\Imprese";
+ $nomi['imprese.altravia.com'] = "imprese";
+ $clients = [];
+ foreach($domains as $d){
+ if(isset($moduli[$d])){
+ $modulo = $moduli[$d];
+ $nome = $nomi[$d];
+ $this->$nome = new $modulo($token->token, $this->cache);
+ $clients[] = $this->$nome;
+ }
+ }
+ }
+
+
+ /**
+ * Imposta la calsse da utilizzare sistema di cache, deve essere una classe che estende
+ * {@see OpenApi\clasess\utility\DummyCache}
+ *
+ * @param mixed $cacheSys Istanza della classe da usare come sistema di cache
+ * @return void
+ */
+ function setCacheSystem($cacheSys){
+ $this->cache = $cacheSys;
+ foreach($this->clients as $c){
+ $c->setCacheSystem($cacheSys);
+ }
+ }
+
+
+ /**
+ *
+ * Restituisce il token attualemnte in sessione, se non presente o non più valido lo rigenera
+ *
+ * @param boolean $force=FALSE Se impostato a TRUE forza la rigenerazione del token
+ * @return object il token
+ */
+ function getToken($force=FALSE){
+ if(!$force && !$this->isTokenCompatible()){
+
+ //TODO: Controllare se il token è ancora valido
+ if(!$this->mustRfreshToken()){
+ return $_SESSION['openapi']['token'];
+ }
+ $this->renewToken();
+
+ return $_SESSION['openapi']['token'];
+ }
+ if($this->getOldToken()){
+ if(!$this->mustRfreshToken()){
+ return $_SESSION['openapi']['token'];
+ }
+ $this->renewToken();
+ return $_SESSION['openapi']['token'];
+ }
+ return $this->generateNewToken();
+ }
+
+
+ /**
+ * Rinnova il token in sessione
+ *
+ * @return object
+ */
+ private function renewToken(){
+ $param = ["expire" => 86400, "scopes" => $this->scopes];
+ //var_dump($param);exit;
+
+ $token = $this->connect("token/".$_SESSION['openapi']['token']->token,$param,"PUT");
+
+ if($token == NULL){
+ throw new \OpenApi\classes\exception\OpenApiTokenException("REnew Token: Connection Error",40001);
+ }
+ if($token->success == false){
+ $message = "REnew Token: unknow error";
+ if(isset($token->message)) {
+ $message = "REnew Token: $token->message";
+ }
+ $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40002);
+ $except->setServerResponse($token, $this->header, $this->rawResponse);
+
+ throw $except;
+ }
+ if(isset($token->data) && isset($token->data[0]))
+ {
+ $token = $token->data[0];
+ $_SESSION['openapi']['token'] = $token;
+ return $token;
+ }
+
+ }
+
+
+ /**
+ * Controlla se il token in sessione deve essere o meno rinnovato in base alla sua data di scadenza
+ *
+ * @return bool
+ */
+ private function mustRfreshToken(){
+ $token = $_SESSION['openapi']['token'];
+ $diff = $token->expire-date("U");
+ if($diff <= 6000){
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+
+ /**
+ *
+ * Recupera la lista di token per verificare se esiste uno utilizzabile con gli scopes di interesse,
+ * se si lo mette in sessione e ritorna TRUE
+ *
+ * @return boolean
+ */
+ function getOldToken(){
+ $param = ["scopes" => $this->scopes];
+ $token = $this->connect("token",$param,"GET");
+ $finded_token = NULL;
+
+ if($token != NULL && isset($token->data)){
+ foreach($token->data AS $token){
+ if($this->hasValidScopes($token)){
+ $finded_token = $token;
+ break 1;
+ }
+ }
+
+ if($finded_token != NULL){
+ $_SESSION['openapi']['token'] = $finded_token;
+ $_SESSION['openapi']['apikey'] = $this->apikey;
+ $_SESSION['openapi']['scopes'] = serialize($this->scopes);
+ $_SESSION['openapi']['username'] = $this->username;
+ $_SESSION['openapi']['prefix'] = $this->prefix;
+ return TRUE;
+ }
+ return FALSE;
+ }
+ }
+
+ function hasValidScopes($token){
+ foreach($this->scopes as $s){
+ if(!in_array($s, $token->scopes)){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Genera un nuovo token
+ * @return object il token
+ */
+ private function generateNewToken(){
+ $param = ["scopes" => $this->scopes];
+ $token = $this->connect("token",$param,"POST");
+ if($token == NULL){
+ throw new \OpenApi\classes\exception\OpenApiTokenException("Getting Token: Connection Error",40001);
+ }
+ if($token->success == false){
+ $message = "Getting Token: unknow error";
+ if(isset($token->message)) {
+ $message = "Getting Token: $token->message";
+ }
+ $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40002);
+ $except->setServerResponse($token, $this->header, $this->rawResponse);
+
+ throw $except;
+ }
+
+ $invalid_scopes = [];
+ foreach($this->scopes as $s){
+ if(!in_array($s, $token->scopes)){
+ $invalid_scopes[] = $s;
+ }
+ }
+ if(count($invalid_scopes)>0){
+ $message = "Getting Token: unknow error";
+ if(isset($token->message)) {
+
+ }
+ $message = "Getting Token: invalid scopes (".implode($invalid_scopes).")";
+ $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40003);
+ $except->setServerResponse($token, $this->header, $this->rawResponse);
+ throw $except;
+ }
+ $_SESSION['openapi']['token'] = $token;
+ $_SESSION['openapi']['apikey'] = $this->apikey;
+ $_SESSION['openapi']['scopes'] = serialize($this->scopes);
+ $_SESSION['openapi']['username'] = $this->username;
+ $_SESSION['openapi']['prefix'] = $this->prefix;
+ return $token;
+ }
+
+
+ /**
+ *
+ * Constrolla se il token in sessione è compatibile con la richiesta
+ *
+ * @return boolean
+ */
+ private function isTokenCompatible() {
+ if(!isset($_SESSION['openapi'])|| !isset($_SESSION['openapi']['token'])){
+ return TRUE;
+ }
+ if($_SESSION['openapi']['prefix'] != $this->prefix || $_SESSION['openapi']['apikey'] != $this->apikey || $_SESSION['openapi']['username'] != $this->username){
+ return TRUE;
+ }
+ $sessionScopes = unserialize($_SESSION['openapi']['scopes']);
+ if(!is_array($sessionScopes)){
+ return TRUE;
+ }
+ foreach($this->scopes as $s){
+ if(!in_array($s, $sessionScopes)){
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+
+
+ /**
+ * Effettua una connessione al server oauth
+ *
+ * @param string $endpoint path da recuperare
+ * @param array $param Lista dei parametri da passare
+ * @param mixed $mode metodo http da usare per la chiamata
+ * @return object
+ */
+ private function connect(string $endpoint, $param = [], $mode="POST"){
+
+ $this->header = null;
+ $this->rawResponse = null;
+ $basePath = "https://".$this->prefix."oauth.altravia.com";
+ $url = $basePath."/".$endpoint;
+
+
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode);
+ if($mode == "POST" || $mode == "PUT")
+ {
+ curl_setopt($ch, CURLOPT_POST, TRUE);
+ }
+ if($mode == "GET")
+ {
+ $param = http_build_query($param);
+ $url .= "?".$param;
+
+ }else{
+ $param = json_encode($param);
+
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
+ }
+
+ $baseauth = base64_encode($this->username.":".$this->apikey);
+ $headers = array(
+ 'Content-Type:application/json',
+ 'Authorization: Basic '. $baseauth // <---
+ );
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+
+
+ curl_setopt($ch, CURLOPT_TIMEOUT, 30);
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ $response = curl_exec($ch);
+ $this->rawResponse = $response;
+ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+ $this->header = substr($response, 0, $header_size);
+ $return = substr($response, $header_size);
+
+ curl_close($ch);
+ return json_decode($return);
+ }
+}
diff --git a/classes/Imprese.php b/classes/Imprese.php
new file mode 100644
index 0000000..3887ead
--- /dev/null
+++ b/classes/Imprese.php
@@ -0,0 +1,5 @@
+token = $token;
+ $this->token = $cache;
+ }
+
+ /**
+ * Imposta la calsse da utilizzare sistema di cache, deve essere una classe che estende
+ * {@see OpenApi\clasess\utility\DummyCache}
+ *
+ * @param mixed $cacheSys Istanza della classe da usare come sistema di cache
+ * @return void
+ */
+ function setCacheSystem($cacheSys){
+ $this->cache = $cacheSys;
+ }
+
+}
\ No newline at end of file
diff --git a/classes/UfficioPostale.php b/classes/UfficioPostale.php
new file mode 100644
index 0000000..352ef5f
--- /dev/null
+++ b/classes/UfficioPostale.php
@@ -0,0 +1,10 @@
+serverData = NULL;
+ $this->serverHeader = NULL;
+ $this->serverRawResponse = NULL;
+ }
+ public function __toString() {
+ return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
+ }
+
+
+ /**
+ *
+ * Imposta alcune variabili utili in fase di debugging degli errori
+ *
+ * @param object $serverData Response del server già decodato dalla versione json
+ * @param string $serverHeader Stringa contentene gli header della response
+ * @param string $serverRawResponse Stringa contente la risposta raw del server
+ *
+ * @return [type]
+ */
+ function setServerResponse(object $serverData, string $serverHeader, string $serverRawResponse){
+ $this->serverData = $serverData;
+ $this->serverHeader = $serverHeader;
+ $this->serverRawResponse = $serverRawResponse;
+ }
+
+ /**
+ *
+ * Restituisce la risposta del server già decodata da json
+ *
+ * @return object
+ */
+ function getServerResponse(){
+ return $this->serverData;
+ }
+
+ /**
+ *
+ * Restituisce gli header della rispopsta del server
+ *
+ * @return string
+ */
+ function getServerHeaderResponse(){
+ return $this->serverHeader;
+ }
+
+ /**
+ *
+ * Restituisce la risposta in formato RAW del server
+ * @return string
+ */
+ function getServerRawResponse(){
+ return $this->serverRawResponse;
+ }
+}
\ No newline at end of file
diff --git a/classes/exception/OpenApiTokenException.php b/classes/exception/OpenApiTokenException.php
new file mode 100644
index 0000000..b84a288
--- /dev/null
+++ b/classes/exception/OpenApiTokenException.php
@@ -0,0 +1,16 @@
+openapi = new \OpenApi\OpenApi($scopes,$user,$apikey,"test");
+ ```
+ Dove ```$scopes``` è un array di stringhe o di oggetti in uno dei seguenti formati:
+
+ ```php
+ $scopes=[
+ "GET:ws.ufficiopostale.com/comuni",
+ ["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
+ ];
+ ```
+
+ A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
+ ```php
+ $this->openapi->ufficioposale
+ $this->openapi->imprese
+ ```
+ che possono essere usati al seguente modo:
+ ```php
+ $this->openapi->ufficioposale->getCitiesByCap('00132';)
+ ```
\ No newline at end of file
From a206636ede48f5d24d565d4de88d9a88c222328b Mon Sep 17 00:00:00 2001
From: Simone Desantis
<67371387+SimoneDesantisAltravia@users.noreply.github.com>
Date: Fri, 17 Jul 2020 10:41:26 +0200
Subject: [PATCH 02/85] Set theme jekyll-theme-slate
---
_config.yml | 1 +
1 file changed, 1 insertion(+)
create mode 100644 _config.yml
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 0000000..c741881
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-slate
\ No newline at end of file
From af690b1c3cd08370e47e8fe78e9b6c9948a86e34 Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Thu, 30 Jul 2020 18:01:39 +0200
Subject: [PATCH 03/85] Aggiunta parte della gestione delle visure
---
OpenApi.php | 123 ++++++----
classes/Imprese.php | 66 ++++++
classes/OpenApiBase.php | 152 ++++++++++++-
classes/UfficioPostale.php | 26 ++-
classes/VisEngine.php | 110 +++++++++
.../exception/OpenApiConnectionsException.php | 17 ++
classes/exception/OpenApiExceptionBase.php | 8 +-
.../exception/OpenApiVisEngineException.php | 16 ++
classes/utility/CacheSystemInterface.php | 8 +
classes/utility/DummyCache.php | 6 +-
classes/utility/VisEngine/VisRequest.php | 212 ++++++++++++++++++
classes/utility/ci4SessionStoreToken.php | 18 ++
classes/utility/sessionStoreToken.php | 19 ++
classes/utility/storeTokenInterface.php | 8 +
readme.md | 65 ++++--
15 files changed, 778 insertions(+), 76 deletions(-)
create mode 100644 classes/VisEngine.php
create mode 100644 classes/exception/OpenApiConnectionsException.php
create mode 100644 classes/exception/OpenApiVisEngineException.php
create mode 100644 classes/utility/CacheSystemInterface.php
create mode 100644 classes/utility/VisEngine/VisRequest.php
create mode 100644 classes/utility/ci4SessionStoreToken.php
create mode 100644 classes/utility/sessionStoreToken.php
create mode 100644 classes/utility/storeTokenInterface.php
diff --git a/OpenApi.php b/OpenApi.php
index 12bccc3..303edc7 100644
--- a/OpenApi.php
+++ b/OpenApi.php
@@ -1,5 +1,5 @@
cache = new \OpenApi\classes\utility\DummyCache;
+ $this->store = $store;
$this->header = null;
$this->rawResponse = null;
$realScopes = [];
+ $domainsRealScopes = [];
$prefix = $environment=="production"?"":$environment.".";
$domains = [];
foreach($scopes as $s){
@@ -28,37 +32,57 @@ function __construct(array $scopes, string $username, string $apikey, $environme
}
if(!in_array($domain, $domains)){
$domains[] = $domain;
+ $domainsRealScopes[$domain] = [];
}
+
if(!in_array($realScope,$realScopes)){
$realScopes[] = $realScope;
+ $domainsRealScopes[$domain][] = $realScope;
}
+
}
+
$this->username = $username;
$this->apikey = $apikey;
$this->prefix = $prefix;
$this->scopes = $realScopes;
- $token = $this->getToken();
-
- $moduli['ws.ufficiopostale.com'] = "\\OpenApi\\classes\\UfficioPostale";
- $nomi['ws.ufficiopostale.com'] = "ufficiopostale";
- $moduli['imprese.altravia.com'] = "\\OpenApi\\classes\\Imprese";
- $nomi['imprese.altravia.com'] = "imprese";
- $clients = [];
+ $token = $this->getToken();
+ //var_dump($token);exit;
+ list($moduli,$nomi) = $this->getListaModuli();
+ $this->clients = [];
foreach($domains as $d){
if(isset($moduli[$d])){
$modulo = $moduli[$d];
$nome = $nomi[$d];
- $this->$nome = new $modulo($token->token, $this->cache);
- $clients[] = $this->$nome;
+ $this->$nome = new $modulo($token->token, $domainsRealScopes[$d], $this->cache, $prefix);
+ $this->clients[] = $nome;
}
}
}
+ /**
+ *
+ * Restituisce la lista dei moduli disponibili
+ *
+ * @return array
+ */
+ private function getListaModuli(){
+ $moduli = [];
+ $nomi = [];
+ $moduli['ws.ufficiopostale.com'] = "\\OpenApi\\classes\\UfficioPostale";
+ $nomi['ws.ufficiopostale.com'] = "ufficiopostale";
+ $moduli['imprese.altravia.com'] = "\\OpenApi\\classes\\Imprese";
+ $nomi['imprese.altravia.com'] = "imprese";
+
+ $moduli['visengine2.altravia.com'] = "\\OpenApi\\classes\\VisEngine";
+ $nomi['visengine2.altravia.com'] = "visengine";
+ return array($moduli,$nomi);
+ }
/**
* Imposta la calsse da utilizzare sistema di cache, deve essere una classe che estende
- * {@see OpenApi\clasess\utility\DummyCache}
+ * {@see OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
*
* @param mixed $cacheSys Istanza della classe da usare come sistema di cache
* @return void
@@ -66,11 +90,11 @@ function __construct(array $scopes, string $username, string $apikey, $environme
function setCacheSystem($cacheSys){
$this->cache = $cacheSys;
foreach($this->clients as $c){
- $c->setCacheSystem($cacheSys);
+ $this->$c->setCacheSystem($cacheSys);
}
}
-
+
/**
*
* Restituisce il token attualemnte in sessione, se non presente o non più valido lo rigenera
@@ -81,20 +105,19 @@ function setCacheSystem($cacheSys){
function getToken($force=FALSE){
if(!$force && !$this->isTokenCompatible()){
- //TODO: Controllare se il token è ancora valido
if(!$this->mustRfreshToken()){
- return $_SESSION['openapi']['token'];
+ return $this->store->get()['token'];
}
$this->renewToken();
- return $_SESSION['openapi']['token'];
+ return $this->store->get()['token'];
}
if($this->getOldToken()){
if(!$this->mustRfreshToken()){
- return $_SESSION['openapi']['token'];
+ return $this->store->get()['token'];
}
$this->renewToken();
- return $_SESSION['openapi']['token'];
+ return $this->store->get()['token'];
}
return $this->generateNewToken();
}
@@ -106,13 +129,13 @@ function getToken($force=FALSE){
* @return object
*/
private function renewToken(){
- $param = ["expire" => 86400, "scopes" => $this->scopes];
+ $param = ["expire" => time() + 86400, "scopes" => $this->scopes];
//var_dump($param);exit;
- $token = $this->connect("token/".$_SESSION['openapi']['token']->token,$param,"PUT");
+ $token = $this->connect("token/".$this->store->get()['token']->token,$param,"PUT");
if($token == NULL){
- throw new \OpenApi\classes\exception\OpenApiTokenException("REnew Token: Connection Error",40001);
+ throw new \OpenApi\classes\exception\OpenApiTokenException("Renew Token: Connection Error",40001);
}
if($token->success == false){
$message = "REnew Token: unknow error";
@@ -127,7 +150,7 @@ private function renewToken(){
if(isset($token->data) && isset($token->data[0]))
{
$token = $token->data[0];
- $_SESSION['openapi']['token'] = $token;
+ $this->store->get()['token'] = $token;
return $token;
}
@@ -140,7 +163,7 @@ private function renewToken(){
* @return bool
*/
private function mustRfreshToken(){
- $token = $_SESSION['openapi']['token'];
+ $token = $this->store->get()['token'];
$diff = $token->expire-date("U");
if($diff <= 6000){
return TRUE;
@@ -157,8 +180,9 @@ private function mustRfreshToken(){
* @return boolean
*/
function getOldToken(){
- $param = ["scopes" => $this->scopes];
+ $param = ["scope" => $this->scopes];
$token = $this->connect("token",$param,"GET");
+
$finded_token = NULL;
if($token != NULL && isset($token->data)){
@@ -170,11 +194,12 @@ function getOldToken(){
}
if($finded_token != NULL){
- $_SESSION['openapi']['token'] = $finded_token;
- $_SESSION['openapi']['apikey'] = $this->apikey;
- $_SESSION['openapi']['scopes'] = serialize($this->scopes);
- $_SESSION['openapi']['username'] = $this->username;
- $_SESSION['openapi']['prefix'] = $this->prefix;
+ $tostore['token'] = $finded_token;
+ $tostore['apikey'] = $this->apikey;
+ $tostore['scopes'] = serialize($this->scopes);
+ $tostore['username'] = $this->username;
+ $tostore['prefix'] = $this->prefix;
+ $this->session->save($tostore);
return TRUE;
}
return FALSE;
@@ -227,11 +252,14 @@ private function generateNewToken(){
$except->setServerResponse($token, $this->header, $this->rawResponse);
throw $except;
}
- $_SESSION['openapi']['token'] = $token;
- $_SESSION['openapi']['apikey'] = $this->apikey;
- $_SESSION['openapi']['scopes'] = serialize($this->scopes);
- $_SESSION['openapi']['username'] = $this->username;
- $_SESSION['openapi']['prefix'] = $this->prefix;
+ $tostore['token'] = $token;
+ $tostore['apikey'] = $this->apikey;
+ $tostore['scopes'] = serialize($this->scopes);
+ $tostore['username'] = $this->username;
+ $tostore['prefix'] = $this->prefix;
+
+ $this->store->save($tostore);
+
return $token;
}
@@ -243,13 +271,13 @@ private function generateNewToken(){
* @return boolean
*/
private function isTokenCompatible() {
- if(!isset($_SESSION['openapi'])|| !isset($_SESSION['openapi']['token'])){
+ if(!$this->store->isset()|| !isset($this->store->get()['token'])){
return TRUE;
}
- if($_SESSION['openapi']['prefix'] != $this->prefix || $_SESSION['openapi']['apikey'] != $this->apikey || $_SESSION['openapi']['username'] != $this->username){
+ if($this->store->get()['prefix'] != $this->prefix || $this->store->get()['apikey'] != $this->apikey || $this->store->get()['username'] != $this->username){
return TRUE;
}
- $sessionScopes = unserialize($_SESSION['openapi']['scopes']);
+ $sessionScopes = unserialize($this->store->get()['scopes']);
if(!is_array($sessionScopes)){
return TRUE;
}
@@ -276,7 +304,12 @@ private function connect(string $endpoint, $param = [], $mode="POST"){
$this->rawResponse = null;
$basePath = "https://".$this->prefix."oauth.altravia.com";
$url = $basePath."/".$endpoint;
-
+ if($mode == "GET")
+ {
+ $param = http_build_query($param);
+ $param = preg_replace('/(%5B)\d+(%5D=)/i', '$1$2', $param);
+ $url .= "?".$param;
+ }
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode);
@@ -284,12 +317,8 @@ private function connect(string $endpoint, $param = [], $mode="POST"){
{
curl_setopt($ch, CURLOPT_POST, TRUE);
}
- if($mode == "GET")
+ if($mode != "GET")
{
- $param = http_build_query($param);
- $url .= "?".$param;
-
- }else{
$param = json_encode($param);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
@@ -298,7 +327,7 @@ private function connect(string $endpoint, $param = [], $mode="POST"){
$baseauth = base64_encode($this->username.":".$this->apikey);
$headers = array(
'Content-Type:application/json',
- 'Authorization: Basic '. $baseauth // <---
+ 'Authorization: Basic '. $baseauth
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
@@ -309,10 +338,10 @@ private function connect(string $endpoint, $param = [], $mode="POST"){
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
$this->rawResponse = $response;
+
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$this->header = substr($response, 0, $header_size);
$return = substr($response, $header_size);
-
curl_close($ch);
return json_decode($return);
}
diff --git a/classes/Imprese.php b/classes/Imprese.php
index 3887ead..23b58e6 100644
--- a/classes/Imprese.php
+++ b/classes/Imprese.php
@@ -1,5 +1,71 @@
basePath = "https://imprese.altravia.com";
+ }
+ /**
+ *
+ * Consente di recuperare i dati di una azienda a partire dalla partita IVA
+ *
+ * @param string $partitaIva La partita IVa da ricercare
+ * @param int $ttr Time to Release: per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+ *
+ * @return object
+ */
+ function getByPartitaIva(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("advance/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+
+
+ }
+
+ /**
+ *
+ * Cerca un'azienda o più utilizzando vari parametri
+ *
+ * @param string $denominazione Denominazione azienda
+ * @param string $provincia Provincia
+ * @param string $partitaIva=NULL Partita IVA
+ * @param string $codiceFiscale=NULL Codice Fiscale
+ * @param int $ttr Time to Release: per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+ *
+ * @return array Lista delle aziende individuate
+ */
+ function getBySearch(string $denominazione, string $provincia, $partitaIva= NULL , $codiceFiscale=NULL, $ttr = 86400){
+ $params=[];
+ if($denominazione != NULL){
+ $params['denominazione'] = $denominazione;
+ }
+ if($provincia != NULL){
+ $params['provincia'] = $provincia;
+ }
+ if($partitaIva != NULL){
+ $params['piva'] = $partitaIva;
+ }
+ if($codiceFiscale != NULL){
+ $params['cf'] = $codiceFiscale;
+ }
+
+ $data = $this->connect("advance/$partitaIva", "GET", $params, $ttr);
+ return $data->data;
+ }
}
\ No newline at end of file
diff --git a/classes/OpenApiBase.php b/classes/OpenApiBase.php
index 68572ac..a88dedb 100644
--- a/classes/OpenApiBase.php
+++ b/classes/OpenApiBase.php
@@ -1,20 +1,162 @@
token = $token;
- $this->token = $cache;
+ $this->cache = $cache;
+ $this->scopes = $scopes;
+ $this->prefix = $prefix;
+ $this->basePath = null;
}
/**
* Imposta la calsse da utilizzare sistema di cache, deve essere una classe che estende
- * {@see OpenApi\clasess\utility\DummyCache}
+ * {@see \OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
*
- * @param mixed $cacheSys Istanza della classe da usare come sistema di cache
+ * @param object $cacheSys Istanza della classe da usare come sistema di cache
* @return void
*/
- function setCacheSystem($cacheSys){
+ function setCacheSystem(object $cacheSys){
$this->cache = $cacheSys;
}
+
+
+ /**
+ * Salva un oggetto nella cache
+ * @param string $key LA chiave utilizzata per salvare l'oggetto nella cache
+ * @param object $value L'oggetto da salvare nella cache
+ * @param int $ttr TEmpo in cui l'oggetto resta in cache
+ *
+ * @return void
+ */
+ protected function setCacheObject(string $key, object $value, int $ttr){
+ $ttr += rand ( 0 , 120 );
+ $this->cache->save($key, $value, $ttr);
+ }
+
+ /**
+ *
+ * Recupera un oggetto dalla cache se presente
+ *
+ * @param string $key LA chiave da utilizzare per recuperare l'oggetto in cache
+ *
+ * @return mixed L'oggetto o NUL se insesistente
+ */
+ protected function getCacheObject(string $key){
+ $cached = $this->cache->get($key);
+ if($cached){
+ return $cached;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * Controlla se si ha lo scope necessario per poter invocare il metodo, in caso contrario scatena un'eccezione
+ *
+ * @param string $url
+ *
+ * @return void
+ */
+ private function checkHasScope(string $url, string $type){
+ $parsed = parse_url($url);
+ $permission = $type.":".$parsed['host'];
+ $path = $parsed['path'];
+ $path = explode("/", $path);
+ if(isset($path[1])){
+ $permission .= "/".$path[1];
+ }
+ if(!in_array($permission, $this->scopes)){
+ throw new \OpenApi\classes\exception\OpenApiConnectionsException("Scope missed: $permission",40004);
+ }
+
+ }
+
+ /**
+ * @param string $endpoint Endpoint da richiamare
+ * @param string $type Tipo di chiamata
+ * @param array $param Parametri da passare alla chiamata
+ * @param int $ttr Tempo in cui la chiamata resta in cache (0 = no cache)
+ *
+ * @return mixed
+ */
+ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0){
+ $url = $this->basePath;
+ $url = str_replace("https://","https://".$this->prefix,$url);
+ $url = str_replace("http://","http://".$this->prefix,$url);
+ $url .= "/".$endpoint;
+ $this->checkHasScope($url, $type);
+ if($type == "GET" && $ttr > 0 && $ret = $this->getCacheObject($url)) {
+ return $ret;
+ }
+ $ch = curl_init();
+ if($type == "POST" || $type == "PUT") {
+ curl_setopt($ch, CURLOPT_POST, TRUE);
+ }
+ if($param != array()) {
+ if($type == "GET") {
+ $param = http_build_query($param);
+ $url .= "?".$param;
+
+ }else{
+ if($type == "PUT") {
+ $param = json_encode($param);
+ }else{
+ $param = json_encode($param);
+ }
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
+ }
+ }
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
+ curl_setopt($ch,CURLOPT_HTTPHEADER,array("Authorization: Bearer ".$this->token));
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ $response = curl_exec($ch);
+ $this->rawResponse = $response;
+ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+ $this->header = substr($response, 0, $header_size);
+ $return = substr($response, $header_size);
+ $httpCode = curl_getinfo ( $ch, CURLINFO_RESPONSE_CODE );;
+ curl_close($ch);
+ $data = json_decode($return);
+ if($data == NULL){
+ throw new \OpenApi\classes\exception\OpenApiConnectionsException("Connection to $url: Connection Error",40001);
+ }
+ // var_dump($data);exit;
+ if($data->success == false){
+ $message = "Connection to $url: unknow error";
+ if(isset($data->message)) {
+ if(is_string(($data->message))){
+ if($dataMessage = json_decode($data->message)){
+ $data = $dataMessage;
+ }
+ $message = "Connection to $url: $data->message";
+ }else{
+ $message = "Connection to $url error";
+ }
+
+
+ }
+ //var_dump($this->rawResponse);
+ $except = new \OpenApi\classes\exception\OpenApiConnectionsException($message,40002);
+ $except->setServerResponse($data, $this->header, $this->rawResponse, $httpCode);
+
+ throw $except;
+ }
+ if($type == "GET" && $ttr > 0) {
+ $this->setCacheObject($url, $data, $ttr);
+ }
+ return $data;
+ }
+
}
\ No newline at end of file
diff --git a/classes/UfficioPostale.php b/classes/UfficioPostale.php
index 352ef5f..42471ff 100644
--- a/classes/UfficioPostale.php
+++ b/classes/UfficioPostale.php
@@ -2,9 +2,29 @@
namespace OpenApi\classes;
class UfficioPostale extends OpenApiBase {
- function getCitiesByCap($cap){
- echo "QUI";
- var_dump($cap);
+ /**
+ * @param string $token Il token da utilizzare per il collegamento
+ * @param array $scopes Array con la lista degli scope per cui il token è abilitato
+ * @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)
+ */
+ function __construct(string $token, array $scopes, object $cache, string $prefix){
+ parent::__construct($token, $scopes, $cache, $prefix);
+ $this->basePath = "https://ws.ufficiopostale.com";
+ }
+
+
+ /**
+ *
+ * A partire dal CAP restistuisce un'array di oggietti di tipo comune
+ *
+ * @param string $cap Il cap da ricercare
+ * @param int $ttl Il tempo di chache degli oggetti ritornati, 0 per no chche
+ *
+ * @return array
+ */
+ function getCitiesByCap(string $cap, $ttl = 86400){
+ $data = $this->connect("comuni/$cap", "GET", [], $ttl);
+ return $data->data;
}
}
\ No newline at end of file
diff --git a/classes/VisEngine.php b/classes/VisEngine.php
new file mode 100644
index 0000000..76c015d
--- /dev/null
+++ b/classes/VisEngine.php
@@ -0,0 +1,110 @@
+hash = NULL;
+ parent::__construct($token, $scopes, $cache, $prefix);
+ $this->basePath = "https://visengine2.altravia.com";
+ }
+
+ /**
+ * Imposta l'hash della Visura da utilizzare per tutti i dati
+ * @param string $hash
+ *
+ */
+ function setHash(string $hash){
+ $this->hash = $hash;
+ }
+
+ function getFormTool(){
+ if($this->hash == NULL){
+ throw new \OpenApi\classes\exception\OpenApiVisEngineException("Visengine hash is not setted",40005);
+ }
+ $url = $this->basePath;
+ $url = str_replace("https://","https://".$this->prefix,$url);
+ $url = str_replace("http://","http://".$this->prefix,$url);
+ $url .= "/visura/formTool/{$this->hash}.hs";
+ return $url;
+ }
+
+
+ /**
+ *
+ * Prepara un nuovo oggetto di tipo VisRequest da utilizzare per inviare una nuova richiesta e lo restituisce
+ * @param int $ttr Time to Release sulla richiesta dei dati della visura
+ *
+ * @return object
+ */
+ function createRequest($ttr = 500){
+ if($this->hash == NULL){
+ throw new \OpenApi\classes\exception\OpenApiVisEngineException("Visengine hash is not setted",40005);
+ }
+ $this->visura = $this->connect("visure/$this->hash", "GET", [], $ttr);
+ defined("OPENAPI_CREATING_REQUEST") OR define("OPENAPI_CREATING_REQUEST", TRUE);
+ return new \OpenApi\classes\utility\VisEngine\VisRequest($this->visura);
+ }
+
+
+ /**
+ * Invia una request, in base al contenuto della stessa distingue automaticamente se fare la chiamata in POST o PUT
+ * Restituisce la richiesa comprensiva di risposta del server
+ * @param \OpenApi\classes\utility\VisEngine\VisRequest $request
+ *
+ * @return object
+ */
+ function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req) {
+ $params = new \stdClass();
+ $params->state = $req->getState();
+ $params->test = $req->getTest();
+ $params->hash_visura = $this->hash;
+ if($req->getJson() != NULL){
+ $params->json_visura = $req->getJson();
+ }
+ if($req->getCallbackData() != NULL){
+ $params->callback_data = $req->getCallbackData();
+ }
+ if($req->getTargetEmail() != NULL){
+ $params->email_target = $req->getTargetEmail();
+ }
+ if($req->getNew()){
+ $data = $this->connect("richiesta", "POST", $params);
+ $req->setNew(FALSE);
+ $req->setId($data->data->_id);
+ $req->setStatoRichiesta($data->data->stato_richiesta);
+ if(isset($data->data->ricerche)){
+ $req->setRicerche($data->data->ricerche);
+ }
+ return $req;
+ }
+
+
+ }
+
+ function getRequestByIdVisura($id_visura){
+ $visura = $this->connect("richiesta/$id_visura", "GET");
+ return $this->getRequetByData($visura);
+ }
+
+ function getRequetByData($visura){
+ $this->visura = $this->connect("visure/{$visura->data->hash_visura}", "GET", [], 0);
+ $this->hash = $visura->data->hash_visura;
+ defined("OPENAPI_CREATING_REQUEST") OR define("OPENAPI_CREATING_REQUEST", TRUE);
+ $request = new \OpenApi\classes\utility\VisEngine\VisRequest($this->visura);
+ $request->setNew(FALSE);
+ $request->setId($visura->data->_id);
+ $request->setStatoRichiesta($visura->data->stato_richiesta);
+ if(isset($visura->data->ricerche)){
+ $request->setRicerche($visura->data->ricerche);
+ }
+ return $request;
+ }
+
+}
+
+
diff --git a/classes/exception/OpenApiConnectionsException.php b/classes/exception/OpenApiConnectionsException.php
new file mode 100644
index 0000000..b8ef39f
--- /dev/null
+++ b/classes/exception/OpenApiConnectionsException.php
@@ -0,0 +1,17 @@
+serverData = NULL;
$this->serverHeader = NULL;
$this->serverRawResponse = NULL;
+ $this->httpCode = NULL;
}
public function __toString() {
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
@@ -23,10 +24,11 @@ public function __toString() {
*
* @return [type]
*/
- function setServerResponse(object $serverData, string $serverHeader, string $serverRawResponse){
+ function setServerResponse(object $serverData, string $serverHeader, string $serverRawResponse, $httpCode = NULL){
$this->serverData = $serverData;
$this->serverHeader = $serverHeader;
$this->serverRawResponse = $serverRawResponse;
+ $this->httpCode = $httpCode;
}
/**
@@ -57,4 +59,8 @@ function getServerHeaderResponse(){
function getServerRawResponse(){
return $this->serverRawResponse;
}
+
+ function getHttpCode(){
+ return $this->httpCode;
+ }
}
\ No newline at end of file
diff --git a/classes/exception/OpenApiVisEngineException.php b/classes/exception/OpenApiVisEngineException.php
new file mode 100644
index 0000000..0273ebc
--- /dev/null
+++ b/classes/exception/OpenApiVisEngineException.php
@@ -0,0 +1,16 @@
+ visengin",40008);
+ }
+ $this->visura = $visura;
+ $this->variables = [];
+ $this->new = TRUE;
+ $this->json = NULL;
+ $this->jsonValido = FALSE;
+ $this->state = 0;
+ $this->test = false;
+ $this->callback = NULL;
+ $this->email_target = NULL;
+ $this->id = NULL;
+ $this->statoRichiesta = NULL;
+ $this->ricerche = [];
+ foreach($visura->data->json_struttura->campi as $k => $v){
+ $this->variables[$k] = FALSE;
+ }
+ }
+
+ function setNew(bool $new){
+ return $this->new = $new;
+ }
+
+ function getNew(){
+ return $this->new;
+ }
+ /**
+ *
+ * Imposta il JSON per inviare una nuova visura
+ *
+ * @param array $data IL JSON della visura da inviare
+ *
+ * @return boolean Ritorna TRUE nel caso in cui tutti i campi richiesti per la visura sono stati compilati (attenzione, viene effettuata la sola validazione sui required, per la validazione del formato occcorre inviare la visura)
+ */
+ function setJson(object $data){
+ foreach($data as $k => $v){
+ if(!isset($this->variables[$k])){
+ throw new \OpenApi\classes\exception\OpenApiVisEngineException("Visengine you are setting $k json key, but $k key is not presente for {$this->visura->data->nome_visura}",40006);
+ }
+ $this->variables[$k] = TRUE;
+ }
+ $this->json = $data;
+
+ $this->validaJSON();
+ return $this->jsonValido;
+ }
+
+
+
+ /**
+ *
+ * Restituisce il JSON della visura
+ *
+ * @return object
+ */
+ function getJson(){
+ return $this->json;
+ }
+
+ /**
+ * Ritorna TRUE nel caso in cui tutti i campi richiesti per la visura sono presenti all'interno del JSON
+ * @return boolean
+ */
+ function isValidJson(){
+ return $this->jsonValido;
+ }
+
+ /**
+ *
+ * Imposta i dati della callback
+ *
+ * @param string $url La url da richiamare per la callback
+ * @param object $data Oggetto data che verrà ripassato
+ * @param string $method='JSON' Metodo da usare JSON/POST
+ * @param string $field="visengineData" Nome del campo dove verranno passati i dati della visura
+ *
+ * @return void
+ */
+ function setCallbackData(string $url, object $data, $method = "JSON", $field="visengineData"){
+ $this->callback = (object)[
+ "url" => $url,
+ "data" => $data,
+ "method" => $method,
+ "field" => $field
+ ];
+ }
+
+
+ /**
+ * Restituisce i dati della callback
+ *
+ * @return object
+ */
+ function getCallbackData(){
+ return $this->callback;
+ }
+
+ /**
+ * Impowsta il parametro state della visura
+ * @param int $stato
+ *
+ * @return void
+ */
+ function setState($stato = 0){
+ if($stato != 0 && !$this->jsonValido ){
+ throw new \OpenApi\classes\exception\OpenApiVisEngineException("JSON is not valid, so is not possible set state = 1",40007);
+ }
+ $this->state = $stato == 0 ? $stato : 1;
+ }
+
+ /**
+ * Ritorna il parametro state
+ * @return int
+ */
+ function getState(){
+ return $this->state;
+ }
+
+ /**
+ * Imposta il parametro email_target
+ *
+ * @param string $email_target
+ *
+ * @return void
+ */
+ function setTargetEmail(string $email_target){
+ $this->email_target = $email_target;
+ }
+
+ /**
+ * Ritorna il parametro email_target
+ * @return string
+ */
+ function getTargetEmail(){
+ return $this->email_target;
+ }
+
+
+ /**
+ *
+ * Imposta il parametro test
+ *
+ * @param bool $test
+ *
+ * @return void
+ */
+ function setTest(bool $test){
+ $this->test = $test;
+ }
+
+
+ /**
+ * Restituisce il parametro test
+ * @return bool
+ */
+ function getTest(){
+ return $this->test;
+ }
+
+
+ /**
+ * Controlla il JSON e ritorna TRUE nel caso in cui tutti i campi richiesti per la visura sono presenti all'interno del JSON
+ * @return boolean
+ */
+ private function validaJSON(){
+ $re = '/\$(\d)+/m';
+ $validazione = $this->visura->data->json_struttura->validazione;
+ $subst = '$this->variables[\'$0\']';
+
+ $validazione = '$this->jsonValido = ' .preg_replace($re, $subst, $validazione).";";
+ eval($validazione);
+ }
+
+ function getId() {
+ return $this->id;
+ }
+
+ function setId($id) {
+ $this->id = $id;
+ }
+
+ function getStatoRichiesta() {
+ return $this->statoRichiesta;
+ }
+
+ function setStatoRichiesta($statoRichiesta) {
+ $this->statoRichiesta = $statoRichiesta;
+ }
+
+ function getRicerche() {
+ return $this->ricerche;
+ }
+
+ function setRicerche($ricerche) {
+ $this->ricerche = $ricerche;
+ }
+
+ function getStatoRicerca(){
+ if(count($this->ricerche) == NULL){
+ return FALSE;
+ }
+ return $this->ricerche[count($this->ricerche) - 1]->stato_ricerca;
+ }
+}
\ No newline at end of file
diff --git a/classes/utility/ci4SessionStoreToken.php b/classes/utility/ci4SessionStoreToken.php
new file mode 100644
index 0000000..c01d873
--- /dev/null
+++ b/classes/utility/ci4SessionStoreToken.php
@@ -0,0 +1,18 @@
+set("openapi",$data);
+ }
+
+ function clear(){
+ session()->remove("openapi");
+ }
+
+ function isset(){
+ return session()->has("openapi");
+ }
+}
\ No newline at end of file
diff --git a/classes/utility/sessionStoreToken.php b/classes/utility/sessionStoreToken.php
new file mode 100644
index 0000000..066bbb9
--- /dev/null
+++ b/classes/utility/sessionStoreToken.php
@@ -0,0 +1,19 @@
+openapi = new \OpenApi\OpenApi($scopes,$user,$apikey,"test");
- ```
- Dove ```$scopes``` è un array di stringhe o di oggetti in uno dei seguenti formati:
-
- ```php
- $scopes=[
- "GET:ws.ufficiopostale.com/comuni",
- ["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
- ];
- ```
-
- A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
- ```php
- $this->openapi->ufficioposale
- $this->openapi->imprese
- ```
- che possono essere usati al seguente modo:
- ```php
- $this->openapi->ufficioposale->getCitiesByCap('00132';)
- ```
\ No newline at end of file
+```
+
+Dove ```$scopes``` è un array di stringhe o di oggetti in uno dei seguenti formati:
+
+```php
+$scopes=[
+"GET:ws.ufficiopostale.com/comuni",
+["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
+];
+```
+
+A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
+
+```php
+$this->openapi->ufficiopostale
+$this->openapi->imprese
+...
+```
+
+che possono essere usati al seguente modo:
+
+```php
+$this->openapi->ufficioposale->getCitiesByCap('00132');
+```
+
+# Modulo ufficio postale
+
+# Modulo visure
+
+# Modulo imprese
+
+## `getByPartitaIva`
+
+### Introduction
+
+La funzione consente di recuperare i dati aziendali a partire dalla partita IVA
+
+### Description
+
+`function getByPartitaIva(string $partitaIva, $ttl = 86400):object`
+
+* $partitaIva: La partita IVA da cvercare
+* $ttl: Time To Release, per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
From f28c23d46c684eb2c77827f93d64823d5a36f09e Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Tue, 29 Sep 2020 11:47:40 +0200
Subject: [PATCH 04/85] Aggiunte le seguenti api: Comuni Geocoding Marche
Temporali
---
OpenApi.php | 6 +
classes/Comuni.php | 103 ++++++
classes/Geocoding.php | 21 ++
classes/Imprese.php | 53 ++-
classes/MarcheTemporali.php | 51 +++
classes/OpenApiBase.php | 14 +-
classes/UfficioPostale.php | 14 +-
classes/VisEngine.php | 64 +++-
.../OpenApiMarcheTemporaliException.php | 13 +
classes/utility/Plugins/FiscalCode.php | 317 ++++++++++++++++++
classes/utility/Plugins/Validations.php | 122 +++++++
classes/utility/VisEngine/VisRequest.php | 215 +++++++++++-
composer.json | 18 +
13 files changed, 980 insertions(+), 31 deletions(-)
create mode 100644 classes/Comuni.php
create mode 100644 classes/Geocoding.php
create mode 100644 classes/MarcheTemporali.php
create mode 100644 classes/exception/OpenApiMarcheTemporaliException.php
create mode 100644 classes/utility/Plugins/FiscalCode.php
create mode 100644 classes/utility/Plugins/Validations.php
create mode 100644 composer.json
diff --git a/OpenApi.php b/OpenApi.php
index 303edc7..bc87789 100644
--- a/OpenApi.php
+++ b/OpenApi.php
@@ -59,6 +59,8 @@ function __construct(array $scopes, string $username, string $apikey, $environme
$this->clients[] = $nome;
}
}
+
+ $this->validations = new \OpenApi\classes\utility\Plugins\Validations();
}
/**
@@ -77,6 +79,10 @@ private function getListaModuli(){
$moduli['visengine2.altravia.com'] = "\\OpenApi\\classes\\VisEngine";
$nomi['visengine2.altravia.com'] = "visengine";
+
+
+ $moduli['comuni.openapi.it'] = "\\OpenApi\\classes\\Comuni";
+ $nomi['comuni.openapi.it'] = "comuni";
return array($moduli,$nomi);
}
diff --git a/classes/Comuni.php b/classes/Comuni.php
new file mode 100644
index 0000000..b7da833
--- /dev/null
+++ b/classes/Comuni.php
@@ -0,0 +1,103 @@
+basePath = "https://comuni.openapi.it";
+ }
+
+
+ /**
+ *
+ * A partire dal CAP restistuisce un'array di oggietti di tipo comune
+ *
+ * @param string $cap Il cap da ricercare
+ * @param int $ttl Il tempo di chache degli oggetti ritornati, 0 per no chche
+ *
+ * @return array
+ */
+ function getCitiesByCap(string $cap, $ttl = 86400){
+ $data = $this->connect("cap/$cap", "GET", [], $ttl);
+ return $data->data;
+ }
+
+ /**
+ * Restituisce la lista delle regioni italiani
+ *
+ * @return array
+ */
+ function getRegioni($ttl = 86400){
+ $data = $this->connect("regioni", "GET", [], $ttl);
+ $regioni = $data->data;
+ sort($regioni);
+ return $regioni;
+ }
+
+ /**
+ * Restituisce la lsita delle province italiane (a partire dalla regione)
+ * @param string $regione La regione per la quale recuperare le regioni
+ *
+ * @return array
+ */
+ function getProvince($regione = NULL, $ttl = 86400){
+ if($regione == NULL){
+ $data = $this->connect("province", "GET", [], $ttl);
+ $province = $data->data;
+
+ $_province = [];
+ foreach($province as $key => $p){
+ $provincia = new \stdClass();
+ $provincia->nome_provincia = $p;
+ $provincia->sigla_provincia = $key;
+ $_province[] = $provincia;
+ }
+
+ usort($_province,[$this, 'sortProcince']);
+ return $_province;
+ }
+ $regione = explode("/",$regione)[0];
+ $regione = trim(\strtolower($regione));
+ $regione = urlencode($regione);
+
+ $data = $this->connect("regioni/$regione", "GET", [], $ttl);
+
+
+ $province = $data->data;
+ usort($province,[$this, 'sortProcince']);
+ return $province;
+ }
+
+ function getComuni($provincia, $ttl = 86400){
+
+ $provincia = trim(\strtolower($provincia));
+ $data = $this->connect("province/$provincia", "GET", [], $ttl);
+
+
+ $comuni = $data->data;
+ //sort($comuni->comuni);
+ //usort($comuni->dettaglio_comuni,[$this, 'sortComune']);
+ return $comuni;
+
+ }
+
+ private function sortComune($a, $b){
+ if($a->nome == $b->nome){
+ return 0;
+ }
+ return $a->nome < $b->nome ? -1 : 1;
+ }
+
+ private function sortProcince($a, $b){
+ if($a->nome_provincia == $b->nome_provincia){
+ return 0;
+ }
+ return $a->nome_provincia < $b->nome_provincia ? -1 : 1;
+ }
+
+}
\ No newline at end of file
diff --git a/classes/Geocoding.php b/classes/Geocoding.php
new file mode 100644
index 0000000..ca81382
--- /dev/null
+++ b/classes/Geocoding.php
@@ -0,0 +1,21 @@
+basePath = "https://geocoding.realgest.it";
+ }
+
+ function geocode(string $address, $ttl = 86400){
+ $data = $this->connect("geocode", "POST", ["address" => $address], $ttl, TRUE);
+
+ return $data;
+ }
+
+}
\ No newline at end of file
diff --git a/classes/Imprese.php b/classes/Imprese.php
index 23b58e6..22255ab 100644
--- a/classes/Imprese.php
+++ b/classes/Imprese.php
@@ -38,6 +38,57 @@ function getByPartitaIva(string $partitaIva, $ttr = 86400){
}
+ function getClosed(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("closed/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
+ function getVatGroup(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("gruppoIva/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
+ function getPec(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("pec/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
/**
*
* Cerca un'azienda o più utilizzando vari parametri
@@ -53,7 +104,7 @@ function getByPartitaIva(string $partitaIva, $ttr = 86400){
function getBySearch(string $denominazione, string $provincia, $partitaIva= NULL , $codiceFiscale=NULL, $ttr = 86400){
$params=[];
if($denominazione != NULL){
- $params['denominazione'] = $denominazione;
+ $params['denominazione'] = trim($denominazione);
}
if($provincia != NULL){
$params['provincia'] = $provincia;
diff --git a/classes/MarcheTemporali.php b/classes/MarcheTemporali.php
new file mode 100644
index 0000000..f7466ea
--- /dev/null
+++ b/classes/MarcheTemporali.php
@@ -0,0 +1,51 @@
+basePath = "https://ws.marchetemporali.com";
+ }
+
+ function availability(string $type, int $qty){
+ $data = $this->connect("availability/$type/$qty", "GET", []);
+ return $data->data;
+ }
+
+ function checkLotto($username, $password){
+
+ if(substr($username,0,4) == "FAKE" && substr($password,0,4) == "FAKE"){
+ $ret = new \stdClass();
+ $ret->data = new \stdClass();
+ $ret->data->available = 10;
+ $ret->data->used = 90;
+ $ret->message = "DESCR= Marche per $username; disponibili 10 consumate 0";
+ $ret->success = TRUE;
+ $ret->error = NULL;
+ return $ret->data;
+ }
+ $data = $this->connect("check_lotto", "POST", ["username"=>$username, "password"=> $password]);
+
+ return $data->data;
+ }
+
+ function purcahse(string $type, int $qty){
+ $data = $this->availability($type, $qty);
+ //var_dump($data);exit;
+ if($data->availability == 0){
+ throw new \OpenApi\classes\exception\OpenApiMarcheTemporaliException("$qty $type time stamps is not availabile for purchase",40009);
+ }
+ //echo "marche/$type/$qty";exit;
+ $data = $this->connect("marche/$type/$qty", "GET", []);
+ //var_dump($data);exit;
+ return $data->data;
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/classes/OpenApiBase.php b/classes/OpenApiBase.php
index a88dedb..6b75432 100644
--- a/classes/OpenApiBase.php
+++ b/classes/OpenApiBase.php
@@ -89,12 +89,15 @@ private function checkHasScope(string $url, string $type){
*
* @return mixed
*/
- protected function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0){
+ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false){
$url = $this->basePath;
$url = str_replace("https://","https://".$this->prefix,$url);
$url = str_replace("http://","http://".$this->prefix,$url);
$url .= "/".$endpoint;
- $this->checkHasScope($url, $type);
+ if(!$force){
+ $this->checkHasScope($url, $type);
+ }
+
if($type == "GET" && $ttr > 0 && $ret = $this->getCacheObject($url)) {
return $ret;
}
@@ -108,11 +111,7 @@ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr =
$url .= "?".$param;
}else{
- if($type == "PUT") {
- $param = json_encode($param);
- }else{
- $param = json_encode($param);
- }
+ $param = json_encode($param);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
}
}
@@ -122,6 +121,7 @@ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr =
curl_setopt($ch,CURLOPT_HTTPHEADER,array("Authorization: Bearer ".$this->token));
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
+ //var_dump($response);exit;
$this->rawResponse = $response;
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$this->header = substr($response, 0, $header_size);
diff --git a/classes/UfficioPostale.php b/classes/UfficioPostale.php
index 42471ff..ac83477 100644
--- a/classes/UfficioPostale.php
+++ b/classes/UfficioPostale.php
@@ -13,18 +13,6 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
}
- /**
- *
- * A partire dal CAP restistuisce un'array di oggietti di tipo comune
- *
- * @param string $cap Il cap da ricercare
- * @param int $ttl Il tempo di chache degli oggetti ritornati, 0 per no chche
- *
- * @return array
- */
- function getCitiesByCap(string $cap, $ttl = 86400){
- $data = $this->connect("comuni/$cap", "GET", [], $ttl);
- return $data->data;
- }
+
}
\ No newline at end of file
diff --git a/classes/VisEngine.php b/classes/VisEngine.php
index 76c015d..0080d58 100644
--- a/classes/VisEngine.php
+++ b/classes/VisEngine.php
@@ -29,7 +29,7 @@ function getFormTool(){
$url = $this->basePath;
$url = str_replace("https://","https://".$this->prefix,$url);
$url = str_replace("http://","http://".$this->prefix,$url);
- $url .= "/visura/formTool/{$this->hash}.hs";
+ $url .= "/visura/formTool/{$this->hash}.js";
return $url;
}
@@ -59,7 +59,11 @@ function createRequest($ttr = 500){
* @return object
*/
function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req) {
- $params = new \stdClass();
+
+
+
+ if($req->getNew()){
+ $params = new \stdClass();
$params->state = $req->getState();
$params->test = $req->getTest();
$params->hash_visura = $this->hash;
@@ -72,8 +76,8 @@ function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req) {
if($req->getTargetEmail() != NULL){
$params->email_target = $req->getTargetEmail();
}
- if($req->getNew()){
$data = $this->connect("richiesta", "POST", $params);
+
$req->setNew(FALSE);
$req->setId($data->data->_id);
$req->setStatoRichiesta($data->data->stato_richiesta);
@@ -81,17 +85,39 @@ function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req) {
$req->setRicerche($data->data->ricerche);
}
return $req;
- }
+ }else{
+ $params = new \stdClass();
+ $params->state = $req->getState();
+ // $params->test = $req->getTest();
+
+ if($req->getJson() != NULL){
+ $params->json_visura = $req->getJson();
+ }
+ $id_visura = $req->getId();
+ //echo json_encode($params);exit;
+ //var_dump($params);exit;
+ $data = $this->connect("richiesta/$id_visura", "PUT", $params);
+
+
+ $req->setNew(FALSE);
+ $req->setId($data->data->_id);
+ $req->setStatoRichiesta($data->data->stato_richiesta);
+ if(isset($data->data->ricerche)){
+ $req->setRicerche($data->data->ricerche);
+ }
+ return $req;
+ }
}
function getRequestByIdVisura($id_visura){
$visura = $this->connect("richiesta/$id_visura", "GET");
- return $this->getRequetByData($visura);
+ return $this->getRequestByData($visura);
}
- function getRequetByData($visura){
+ function getRequestByData($visura){
+
$this->visura = $this->connect("visure/{$visura->data->hash_visura}", "GET", [], 0);
$this->hash = $visura->data->hash_visura;
defined("OPENAPI_CREATING_REQUEST") OR define("OPENAPI_CREATING_REQUEST", TRUE);
@@ -99,12 +125,38 @@ function getRequetByData($visura){
$request->setNew(FALSE);
$request->setId($visura->data->_id);
$request->setStatoRichiesta($visura->data->stato_richiesta);
+
if(isset($visura->data->ricerche)){
$request->setRicerche($visura->data->ricerche);
+ }else{
+ $request->setRicerche([]);
+ }
+ return $request;
+ }
+
+ function getDocument($id_visura){
+ $request = $this->getRequestByIdVisura($id_visura);
+ $documento = $this->connect("documento/{$id_visura}", "GET", [], 0);
+ if($request->getStatoRichiesta() == "Dati disponibili" || $request->getStatoRichiesta() == "Visura evasa"){
+
+ $request->setDocument($documento->data);
}
return $request;
}
+ function setRicerca($id_visura, $id_ricerca, $index){
+ $index = str_replace("indice_","",$index);
+ $request = $this->getRequestByIdVisura($id_visura);
+ $hash_visura = $request->visura->data->hash_visura;
+ $param = ["id_ricerca"=>$id_ricerca, "indice"=> $index];
+
+ $visura = $this->connect("richiesta/{$id_visura}/ricerche", "PUT", $param, 0);
+
+ $request->setStatoRichiesta($visura->data->stato_richiesta);
+ return $request;
+
+ }
+
}
diff --git a/classes/exception/OpenApiMarcheTemporaliException.php b/classes/exception/OpenApiMarcheTemporaliException.php
new file mode 100644
index 0000000..072c875
--- /dev/null
+++ b/classes/exception/OpenApiMarcheTemporaliException.php
@@ -0,0 +1,13 @@
+ 'A', 2 => 'B', 3 => 'C', 4 => 'D', 5 => 'E',
+ 6 => 'H', 7 => 'L', 8 => 'M', 9 => 'P', 10 => 'R',
+ 11 => 'S', 12 => 'T'
+ );
+
+
+ protected $_pari = array(
+ '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4,
+ '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9,
+ 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4,
+ 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9,
+ 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14,
+ 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19,
+ 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24,
+ 'Z' => 25
+ );
+
+ protected $_dispari = array(
+ '0' => 1, '1' => 0, '2' => 5, '3' => 7, '4' => 9,
+ '5' => 13, '6' => 15, '7' => 17, '8' => 19, '9' => 21,
+ 'A' => 1, 'B' => 0, 'C' => 5, 'D' => 7, 'E' => 9,
+ 'F' => 13, 'G' => 15, 'H' => 17, 'I' => 19, 'J' => 21,
+ 'K' => 2, 'L' => 4, 'M' => 18, 'N' => 20, 'O' => 11,
+ 'P' => 3, 'Q' => 6, 'R' => 8, 'S' => 12, 'T' => 14,
+ 'U' => 16, 'V' => 10, 'W' => 22, 'X' => 25, 'Y' => 24,
+ 'Z' => 23
+ );
+
+ protected $_controllo = array(
+ '0' => 'A', '1' => 'B', '2' => 'C', '3' => 'D',
+ '4' => 'E', '5' => 'F', '6' => 'G', '7' => 'H',
+ '8' => 'I', '9' => 'J', '10' => 'K', '11' => 'L',
+ '12' => 'M', '13' => 'N', '14' => 'O', '15' => 'P',
+ '16' => 'Q', '17' => 'R', '18' => 'S', '19' => 'T',
+ '20' => 'U', '21' => 'V', '22' => 'W', '23' => 'X',
+ '24' => 'Y', '25' => 'Z'
+ );
+
+ /**
+ * Stringa di errore
+ */
+ protected $_error = null;
+
+ /**
+ * Separatore per la data di nascita
+ */
+ protected $_dateSeparator = '-';
+
+
+ /**
+ * Percorso del file del database SQLite
+ * dei codici catastali
+ */
+ protected $_dbCatastali = null;
+
+
+ /**
+ * Trasforma la stringa passata in un array di lettere
+ * e lo incrocia con un ulteriore array
+ */
+ protected function _getLettere($string, array $haystack) {
+ $letters = array();
+ foreach(str_split($string) as $needle) {
+ if (in_array($needle, $haystack)) {
+ $letters[] = $needle;
+ }
+ }
+ return $letters;
+ }
+
+ /**
+ * Ritorna un array con le vocali di una data stringa
+ */
+ protected function _getVocali($string) {
+ return $this->_getLettere($string, $this->_vocali);
+ }
+
+ /**
+ * Ritorna un array con le consonanti di una data stringa
+ */
+ protected function _getConsonanti($string) {
+ return $this->_getLettere($string, $this->_consonanti);
+ }
+
+ /**
+ * Pulisce la stringa filtrando tutti i caratteri che
+ * non sono lettere. Lo switch $toupper se impostato a TRUE
+ * converte la stringa risultante in MAIUSCOLO.
+ */
+ protected function _sanitize($string, $toupper = true) {
+ $result = preg_replace('/[^A-Za-z]*/', '', $string);
+ return ($toupper) ? strtoupper($result) : $result;
+ }
+
+ /**
+ * Se la stringa passata a funzione e' costituita
+ * da meno di 3 caratteri, rimpiazza le lettere
+ * mancanti con la lettera X.
+ */
+ protected function _addMissingX($string) {
+ $code = $string;
+ while(strlen($code) < 3) {
+ $code .= 'X';
+ }
+ return $code;
+ }
+
+ /**
+ * Ottiene il codice identificativo del nome
+ */
+ protected function _calcolaNome($string) {
+ $nome = $this->_sanitize($string);
+
+ // Se il nome inserito e' piu' corto di 3 lettere
+ // si aggiungono tante X quanti sono i caratteri
+ // mancanti.
+ if (strlen($nome) < 3) {
+ return $this->_addMissingX($nome);
+ }
+
+ $nome_cons = $this->_getConsonanti($nome);
+ $code = "";
+ // Se le consonanti contenute nel nome sono minori
+ // o uguali a 3 vengono considerate nell'ordine in cui
+ // compaiono.
+ if (count($nome_cons) <= 3) {
+ $code = implode('', $nome_cons);
+ } else {
+ // Se invece abbiamo almeno 4 consonanti, prendiamo
+ // la prima, la terza e la quarta.
+ for($i=0; $i<4; $i++) {
+ if ($i == 1) continue;
+ if (!empty($nome_cons[$i])) {
+ $code .= $nome_cons[$i];
+ }
+ }
+ }
+
+ // Se compaiono meno di 3 consonanti nel nome, si
+ // utilizzano le vocali, nell'ordine in cui compaiono
+ // nel nome.
+ if (strlen($code) < 3) {
+ $nome_voc = $this->_getVocali($nome);
+ while (strlen($code) < 3) {
+ $code .= array_shift($nome_voc);
+ }
+ }
+
+ return $code;
+ }
+
+ protected function _calcolaCognome($string) {
+ $cognome = $this->_sanitize($string);
+ $code = "";
+
+ // Se il cognome inserito e' piu' corto di 3 lettere
+ // si aggiungono tante X quanti sono i caratteri
+ // mancanti.
+ if (strlen($cognome) < 3) {
+ return $this->_addMissingX($cognome);
+ }
+
+ $cognome_cons = $this->_getConsonanti($cognome);
+
+ // Per il calcolo del cognome si prendono le prime
+ // 3 consonanti.
+ for ($i=0; $i<3; $i++) {
+ if (array_key_exists($i, $cognome_cons)) {
+ $code .= $cognome_cons[$i];
+ }
+ }
+
+ // Se le consonanti non bastano, vengono prese
+ // le vocali nell'ordine in cui compaiono.
+ if (strlen($code) < 3) {
+ $cognome_voc = $this->_getVocali($cognome);
+ while (strlen($code) < 3) {
+ $code .= array_shift($cognome_voc);
+ }
+ }
+
+ return $code;
+ }
+
+ /**
+ * Imposta il separatore di data ( default: / )
+ */
+ public function setDateSeparator($char) {
+ $this->_dateSeparator = $char;
+ return $this;
+ }
+
+ /**
+ * Ritorna la parte di codice fiscale corrispondente
+ * alla data di nascita del soggetto (Forma: AAMGG)
+ */
+ protected function _calcolaDataNascita($data, $sesso) {
+ $dn = explode($this->_dateSeparator, $data);
+
+ $giorno = (int) @$dn[2];
+ $mese = (int) @$dn[1];
+ $anno = (int) @$dn[0];
+
+ // Le ultime due cifre dell'anno di nascita
+ $aa = substr($anno, -2);
+
+ // La lettera corrispondente al mese di nascita
+ $mm = $this->_mesi[$mese];
+
+ // Il giorno viene calcolato a seconda del sesso
+ // del soggetto di cui si calcola il codice:
+ // se e' Maschio si mette il giorno reale, se e'
+ // Femmina viene aggiungo 40 a questo numero.
+ $gg = (strtoupper($sesso) == 'M') ? $giorno : ($giorno + 40);
+
+ // Bug #1: Thanks to Luca
+ if (strlen($gg) < 2) $gg = '0' . $gg;
+
+
+ return $aa . $mm . $gg;
+ }
+
+
+
+ /**
+ * Ritorna la cifra di controllo sulla base dei
+ * 15 caratteri del codice fiscale calcolati.
+ */
+ protected function _calcolaCifraControllo($codice) {
+ $code = str_split($codice);
+ $sum = 0;
+
+ for($i=1; $i <= count($code); $i++) {
+ $cifra = $code[$i-1];
+ $sum += ($i % 2) ? $this->_dispari[$cifra] : $this->_pari[$cifra];
+ }
+
+ $sum %= 26;
+
+ return $this->_controllo[$sum];
+ }
+
+
+ /**
+ * Imposta il messaggio di errore
+ */
+ protected function _setError($string) {
+ $this->_error = $string;
+ }
+
+ /**
+ * Verifica la presenza di un errore.
+ * Ritorna TRUE se presente, FALSE altrimenti.
+ */
+ public function hasError() {
+ return !is_null($this->_error);
+ }
+
+ /**
+ * Ritorna la stringa di errore
+ */
+ public function getError() {
+ return $this->_error;
+ }
+
+ /**
+ * Ritorna il codice fiscale utilizzando i parametri
+ * passati a funzione. Se si verifica
+ */
+ public function calculate($nome, $cognome, $data, $sesso, $codice_catastale_comune) {
+ $codice = $this->_calcolaCognome($cognome) .
+ $this->_calcolaNome($nome) .
+ $this->_calcolaDataNascita($data, $sesso) .
+ $codice_catastale_comune;
+
+ if ($this->hasError()) {
+ return false;
+ }
+
+ $codice .= $this->_calcolaCifraControllo($codice);
+
+ if (strlen($codice) != 16) {
+ $this->_setError(self::ERR_GENERIC);
+ return false;
+ }
+
+ return $codice;
+ }
+}
\ No newline at end of file
diff --git a/classes/utility/Plugins/Validations.php b/classes/utility/Plugins/Validations.php
new file mode 100644
index 0000000..503f87d
--- /dev/null
+++ b/classes/utility/Plugins/Validations.php
@@ -0,0 +1,122 @@
+9){
+ $secondo=$secondo-9;
+ }
+
+ $primo+=$secondo;
+
+ }
+ if( (10-$primo%10)%10 != ord($variabile[10])-ord('0') ){
+ return false;
+ }
+
+
+ return true;
+
+ }
+}
\ No newline at end of file
diff --git a/classes/utility/VisEngine/VisRequest.php b/classes/utility/VisEngine/VisRequest.php
index 8b3597c..8aac5cb 100644
--- a/classes/utility/VisEngine/VisRequest.php
+++ b/classes/utility/VisEngine/VisRequest.php
@@ -20,6 +20,8 @@ function __construct($visura)
$this->id = NULL;
$this->statoRichiesta = NULL;
$this->ricerche = [];
+ $this->document = NULL;
+ $this->format_errror = [];
foreach($visura->data->json_struttura->campi as $k => $v){
$this->variables[$k] = FALSE;
}
@@ -45,13 +47,15 @@ function setJson(object $data){
if(!isset($this->variables[$k])){
throw new \OpenApi\classes\exception\OpenApiVisEngineException("Visengine you are setting $k json key, but $k key is not presente for {$this->visura->data->nome_visura}",40006);
}
- $this->variables[$k] = TRUE;
+ $this->variables[$k] = $v!=NULL;
}
$this->json = $data;
$this->validaJSON();
return $this->jsonValido;
}
+
+
@@ -143,6 +147,39 @@ function getTargetEmail(){
return $this->email_target;
}
+ function hasSearchResult(){
+ return $this->visura->data->ricerca == 1 && $this->getStatoRichiesta() == "In ricerca" && $this->getStatoRicerca() == "Ricerca evasa";
+ }
+
+ function getSearchResult(){
+ if(count($this->ricerche) == NULL){
+ return FALSE;
+ }
+ return json_decode($this->ricerche[count($this->ricerche) - 1]->json_risultato);
+ }
+ function getSearchId(){
+ if(count($this->ricerche) == NULL){
+ return FALSE;
+ }
+ return $this->ricerche[count($this->ricerche) - 1]->id_ricerca;
+ }
+
+ function getSearchCount(){
+ return count($this->ricerche);
+ }
+
+ function setDocument($document){
+ $this->document = $document;
+ }
+
+ function getDocument(){
+ return $this->document;
+ }
+
+ function getHash(){
+ return $this->visura->data->hash_visura;
+ }
+
/**
*
@@ -171,12 +208,178 @@ function getTest(){
* @return boolean
*/
private function validaJSON(){
+ if(!$this->validaPresenzaCampi()){
+ $this->format_errror = [];
+ $this->jsonValido = FALSE;
+ return;
+ }
+ $this->format_errror = [];
+ if(!$this->validaFormatoCampi()){
+ $this->jsonValido = FALSE;
+ return;
+ }
+ $this->jsonValido = TRUE;
+
+ }
+
+ private function validaFormatoCampi(){
+ $error = FALSE;
+// var_dump($this->visura->data->json_struttura->campi);exit;
+
+ //cod_comune
+ //cod_provincia
+ //codice_fiscale_persona_fisica
+ foreach($this->visura->data->json_struttura->campi as $key => $campo){
+ if(!isset($this->json->$key) || $this->json->$key == ""){
+ continue;
+ }
+ if(isset($campo->tipo) && $campo->tipo == 'codice_fiscale_persona_fisica'){
+ $val = new \OpenApi\classes\utility\Plugins\Validations();
+ if(!$val->italianFiscalCode($this->json->$key)){
+ $this->format_errror[$key] = 'codice_fiscale_persona_fisica';
+ $error = TRUE;
+ }
+ }
+
+ if(isset($campo->tipo) && $campo->tipo == 'partita_iva'){
+ $val = new \OpenApi\classes\utility\Plugins\Validations();
+ if(!$val->italianFiscalCode($this->json->$key) && !$val->italianVat($this->json->$key)){
+ $this->format_errror[$key] = 'partita_iva';
+ $error = TRUE;
+ }
+ }
+
+ if(isset($campo->tipo) && $campo->tipo == 'codice_fiscale'){
+ $val = new \OpenApi\classes\utility\Plugins\Validations();
+ if(!$val->italianFiscalCode($this->json->$key) && !$val->italianVat($this->json->$key)){
+ $this->format_errror[$key] = 'codice_fiscale';
+ $error = TRUE;
+ }
+ }
+ if(isset($campo->tipo) && $campo->tipo == 'cod_comune'){
+ $re = '/^[a-zA-Z]{1}[0-9]{3}$/m';
+
+ preg_match_all($re, $this->json->$key, $matches, PREG_SET_ORDER, 0);
+ if(count($matches) == 0){
+ $this->format_errror[$key] = 'cod_comune';
+ $error = TRUE;
+ }
+ }
+
+ if(isset($campo->tipo) && $campo->tipo == 'cod_provincia'){
+ $re = '/^[a-zA-Z]{2}$/m';
+
+ preg_match_all($re, $this->json->$key, $matches, PREG_SET_ORDER, 0);
+ if(count($matches) == 0){
+ $this->format_errror[$key] = 'cod_provincia';
+ $error = TRUE;
+ }
+ }
+ if(isset($campo->tipo) && $campo->tipo == 'data_iso8601'){
+ $d = \DateTime::createFromFormat("d-m-Y", $this->json->$key);
+
+ if(!($d && $d->format('d-m-Y') === $this->json->$key)){
+ $this->format_errror[$key] = 'data_iso8601';
+ $error = TRUE;
+ }
+ }
+ }
+ return !$error;
+ }
+
+ private function validaPresenzaCampi(){
$re = '/\$(\d)+/m';
$validazione = $this->visura->data->json_struttura->validazione;
$subst = '$this->variables[\'$0\']';
-
- $validazione = '$this->jsonValido = ' .preg_replace($re, $subst, $validazione).";";
+ $valida = TRUE;
+ $validazione = '$valida = ' .preg_replace($re, $subst, $validazione).";";
eval($validazione);
+ return $valida;
+ }
+
+ public function getErrors(){
+ if(count($this->format_errror) != 0){
+ $ret['error_type'] = "format";
+ $ret['error'] = $this->format_errror;
+ return $ret;
+ }
+ $this->expr = [];
+ $validazione = $this->visura->data->json_struttura->validazione;
+
+ list($validazione, $expr) =$this->createExpression($validazione);
+
+ //var_dump($validazione);exit;
+ $errori = $this->valida($validazione, $expr);
+
+ $ret['error_type'] = "empty_fields";
+ $ret['error'] = $errori;
+ return $ret;
+
+ }
+
+ private function valida($validazione,$expr, $errori = []){
+ //var_dump($this->variables);
+ $errori = ["type"=>"and","list"=>[]];
+ $and = explode('&&',$validazione);
+ foreach($and as $andItem){
+ $andItem = trim($andItem);
+ $or = explode('||',$andItem);
+ if(count($or) == 1){
+ $orItem = $or[0];
+ if(substr($orItem,0,1)=='$'){
+ if(!$this->variables[$orItem]){
+ $errori['list'][] = $orItem;
+ }
+ }else{
+ $errors = $this->valida($expr[str_replace("e","",$orItem)], $expr);
+ if(count($errors)){
+
+ $errori['list'] = array_merge($errori['list'], $errors['list']);
+
+ }
+ }
+ }else{
+ $errore = false;
+ $item = array();
+ $hasError = true;
+ foreach($or as $orItem){
+ $orItem = trim($orItem);
+ if(substr($orItem,0,1)=='$'){
+ $item[] = $orItem;
+ if($this->variables[$orItem]){
+
+ $hasError = FALSE;
+ }
+ }else{
+ $errors = $this->valida($expr[str_replace("e","",$orItem)], $expr);
+ if(count($errors['list'])){
+ $item[] = $errors;
+ }else{
+ $hasError = FALSE;
+ }
+ }
+ }
+
+ if($hasError){
+ $errori['list'][] = ["type"=>"or","list"=>$item];
+ }
+ }
+ }
+
+ return $errori;
+ }
+
+ private function createExpression($validazione, $expr = []){
+ $preg = "/\(([$\d&| e]*?)\)/";
+ preg_match($preg, $validazione, $matches, PREG_OFFSET_CAPTURE, 0);
+ if(isset($matches[0]) && isset($matches[1])){
+ $expr[] = $matches[1][0];
+ $expn = count($expr)-1;
+ $validazione = str_replace($matches[0],"e{$expn}",$validazione);
+ return $this->createExpression($validazione, $expr);
+ }
+ return array($validazione, $expr);
+
}
function getId() {
@@ -197,7 +400,7 @@ function setStatoRichiesta($statoRichiesta) {
function getRicerche() {
return $this->ricerche;
- }
+ }
function setRicerche($ricerche) {
$this->ricerche = $ricerche;
@@ -209,4 +412,8 @@ function getStatoRicerca(){
}
return $this->ricerche[count($this->ricerche) - 1]->stato_ricerca;
}
+
+ function getValidation(){
+ return $validazione = $this->visura->data->json_struttura->validazione;;
+ }
}
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..f399979
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,18 @@
+{
+ "name": "Altravia/OpenApi",
+ "description": "My first Composer project",
+ "authors": [
+ {
+ "name": "Altravia",
+ "email": "info@altravia.com"
+ }
+ ],
+ "minimum-stability": "production",
+ "require": {
+ "php": ">=7.2.0"
+ },
+ "autoload": {
+ "psr-0": {
+ "OpenApi": "OpenApi/"
+ }
+ }
\ No newline at end of file
From 8c8e304b0f99a81621029febf8cc2e782eb49a94 Mon Sep 17 00:00:00 2001
From: pberanrdiniAltravia
<68341384+pberanrdiniAltravia@users.noreply.github.com>
Date: Tue, 29 Sep 2020 11:52:58 +0200
Subject: [PATCH 05/85] modificato package.json
---
composer.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index f399979..d2035c9 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "Altravia/OpenApi",
- "description": "My first Composer project",
+ "description": "Librerie OpenApi PHP (https://openapi.it)",
"authors": [
{
"name": "Altravia",
@@ -15,4 +15,4 @@
"psr-0": {
"OpenApi": "OpenApi/"
}
- }
\ No newline at end of file
+ }
From ae31a55f149849f338dfd726a6a34034b2540406 Mon Sep 17 00:00:00 2001
From: pberanrdiniAltravia
<68341384+pberanrdiniAltravia@users.noreply.github.com>
Date: Tue, 29 Sep 2020 12:01:58 +0200
Subject: [PATCH 06/85] errore sul packee.json
---
composer.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/composer.json b/composer.json
index d2035c9..3a8c781 100644
--- a/composer.json
+++ b/composer.json
@@ -16,3 +16,4 @@
"OpenApi": "OpenApi/"
}
}
+}
From 571b5f660b17f316817884d9f7140fe0e1874e72 Mon Sep 17 00:00:00 2001
From: pberanrdiniAltravia
<68341384+pberanrdiniAltravia@users.noreply.github.com>
Date: Tue, 29 Sep 2020 12:05:15 +0200
Subject: [PATCH 07/85] modificato il package
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 3a8c781..aefde13 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,5 @@
{
- "name": "Altravia/OpenApi",
+ "name": "openapi/openapi",
"description": "Librerie OpenApi PHP (https://openapi.it)",
"authors": [
{
From 9e7ef0b09bcd411646c38a02d568bef42ad444bb Mon Sep 17 00:00:00 2001
From: pberanrdiniAltravia
<68341384+pberanrdiniAltravia@users.noreply.github.com>
Date: Tue, 29 Sep 2020 12:06:31 +0200
Subject: [PATCH 08/85] modificato vendor name
---
composer.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index aefde13..3618995 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
- "name": "openapi/openapi",
- "description": "Librerie OpenApi PHP (https://openapi.it)",
+ "name": "altravia/openapi",
+ "description": "OpenApi PHP Libraries (https://openapi.it)",
"authors": [
{
"name": "Altravia",
From 75f9160b66d096090cf0ed8675688ee6f2117865 Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Tue, 29 Sep 2020 12:10:33 +0200
Subject: [PATCH 09/85] spostato il sorgente dentro src
---
_config.yml | 1 -
OpenApi.php => src/OpenApi.php | 0
{classes => src/classes}/Comuni.php | 0
{classes => src/classes}/Geocoding.php | 0
{classes => src/classes}/Imprese.php | 0
{classes => src/classes}/MarcheTemporali.php | 0
{classes => src/classes}/OpenApiBase.php | 0
{classes => src/classes}/UfficioPostale.php | 0
{classes => src/classes}/VisEngine.php | 0
.../classes}/exception/OpenApiConnectionsException.php | 0
{classes => src/classes}/exception/OpenApiExceptionBase.php | 0
.../classes}/exception/OpenApiMarcheTemporaliException.php | 0
{classes => src/classes}/exception/OpenApiTokenException.php | 0
{classes => src/classes}/exception/OpenApiVisEngineException.php | 0
{classes => src/classes}/utility/CacheSystemInterface.php | 0
{classes => src/classes}/utility/DummyCache.php | 0
{classes => src/classes}/utility/Plugins/FiscalCode.php | 0
{classes => src/classes}/utility/Plugins/Validations.php | 0
{classes => src/classes}/utility/VisEngine/VisRequest.php | 0
{classes => src/classes}/utility/ci4SessionStoreToken.php | 0
{classes => src/classes}/utility/sessionStoreToken.php | 0
{classes => src/classes}/utility/storeTokenInterface.php | 0
22 files changed, 1 deletion(-)
delete mode 100644 _config.yml
rename OpenApi.php => src/OpenApi.php (100%)
rename {classes => src/classes}/Comuni.php (100%)
rename {classes => src/classes}/Geocoding.php (100%)
rename {classes => src/classes}/Imprese.php (100%)
rename {classes => src/classes}/MarcheTemporali.php (100%)
rename {classes => src/classes}/OpenApiBase.php (100%)
rename {classes => src/classes}/UfficioPostale.php (100%)
rename {classes => src/classes}/VisEngine.php (100%)
rename {classes => src/classes}/exception/OpenApiConnectionsException.php (100%)
rename {classes => src/classes}/exception/OpenApiExceptionBase.php (100%)
rename {classes => src/classes}/exception/OpenApiMarcheTemporaliException.php (100%)
rename {classes => src/classes}/exception/OpenApiTokenException.php (100%)
rename {classes => src/classes}/exception/OpenApiVisEngineException.php (100%)
rename {classes => src/classes}/utility/CacheSystemInterface.php (100%)
rename {classes => src/classes}/utility/DummyCache.php (100%)
rename {classes => src/classes}/utility/Plugins/FiscalCode.php (100%)
rename {classes => src/classes}/utility/Plugins/Validations.php (100%)
rename {classes => src/classes}/utility/VisEngine/VisRequest.php (100%)
rename {classes => src/classes}/utility/ci4SessionStoreToken.php (100%)
rename {classes => src/classes}/utility/sessionStoreToken.php (100%)
rename {classes => src/classes}/utility/storeTokenInterface.php (100%)
diff --git a/_config.yml b/_config.yml
deleted file mode 100644
index c741881..0000000
--- a/_config.yml
+++ /dev/null
@@ -1 +0,0 @@
-theme: jekyll-theme-slate
\ No newline at end of file
diff --git a/OpenApi.php b/src/OpenApi.php
similarity index 100%
rename from OpenApi.php
rename to src/OpenApi.php
diff --git a/classes/Comuni.php b/src/classes/Comuni.php
similarity index 100%
rename from classes/Comuni.php
rename to src/classes/Comuni.php
diff --git a/classes/Geocoding.php b/src/classes/Geocoding.php
similarity index 100%
rename from classes/Geocoding.php
rename to src/classes/Geocoding.php
diff --git a/classes/Imprese.php b/src/classes/Imprese.php
similarity index 100%
rename from classes/Imprese.php
rename to src/classes/Imprese.php
diff --git a/classes/MarcheTemporali.php b/src/classes/MarcheTemporali.php
similarity index 100%
rename from classes/MarcheTemporali.php
rename to src/classes/MarcheTemporali.php
diff --git a/classes/OpenApiBase.php b/src/classes/OpenApiBase.php
similarity index 100%
rename from classes/OpenApiBase.php
rename to src/classes/OpenApiBase.php
diff --git a/classes/UfficioPostale.php b/src/classes/UfficioPostale.php
similarity index 100%
rename from classes/UfficioPostale.php
rename to src/classes/UfficioPostale.php
diff --git a/classes/VisEngine.php b/src/classes/VisEngine.php
similarity index 100%
rename from classes/VisEngine.php
rename to src/classes/VisEngine.php
diff --git a/classes/exception/OpenApiConnectionsException.php b/src/classes/exception/OpenApiConnectionsException.php
similarity index 100%
rename from classes/exception/OpenApiConnectionsException.php
rename to src/classes/exception/OpenApiConnectionsException.php
diff --git a/classes/exception/OpenApiExceptionBase.php b/src/classes/exception/OpenApiExceptionBase.php
similarity index 100%
rename from classes/exception/OpenApiExceptionBase.php
rename to src/classes/exception/OpenApiExceptionBase.php
diff --git a/classes/exception/OpenApiMarcheTemporaliException.php b/src/classes/exception/OpenApiMarcheTemporaliException.php
similarity index 100%
rename from classes/exception/OpenApiMarcheTemporaliException.php
rename to src/classes/exception/OpenApiMarcheTemporaliException.php
diff --git a/classes/exception/OpenApiTokenException.php b/src/classes/exception/OpenApiTokenException.php
similarity index 100%
rename from classes/exception/OpenApiTokenException.php
rename to src/classes/exception/OpenApiTokenException.php
diff --git a/classes/exception/OpenApiVisEngineException.php b/src/classes/exception/OpenApiVisEngineException.php
similarity index 100%
rename from classes/exception/OpenApiVisEngineException.php
rename to src/classes/exception/OpenApiVisEngineException.php
diff --git a/classes/utility/CacheSystemInterface.php b/src/classes/utility/CacheSystemInterface.php
similarity index 100%
rename from classes/utility/CacheSystemInterface.php
rename to src/classes/utility/CacheSystemInterface.php
diff --git a/classes/utility/DummyCache.php b/src/classes/utility/DummyCache.php
similarity index 100%
rename from classes/utility/DummyCache.php
rename to src/classes/utility/DummyCache.php
diff --git a/classes/utility/Plugins/FiscalCode.php b/src/classes/utility/Plugins/FiscalCode.php
similarity index 100%
rename from classes/utility/Plugins/FiscalCode.php
rename to src/classes/utility/Plugins/FiscalCode.php
diff --git a/classes/utility/Plugins/Validations.php b/src/classes/utility/Plugins/Validations.php
similarity index 100%
rename from classes/utility/Plugins/Validations.php
rename to src/classes/utility/Plugins/Validations.php
diff --git a/classes/utility/VisEngine/VisRequest.php b/src/classes/utility/VisEngine/VisRequest.php
similarity index 100%
rename from classes/utility/VisEngine/VisRequest.php
rename to src/classes/utility/VisEngine/VisRequest.php
diff --git a/classes/utility/ci4SessionStoreToken.php b/src/classes/utility/ci4SessionStoreToken.php
similarity index 100%
rename from classes/utility/ci4SessionStoreToken.php
rename to src/classes/utility/ci4SessionStoreToken.php
diff --git a/classes/utility/sessionStoreToken.php b/src/classes/utility/sessionStoreToken.php
similarity index 100%
rename from classes/utility/sessionStoreToken.php
rename to src/classes/utility/sessionStoreToken.php
diff --git a/classes/utility/storeTokenInterface.php b/src/classes/utility/storeTokenInterface.php
similarity index 100%
rename from classes/utility/storeTokenInterface.php
rename to src/classes/utility/storeTokenInterface.php
From 5f1be3bdf64f215e82644f0546a378ba9fd23fee Mon Sep 17 00:00:00 2001
From: pberanrdiniAltravia
<68341384+pberanrdiniAltravia@users.noreply.github.com>
Date: Tue, 29 Sep 2020 12:13:35 +0200
Subject: [PATCH 10/85] modificato composer.json
---
composer.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index 3618995..031aa1f 100644
--- a/composer.json
+++ b/composer.json
@@ -7,13 +7,13 @@
"email": "info@altravia.com"
}
],
- "minimum-stability": "production",
+ "minimum-stability": "stable",
"require": {
"php": ">=7.2.0"
},
"autoload": {
"psr-0": {
- "OpenApi": "OpenApi/"
+ "OpenApi": "src"
}
}
}
From f7cad4aeae55287008c37565c0e598f11c9a3bca Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Fri, 9 Oct 2020 15:16:40 +0200
Subject: [PATCH 11/85] aggiunti sms
---
src/OpenApi.php | 21 +-
src/classes/Comuni.php | 11 +-
src/classes/FirrmaDigitale.php | 16 ++
src/classes/Geocoding.php | 7 +
src/classes/OpenApiBase.php | 3 +-
src/classes/Sms.php | 125 +++++++++
src/classes/UfficioPostale.php | 12 +
src/classes/exception/OpenApiSMSException.php | 13 +
.../UfficioPostale/Objects/Recipient.php | 262 ++++++++++++++++++
.../utility/UfficioPostale/Objects/Sender.php | 237 ++++++++++++++++
.../utility/UfficioPostale/Raccomandata.php | 9 +
.../utility/UfficioPostale/ServiziPostali.php | 112 ++++++++
12 files changed, 821 insertions(+), 7 deletions(-)
create mode 100644 src/classes/FirrmaDigitale.php
create mode 100644 src/classes/Sms.php
create mode 100644 src/classes/exception/OpenApiSMSException.php
create mode 100644 src/classes/utility/UfficioPostale/Objects/Recipient.php
create mode 100644 src/classes/utility/UfficioPostale/Objects/Sender.php
create mode 100644 src/classes/utility/UfficioPostale/Raccomandata.php
create mode 100644 src/classes/utility/UfficioPostale/ServiziPostali.php
diff --git a/src/OpenApi.php b/src/OpenApi.php
index bc87789..292886e 100644
--- a/src/OpenApi.php
+++ b/src/OpenApi.php
@@ -46,9 +46,7 @@ function __construct(array $scopes, string $username, string $apikey, $environme
$this->apikey = $apikey;
$this->prefix = $prefix;
$this->scopes = $realScopes;
-
$token = $this->getToken();
- //var_dump($token);exit;
list($moduli,$nomi) = $this->getListaModuli();
$this->clients = [];
foreach($domains as $d){
@@ -61,6 +59,8 @@ function __construct(array $scopes, string $username, string $apikey, $environme
}
$this->validations = new \OpenApi\classes\utility\Plugins\Validations();
+ $this->fiscalCode = new \OpenApi\classes\utility\Plugins\FiscalCode();
+ //$this->geocoding = new \OpenApi\classes\Geocoding($token->token, [], $this->cache, "");
}
/**
@@ -83,6 +83,21 @@ private function getListaModuli(){
$moduli['comuni.openapi.it'] = "\\OpenApi\\classes\\Comuni";
$nomi['comuni.openapi.it'] = "comuni";
+
+
+ $moduli['ws.marchetemporali.com'] = "\\OpenApi\\classes\\MarcheTemporali";
+ $nomi['ws.marchetemporali.com'] = "marcheTemporali";
+
+
+ $moduli['geocoding.realgest.it'] = "\\OpenApi\\classes\\Geocoding";
+ $nomi['geocoding.realgest.it'] = "geocoding";
+
+ $moduli['ws.messaggisms.com'] = "\\OpenApi\\classes\\Sms";
+ $nomi['ws.messaggisms.com'] = "SMS";
+
+
+ $moduli['ws.firmadigitale.com'] = "\\OpenApi\\classes\\FirmaDigitale";
+ $nomi['ws.firmadigitale.com'] = "FirmaDigitale";
return array($moduli,$nomi);
}
@@ -205,7 +220,7 @@ function getOldToken(){
$tostore['scopes'] = serialize($this->scopes);
$tostore['username'] = $this->username;
$tostore['prefix'] = $this->prefix;
- $this->session->save($tostore);
+ $this->store->save($tostore);
return TRUE;
}
return FALSE;
diff --git a/src/classes/Comuni.php b/src/classes/Comuni.php
index b7da833..a86fca1 100644
--- a/src/classes/Comuni.php
+++ b/src/classes/Comuni.php
@@ -73,15 +73,20 @@ function getProvince($regione = NULL, $ttl = 86400){
return $province;
}
+
+ /**
+ * Restituisce la lista comuni a partire dalla provincia
+ * @param mixed $provincia provincia Es.: RM
+ * @param int $ttl time to reload cache
+ *
+ * @return array
+ */
function getComuni($provincia, $ttl = 86400){
$provincia = trim(\strtolower($provincia));
$data = $this->connect("province/$provincia", "GET", [], $ttl);
-
$comuni = $data->data;
- //sort($comuni->comuni);
- //usort($comuni->dettaglio_comuni,[$this, 'sortComune']);
return $comuni;
}
diff --git a/src/classes/FirrmaDigitale.php b/src/classes/FirrmaDigitale.php
new file mode 100644
index 0000000..de518c5
--- /dev/null
+++ b/src/classes/FirrmaDigitale.php
@@ -0,0 +1,16 @@
+basePath = "https://ws.firmadigitale.com";
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/classes/Geocoding.php b/src/classes/Geocoding.php
index ca81382..b0ec8bd 100644
--- a/src/classes/Geocoding.php
+++ b/src/classes/Geocoding.php
@@ -12,6 +12,13 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
$this->basePath = "https://geocoding.realgest.it";
}
+ /**
+ * Restituisce le coordinate geografiche a partire dall'indirizzo
+ * @param string $address Indirizzo
+ * @param int $ttl Tempo in cui la risposta resta in cahce
+ *
+ * @return object
+ */
function geocode(string $address, $ttl = 86400){
$data = $this->connect("geocode", "POST", ["address" => $address], $ttl, TRUE);
diff --git a/src/classes/OpenApiBase.php b/src/classes/OpenApiBase.php
index 6b75432..3e5f602 100644
--- a/src/classes/OpenApiBase.php
+++ b/src/classes/OpenApiBase.php
@@ -97,6 +97,7 @@ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr =
if(!$force){
$this->checkHasScope($url, $type);
}
+
if($type == "GET" && $ttr > 0 && $ret = $this->getCacheObject($url)) {
return $ret;
@@ -121,7 +122,7 @@ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr =
curl_setopt($ch,CURLOPT_HTTPHEADER,array("Authorization: Bearer ".$this->token));
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
- //var_dump($response);exit;
+ // var_dump($response);exit;
$this->rawResponse = $response;
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$this->header = substr($response, 0, $header_size);
diff --git a/src/classes/Sms.php b/src/classes/Sms.php
new file mode 100644
index 0000000..0a05d9d
--- /dev/null
+++ b/src/classes/Sms.php
@@ -0,0 +1,125 @@
+basePath = "https://ws.messaggisms.com";
+ $this->messageId = NULL;
+ }
+
+ function addRecipeints($recipients, $finish = false){
+ if($this->messageId == NULL){
+ throw new \OpenApi\classes\exception\OpenApiSMSException("No message id presente",40010);
+ exit;
+ }
+ $data = $this->addRecipeintsByMessageId($this->messageId, $recipients, $finish );
+ if($finish){
+ $this->messageId = NULL;
+ }
+ return $data;
+ }
+
+ function addRecipeintsByMessageId($messageId, $recipients, $finish = false){
+ $param['recipients'] = $recipients;
+ $param['transaction'] = !$finish;
+ try{
+ $data = $this->connect("messages/$messageId", "PUT", $param);
+
+ return $data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+ exit;
+ }
+ }
+
+ function getRecipients($messageId, $number = NULL){
+ try{
+ $data = $this->connect("messages/$messageId/recipients/".$number, "GET", []);
+ return $data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+ exit;
+ }
+ }
+
+ function getMessage($messageId){
+ try{
+ $data = $this->connect("messages/$messageId", "GET", []);
+ return $data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+ exit;
+ }
+ }
+
+ function sendMore($sender, $recipients, $text, $transaction = false, $priority = 1,$options = NULL, $test = false){
+
+ $param['test'] = $test;
+ $param['sender'] = $sender;
+ $param['recipients'] = $recipients;
+ $param['body'] = $text;
+ $param['transaction'] = $transaction;
+ if($options != NULL){
+ $param['priority'] = $priority;
+ }
+ try{
+ $data = $this->connect("messages/", "POST", $param);
+ if(isset($data->data[0]) && $transaction){
+ $this->messageId =$data->data[0]->id;
+ }
+ return $data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+ exit;
+ }
+ }
+
+
+ function sendOne($sender, $recipient, $text, $prefix = NULL, $priority = 1,$options = NULL, $test = false){
+ if($prefix != NULL){
+ $recipient = $prefix."-".$recipient;
+ }
+
+ $param['test'] = $test;
+ $param['sender'] = $sender;
+ $param['recipients'] = $recipient;
+ $param['body'] = $text;
+ $param['transaction'] = FALSE;
+ if($options != NULL){
+ $param['priority'] = $priority;
+ }
+
+ try{
+ $data = $this->connect("messages/", "POST", $param);
+
+ return $data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+ exit;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/classes/UfficioPostale.php b/src/classes/UfficioPostale.php
index ac83477..1bb0a49 100644
--- a/src/classes/UfficioPostale.php
+++ b/src/classes/UfficioPostale.php
@@ -12,6 +12,18 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
$this->basePath = "https://ws.ufficiopostale.com";
}
+
+ /**
+ * Restiuisce un oggetto di tipo raccomandata
+ * @return object
+ */
+ function createRaccomandata(){
+ return new \OpenApi\classes\utility\UfficioPostale\Raccomandata($this->connect);
+ }
+
+ //function createRaccomandataByData()
+
+
diff --git a/src/classes/exception/OpenApiSMSException.php b/src/classes/exception/OpenApiSMSException.php
new file mode 100644
index 0000000..c9ead61
--- /dev/null
+++ b/src/classes/exception/OpenApiSMSException.php
@@ -0,0 +1,13 @@
+errors = null;
+ $this->data = new \stdClass();
+ $this->data->firstName = NULL;
+ $this->data->secondName = NULL;
+ $this->data->companyName = NULL;
+ $this->data->at = NULL;
+ $this->data->title = NULL;
+ $this->data->dug = NULL;
+ $this->data->address = NULL;
+ $this->data->huoseNumber = NULL;
+ $this->data->city = NULL;
+ $this->data->zip = NULL;
+ $this->data->province = NULL;
+ $this->data->country = "Italia";
+ $this->data->email = NULL;
+
+
+ $this->itData = new \stdClass();
+ $this->itData->nome = NULL;
+ $this->itData->cognome = NULL;
+ $this->itData->ragione_sociale = NULL;
+ $this->itData->co = NULL;
+ $this->itData->titolo = NULL;
+ $this->itData->dug = NULL;
+ $this->itData->indirizzo = NULL;
+ $this->itData->civico = NULL;
+ $this->itData->comune = NULL;
+ $this->itData->cap = NULL;
+ $this->itData->provincia = NULL;
+ $this->itData->nazione = "Italia";
+ $this->itData->email = NULL;
+
+ $this->validate = false;
+
+ if($recipient == NULL){
+ $this->createFromObject($recipient);
+ }
+ }
+
+ public function createFromObject($object){
+ $this->data->title = isset($object->title)?$object->title:(isset($object->titolo)?$object->titolo:NULL);
+ $this->data->at = isset($object->at)?$object->at:(isset($object->co)?$object->co:NULL);
+ $this->data->firstName = isset($object->firstName)?$object->firstName:(isset($object->nome)?$object->nome:NULL);
+ $this->data->secondName = isset($object->secondName)?$object->secondName:(isset($object->cognome)?$object->cognome:NULL);
+ $this->data->companyName = isset($object->companyName)?$object->companyName:(isset($object->ragione_sociale)?$object->ragione_sociale:NULL);
+ $this->data->dug = isset($object->dug)?$object->dug:NULL;
+ $this->data->address = isset($object->address)?$object->address:(isset($object->indirizzo)?$object->indirizzo:NULL);
+ $this->data->huoseNumber = isset($object->huoseNumber)?$object->huoseNumber:(isset($object->civico)?$object->civico:NULL);
+ $this->data->city = isset($object->city)?$object->city:(isset($object->comune)?$object->comune:NULL);
+ $this->data->zip = isset($object->zip)?$object->zip:(isset($object->cap)?$object->cap:NULL);
+ $this->data->province = isset($object->province)?$object->province:(isset($object->provincia)?$object->provincia:NULL);
+ $this->data->country = isset($object->country)?$object->country:(isset($object->nazione)?$object->nazione:"Italia");
+ $this->data->email = isset($object->email)?$object->email:NULL;
+
+
+ $this->itData->co = $this->data->at;
+ $this->itData->titolo = $this->data->title;
+ $this->itData->nome = $this->data->firstName;
+ $this->itData->cognome = $this->data->secondName;
+ $this->itData->ragione_sociale = $this->data->companyName;
+ $this->itData->dug = $this->data->dug;
+ $this->itData->indirizzo = $this->data->address;
+ $this->itData->civico = $this->data->huoseNumber;
+ $this->itData->comune = $this->data->city;
+ $this->itData->cap = $this->data->zip;
+ $this->itData->provincia = $this->data->province;
+ $this->itData->nazione = $this->data->country;
+ $this->itData->email = $this->data->email;
+
+ }
+
+ public function getObject($itNames = FALSE){
+ if(!$itNames){
+ return $this->data;
+ }
+ return $this->itData;
+ }
+
+ public function getTitle(){
+ return $this->data->title;
+ }
+
+ public function getAt(){
+ return $this->data->at;
+ }
+
+ public function getFirstName(){
+ return $this->data->firstName;
+ }
+ public function getSecondName(){
+ return $this->data->secondName;
+ }
+
+ public function getCompanyName(){
+ return $this->data->companyName;
+ }
+ public function getDug(){
+ return $this->data->dug;
+ }
+ public function getAddress(){
+ return $this->data->address;
+ }
+ public function getHuoseNumber(){
+ return $this->data->huoseNumber;
+ }
+ public function getCity(){
+ return $this->data->city;
+ }
+ public function getZip(){
+ return $this->data->zip;
+ }
+ public function getProvince(){
+ return $this->data->province;
+ }
+ public function getCountry(){
+ return $this->data->country;
+ }
+ public function getEmail(){
+ return $this->data->email;
+ }
+
+ public function setTitle(string $title){
+ $this->data->title = $title;
+ $this->itData->titolo = $title;
+ }
+
+ public function setAt(string $at){
+ $this->data->at = $at;
+ $this->itData->co = $at;
+ }
+
+ public function setFirstName(string $firstName){
+ $this->data->firstName = $firstName;
+ $this->itData->nome = $firstName;
+ }
+
+ public function setSecondName(string $secondName){
+ $this->data->secondName = $secondName;
+ $this->itData->cognome = $secondName;
+ }
+
+ public function setCompanyName(string $companyName){
+ $this->data->companyName = $companyName;
+ $this->itData->ragione_sociale = $companyName;
+ }
+
+ public function setDug(string $dug){
+ $this->data->dug = $dug;
+ $this->itData->dug = $dug;
+ }
+
+ public function setAddress(string $address){
+ $this->data->address = $address;
+ $this->itData->indirizzo = $address;
+ }
+ public function setHuoseNumber(string $huoseNumber){
+ $this->data->huoseNumber = $huoseNumber;
+ $this->itData->civico = $huoseNumber;
+ }
+
+ public function setCity(string $city){
+ $this->data->city = $city;
+ $this->itData->comune = $city;
+ }
+
+ public function setZip(string $zip){
+ $this->data->zip = $zip;
+ $this->itData->cap = $zip;
+ }
+
+ public function setProvince(string $province){
+ $this->data->province = $province;
+ $this->itData->privincia = $province;
+ }
+
+ public function setCountry(string $country){
+ $this->data->country = $country;
+ $this->itData->nazione = $country;
+ }
+
+ public function setEmail(string $email){
+ $this->data->email = $email;
+ $this->itData->email = $email;
+ }
+
+ public function getErrors($validate = TRUE){
+ if($validate){
+ $this->validate();
+ }
+
+ return $this->errors;
+ }
+
+ public function validate(){
+ $this->errors = [];
+ if($this->data->zip == NULL){
+ $this->errors['zip'] = (object)[
+ "code"=> "required",
+ "text"=>"zip field is required"
+ ];
+ } else if($this->data->country == "Italia" || $this->data->country == "Italy"){
+ $re = '/^\d{5}$/';
+ preg_match($re, $this->data->zip, $matches, PREG_OFFSET_CAPTURE, 0);
+ if(count($matches) == 0){
+ $this->errors['zip'] = (object)[
+ "code"=> "5_digit",
+ "text"=>"Italian ZIP must be 5 digits"
+ ];
+ }
+ }
+
+ if($this->data->city == NULL){
+ $this->errors['city'] = (object)[
+ "code"=> "required",
+ "text"=>"city is required"
+ ];
+ }
+
+ if($this->data->province == NULL){
+ $this->errors['province'] = (object)[
+ "code"=> "required",
+ "text"=>"province is required"
+ ];
+ }
+
+
+ if($this->data->dug == NULL){
+ $this->errors['dug'] = (object)[
+ "code"=> "required",
+ "text"=>"dug is required"
+ ];
+ }
+
+ if($this->data->address == NULL){
+ $this->errors['address'] = (object)[
+ "code"=> "required",
+ "text"=>"address is required"
+ ];
+ }
+
+ if($this->data->huoseNumber == NULL){
+ $this->errors['huoseNumber'] = (object)[
+ "code"=> "required",
+ "text"=>"huose number is required"
+ ];
+ }
+
+
+ $this->validate = count($this->errors) == 0;
+ return $this->validate;
+ }
+
+}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/Objects/Sender.php b/src/classes/utility/UfficioPostale/Objects/Sender.php
new file mode 100644
index 0000000..8ec3690
--- /dev/null
+++ b/src/classes/utility/UfficioPostale/Objects/Sender.php
@@ -0,0 +1,237 @@
+errors = null;
+ $this->data = new \stdClass();
+ $this->data->firstName = NULL;
+ $this->data->secondName = NULL;
+ $this->data->companyName = NULL;
+ $this->data->dug = NULL;
+ $this->data->address = NULL;
+ $this->data->huoseNumber = NULL;
+ $this->data->city = NULL;
+ $this->data->zip = NULL;
+ $this->data->province = NULL;
+ $this->data->country = "Italia";
+ $this->data->email = NULL;
+
+
+ $this->itData = new \stdClass();
+ $this->itData->nome = NULL;
+ $this->itData->cognome = NULL;
+ $this->itData->ragione_sociale = NULL;
+ $this->itData->dug = NULL;
+ $this->itData->indirizzo = NULL;
+ $this->itData->civico = NULL;
+ $this->itData->comune = NULL;
+ $this->itData->cap = NULL;
+ $this->itData->provincia = NULL;
+ $this->itData->nazione = "Italia";
+ $this->itData->email = NULL;
+
+ $this->validate = false;
+
+ if($sender == NULL){
+ $this->createFromObject($sender);
+ }
+ }
+
+ public function createFromObject($object){
+ $this->data->firstName = isset($object->firstName)?$object->firstName:(isset($object->nome)?$object->nome:NULL);
+ $this->data->secondName = isset($object->secondName)?$object->secondName:(isset($object->cognome)?$object->cognome:NULL);
+ $this->data->companyName = isset($object->companyName)?$object->companyName:(isset($object->ragione_sociale)?$object->ragione_sociale:NULL);
+ $this->data->dug = isset($object->dug)?$object->dug:NULL;
+ $this->data->address = isset($object->address)?$object->address:(isset($object->indirizzo)?$object->indirizzo:NULL);
+ $this->data->huoseNumber = isset($object->huoseNumber)?$object->huoseNumber:(isset($object->civico)?$object->civico:NULL);
+ $this->data->city = isset($object->city)?$object->city:(isset($object->comune)?$object->comune:NULL);
+ $this->data->zip = isset($object->zip)?$object->zip:(isset($object->cap)?$object->cap:NULL);
+ $this->data->province = isset($object->province)?$object->province:(isset($object->provincia)?$object->provincia:NULL);
+ $this->data->country = isset($object->country)?$object->country:(isset($object->nazione)?$object->nazione:"Italia");
+ $this->data->email = isset($object->email)?$object->email:NULL;
+
+
+ $this->itData->nome = $this->data->firstName;
+ $this->itData->cognome = $this->data->secondName;
+ $this->itData->ragione_sociale = $this->data->companyName;
+ $this->itData->dug = $this->data->dug;
+ $this->itData->indirizzo = $this->data->address;
+ $this->itData->civico = $this->data->huoseNumber;
+ $this->itData->comune = $this->data->city;
+ $this->itData->cap = $this->data->zip;
+ $this->itData->provincia = $this->data->province;
+ $this->itData->nazione = $this->data->country;
+ $this->itData->email = $this->data->email;
+
+ }
+
+ public function getObject($itNames = FALSE){
+ if(!$itNames){
+ return $this->data;
+ }
+ return $this->itData;
+ }
+
+
+ public function getFirstName(){
+ return $this->data->firstName;
+ }
+ public function getSecondName(){
+ return $this->data->secondName;
+ }
+
+ public function getCompanyName(){
+ return $this->data->companyName;
+ }
+ public function getDug(){
+ return $this->data->dug;
+ }
+ public function getAddress(){
+ return $this->data->address;
+ }
+ public function getHuoseNumber(){
+ return $this->data->huoseNumber;
+ }
+ public function getCity(){
+ return $this->data->city;
+ }
+ public function getZip(){
+ return $this->data->zip;
+ }
+ public function getProvince(){
+ return $this->data->province;
+ }
+ public function getCountry(){
+ return $this->data->country;
+ }
+ public function getEmail(){
+ return $this->data->email;
+ }
+
+ public function setFirstName(string $firstName){
+ $this->data->firstName = $firstName;
+ $this->itData->nome = $firstName;
+ }
+
+ public function setSecondName(string $secondName){
+ $this->data->secondName = $secondName;
+ $this->itData->cognome = $secondName;
+ }
+
+ public function setCompanyName(string $companyName){
+ $this->data->companyName = $companyName;
+ $this->itData->ragione_sociale = $companyName;
+ }
+
+ public function setDug(string $dug){
+ $this->data->dug = $dug;
+ $this->itData->dug = $dug;
+ }
+
+ public function setAddress(string $address){
+ $this->data->address = $address;
+ $this->itData->indirizzo = $address;
+ }
+ public function setHuoseNumber(string $huoseNumber){
+ $this->data->huoseNumber = $huoseNumber;
+ $this->itData->civico = $huoseNumber;
+ }
+
+ public function setCity(string $city){
+ $this->data->city = $city;
+ $this->itData->comune = $city;
+ }
+
+ public function setZip(string $zip){
+ $this->data->zip = $zip;
+ $this->itData->cap = $zip;
+ }
+
+ public function setProvince(string $province){
+ $this->data->province = $province;
+ $this->itData->privincia = $province;
+ }
+
+ public function setCountry(string $country){
+ $this->data->country = $country;
+ $this->itData->nazione = $country;
+ }
+
+ public function setEmail(string $email){
+ $this->data->email = $email;
+ $this->itData->email = $email;
+ }
+
+ public function getErrors($validate = TRUE){
+ if($validate){
+ $this->validate();
+ }
+
+ return $this->errors;
+ }
+
+ public function validate(){
+ $this->errors = [];
+ if($this->data->zip == NULL){
+ $this->errors['zip'] = (object)[
+ "code"=> "required",
+ "text"=>"zip field is required"
+ ];
+ } else if($this->data->country == "Italia" || $this->data->country == "Italy"){
+ $re = '/^\d{5}$/';
+ preg_match($re, $this->data->zip, $matches, PREG_OFFSET_CAPTURE, 0);
+ if(count($matches) == 0){
+ $this->errors['zip'] = (object)[
+ "code"=> "5_digit",
+ "text"=>"Italian ZIP must be 5 digits"
+ ];
+ }
+ }
+
+ if($this->data->city == NULL){
+ $this->errors['city'] = (object)[
+ "code"=> "required",
+ "text"=>"city is required"
+ ];
+ }
+
+ if($this->data->province == NULL){
+ $this->errors['province'] = (object)[
+ "code"=> "required",
+ "text"=>"province is required"
+ ];
+ }
+
+
+ if($this->data->dug == NULL){
+ $this->errors['dug'] = (object)[
+ "code"=> "required",
+ "text"=>"dug is required"
+ ];
+ }
+
+ if($this->data->address == NULL){
+ $this->errors['address'] = (object)[
+ "code"=> "required",
+ "text"=>"address is required"
+ ];
+ }
+
+ if($this->data->huoseNumber == NULL){
+ $this->errors['huoseNumber'] = (object)[
+ "code"=> "required",
+ "text"=>"huose number is required"
+ ];
+ }
+
+
+ $this->validate = count($this->errors) == 0;
+ return $this->validate;
+ }
+
+}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/Raccomandata.php b/src/classes/utility/UfficioPostale/Raccomandata.php
new file mode 100644
index 0000000..c551100
--- /dev/null
+++ b/src/classes/utility/UfficioPostale/Raccomandata.php
@@ -0,0 +1,9 @@
+connect = $connect;
+ $this->sender = NULL;
+ $this->recipients = [];
+ $this->documents = [];
+ $this->textMessage = NULL;
+ $this->validRecipients = FALSE;
+ }
+
+
+ public function setSender($sender){
+ if($sender instanceof \OpenApi\classes\utility\UfficioPostale\Objects\Sender){
+ $this->sender = $sender;
+ }else{
+ $this->sender = new \OpenApi\classes\utility\UfficioPostale\Objects\Sender($sender);
+ }
+ if(!$this->sender->validate()){
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ public function getSender(){
+ return $this->sender;
+ }
+
+ public function getSenderError(){
+ if($this->sender == NULL){
+ return NULL;
+ }
+ return $this->sender->getErrors();
+ }
+
+ public function getRecpients(){
+ return $this->recipients;
+ }
+
+ public function getRecpientsErrors(){
+ if($this->recipients == NULL){
+ return NULL;
+ }
+ if($this->validRecipients){
+ return [];
+ }
+ $errors = [];
+ foreach($this->recipient AS $r){
+ $errors[] = $r->getErrors();
+ }
+ return $errors;
+ }
+
+ public function setTextMessage($message){
+ $this->textMessage = $message;
+ }
+
+ public function setRecipients($recipients){
+ $this->clearRecipients();
+ $valid = TRUE;
+ foreach($recipients as $key => $recipient){
+ if(!($recipient instanceof \OpenApi\classes\utility\UfficioPostale\Objects\Recipient)){
+
+ $recipient = new \OpenApi\classes\utility\UfficioPostale\Objects\Recipient($recipient);
+ }
+ if(!$recipient->validate()){
+ $valid = FALSE;
+ }
+ $this->recipient[] = $recipient;
+ }
+ $this->validRecipients = $valid;
+ return $valid;
+ }
+
+ public function addRecipient($recipient){
+ if(!($recipient instanceof \OpenApi\classes\utility\UfficioPostale\Objects\Recipient)){
+ $recipient = new \OpenApi\classes\utility\UfficioPostale\Objects\Recipient($recipient);
+ }
+ $valid = TRUE;
+ if(!$recipient->validate()){
+ $valid = FALSE;
+ }
+ $this->recipient[] = $recipient;
+ $this->validRecipients = $valid;
+ return $valid;
+ }
+
+ public function clearRecipients(){
+ $this->recipients = [];
+ }
+
+ public function setDocuments($documents){
+ $this->documents = $documents;
+ }
+
+ public function addDocument($document){
+ $this->documents[] = $document;
+ }
+
+ public function clearDocuments(){
+ $this->documents = [];
+ }
+}
\ No newline at end of file
From 746ccd196408be8f6f0085cf7d7aa39e23c47f5c Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Fri, 9 Oct 2020 17:17:45 +0200
Subject: [PATCH 12/85] modificato composer.json
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 031aa1f..a2ec37e 100644
--- a/composer.json
+++ b/composer.json
@@ -12,7 +12,7 @@
"php": ">=7.2.0"
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"OpenApi": "src"
}
}
From 5a21e66125741851cb6196f6be78ea3d910975b8 Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Fri, 9 Oct 2020 17:20:42 +0200
Subject: [PATCH 13/85] modificato composer
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index a2ec37e..f1eb223 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
},
"autoload": {
"psr-4": {
- "OpenApi": "src"
+ "OpenApi/": "src"
}
}
}
From c00a66bde604cc13342084d65f4513c62b0739d5 Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Fri, 9 Oct 2020 17:54:11 +0200
Subject: [PATCH 14/85] modifica composer
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index f1eb223..e91e179 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
},
"autoload": {
"psr-4": {
- "OpenApi/": "src"
+ "OpenApi\\": "src"
}
}
}
From 4dd8b6fd8d4f9fefaccfe35104648518320cf704 Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Fri, 16 Oct 2020 10:51:02 +0200
Subject: [PATCH 15/85] added FirmaDigitale and PecMassiva API
---
src/OpenApi.php | 10 ++-
src/classes/FirmaDigitale.php | 69 +++++++++++++++++
src/classes/OpenApiBase.php | 10 ++-
src/classes/PecMassiva.php | 77 +++++++++++++++++++
.../exception/OpenApiPecMassivaException.php | 15 ++++
5 files changed, 178 insertions(+), 3 deletions(-)
create mode 100644 src/classes/FirmaDigitale.php
create mode 100644 src/classes/PecMassiva.php
create mode 100644 src/classes/exception/OpenApiPecMassivaException.php
diff --git a/src/OpenApi.php b/src/OpenApi.php
index 292886e..a77a501 100644
--- a/src/OpenApi.php
+++ b/src/OpenApi.php
@@ -21,7 +21,11 @@ function __construct(array $scopes, string $username, string $apikey, $environme
$domainsRealScopes = [];
$prefix = $environment=="production"?"":$environment.".";
$domains = [];
+ //var_dump($scopes);exit;
foreach($scopes as $s){
+ if($s == NULL){
+ continue;
+ }
if(is_array($s)){
$domain = $s['domain'];
$realScope = $s['mode'].":".$prefix.$s['domain']."/".$s['method'];
@@ -47,6 +51,7 @@ function __construct(array $scopes, string $username, string $apikey, $environme
$this->prefix = $prefix;
$this->scopes = $realScopes;
$token = $this->getToken();
+
list($moduli,$nomi) = $this->getListaModuli();
$this->clients = [];
foreach($domains as $d){
@@ -97,7 +102,10 @@ private function getListaModuli(){
$moduli['ws.firmadigitale.com'] = "\\OpenApi\\classes\\FirmaDigitale";
- $nomi['ws.firmadigitale.com'] = "FirmaDigitale";
+ $nomi['ws.firmadigitale.com'] = "firmaDigitale";
+
+ $moduli['ws.pecmassiva.com'] = "\\OpenApi\\classes\\PecMassiva";
+ $nomi['ws.pecmassiva.com'] = "pecMassiva";
return array($moduli,$nomi);
}
diff --git a/src/classes/FirmaDigitale.php b/src/classes/FirmaDigitale.php
new file mode 100644
index 0000000..5f761ed
--- /dev/null
+++ b/src/classes/FirmaDigitale.php
@@ -0,0 +1,69 @@
+basePath = "https://ws.firmadigitale.com";
+ }
+
+
+ function getModule($id, $add_header = TRUE){
+
+ $pdf = $this->connect("richiesta/$id/modulo", "GET", [], 0, FALSE, TRUE);
+ if(!$add_header){
+ return $pdf;
+ }
+ header("Content-type:application/pdf");
+ header("Content-Disposition:attachment;filename={$id}.pdf");
+ header('Content-Length: '.strlen( $pdf ));
+ header('Cache-Control: public, must-revalidate, max-age=0');
+ header('Pragma: public');
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
+ echo $pdf;
+ }
+
+
+ function requestProduct($data){
+ $type = isset($data['tipo'])?$data['tipo']:NULL;
+ $codice_prodotto = isset($data['codice_prodotto'])?$data['codice_prodotto']:NULL;
+ $anagrafica = isset($data['anagrafica'])?$data['anagrafica']:NULL;
+ $spedizione = isset($data['spedizione'])?$data['spedizione']:NULL;
+ $urgenza = isset($data['urgenza'])?$data['urgenza']:NULL;
+ $assistenza = isset($data['assistenza'])?$data['assistenza']:NULL;
+ $callback = isset($data['callback'])?$data['callback']:NULL;
+
+ $params = [];
+ if($anagrafica != NULL){
+ if($type == "lettore"){
+ $params['anagrafica_spedizione'] = $anagrafica;
+ }else{
+ $params['anagrafica'] = $anagrafica;
+ }
+
+ }
+
+ if($spedizione != NULL && ($type == "lettore" || $type == "firma")){
+ $params['spedizione'] = $spedizione;
+ }
+
+ if($urgenza != NULL && ($type == "lettore" || $type == "firma")){
+ $params['urgenza'] = $urgenza;
+ }
+ if($assistenza != NULL){
+ $params['assistenza'] = $assistenza;
+ }
+
+ if($callback != NULL){
+ $params['callback'] = $callback;
+ }
+ $ret = $this->connect("richiesta/$codice_prodotto","POST",$params);
+ return $ret;
+ }
+
+}
\ No newline at end of file
diff --git a/src/classes/OpenApiBase.php b/src/classes/OpenApiBase.php
index 3e5f602..dd046e0 100644
--- a/src/classes/OpenApiBase.php
+++ b/src/classes/OpenApiBase.php
@@ -89,7 +89,7 @@ private function checkHasScope(string $url, string $type){
*
* @return mixed
*/
- protected function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false){
+ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $addHeader = NULL){
$url = $this->basePath;
$url = str_replace("https://","https://".$this->prefix,$url);
$url = str_replace("http://","http://".$this->prefix,$url);
@@ -119,7 +119,13 @@ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr =
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
- curl_setopt($ch,CURLOPT_HTTPHEADER,array("Authorization: Bearer ".$this->token));
+ $header = array("Authorization: Bearer ".$this->token);
+ if($addHeader != NULL && is_array($addHeader) && count($addHeader)>0){
+ $header = array_merge($header, $addHeader);
+ }
+
+
+ curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
// var_dump($response);exit;
diff --git a/src/classes/PecMassiva.php b/src/classes/PecMassiva.php
new file mode 100644
index 0000000..dcb7f6b
--- /dev/null
+++ b/src/classes/PecMassiva.php
@@ -0,0 +1,77 @@
+basePath = "https://ws.pecmassiva.com";
+ $this->inizialized = FALSE;
+
+ }
+
+ function initialize(string $username, string $password){
+ $this->username = $username;
+ $this->password = $password;
+ $this->inizialized = TRUE;
+ }
+
+ function getStatus($messageId){
+ if(!$this->inizialized){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
+ }
+
+
+ try{
+ $header[] = 'x-username: '.$this->username;
+ $header[] = 'x-password: '.$this->password;
+ return $this->connect("send/$messageId","GET",[],0,false,$header);
+
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if(isset($e->getServerResponse()->message_id)){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
+ }
+ throw $e;
+
+ }
+ }
+
+ function send($recipient, $subject, $body, $attachments = [], $sender = NULL){
+ if(!$this->inizialized){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
+ }
+ $sender = $sender ? $sender : $this->username;
+
+ $params['username'] = $this->username;
+ $params['password'] = $this->password;
+ $params['recipient'] = $recipient;
+ $params['subject'] = $subject;
+ $params['body'] = $body;
+ if(count($attachments)>0){
+ $params['attachments'] = $attachments;
+ }
+ $params['sender'] = $sender;
+ try{
+ return $this->connect("send","POST",$params);
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if(isset($e->getServerResponse()->message_id)){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
+ }
+ throw $e;
+
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/classes/exception/OpenApiPecMassivaException.php b/src/classes/exception/OpenApiPecMassivaException.php
new file mode 100644
index 0000000..31d9848
--- /dev/null
+++ b/src/classes/exception/OpenApiPecMassivaException.php
@@ -0,0 +1,15 @@
+
Date: Fri, 30 Oct 2020 17:51:50 +0100
Subject: [PATCH 16/85] -
---
readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index 634775a..c4f92d6 100644
--- a/readme.md
+++ b/readme.md
@@ -47,5 +47,5 @@ La funzione consente di recuperare i dati aziendali a partire dalla partita IVA
`function getByPartitaIva(string $partitaIva, $ttl = 86400):object`
-* $partitaIva: La partita IVA da cvercare
+* $partitaIva: La partita IVA da cercare
* $ttl: Time To Release, per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
From ba5356fd852cd209311c2c32212df73d2df0d717 Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Fri, 30 Oct 2020 17:56:35 +0100
Subject: [PATCH 17/85] visengine: gestione fornitori
---
src/classes/VisEngine.php | 11 +++++++++++
src/classes/utility/VisEngine/VisRequest.php | 7 +++++++
2 files changed, 18 insertions(+)
diff --git a/src/classes/VisEngine.php b/src/classes/VisEngine.php
index 0080d58..f55fd59 100644
--- a/src/classes/VisEngine.php
+++ b/src/classes/VisEngine.php
@@ -22,6 +22,17 @@ function setHash(string $hash){
$this->hash = $hash;
}
+ function getDatiFornitore($email){
+ $data = $this->connect("fornitori/$email", "GET", []);
+ return $data;
+ }
+
+ function getFornitori(){
+ $data = $this->connect("fornitori", "GET", []);
+ return $data;
+
+ }
+
function getFormTool(){
if($this->hash == NULL){
throw new \OpenApi\classes\exception\OpenApiVisEngineException("Visengine hash is not setted",40005);
diff --git a/src/classes/utility/VisEngine/VisRequest.php b/src/classes/utility/VisEngine/VisRequest.php
index 8aac5cb..50af857 100644
--- a/src/classes/utility/VisEngine/VisRequest.php
+++ b/src/classes/utility/VisEngine/VisRequest.php
@@ -22,11 +22,18 @@ function __construct($visura)
$this->ricerche = [];
$this->document = NULL;
$this->format_errror = [];
+ $this->fornitore = [];
foreach($visura->data->json_struttura->campi as $k => $v){
$this->variables[$k] = FALSE;
}
}
+ function setFornitore($fornitore){
+ $this->fornitore = $fornitore;
+ }
+ function getFornitore(){
+ return $this->fornitore;
+ }
function setNew(bool $new){
return $this->new = $new;
}
From f05435b8fd3df04c36ce5b728dba3a7cb6026f9e Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Wed, 11 Nov 2020 18:05:54 +0100
Subject: [PATCH 18/85] uploader
---
src/OpenApi.php | 3 +
src/classes/OpenApiBase.php | 41 ++-
src/classes/Uploader.php | 78 +++++
.../exception/OpenApiUploaderException.php | 19 +
src/classes/utility/Uploader/Collection.php | 327 ++++++++++++++++++
5 files changed, 464 insertions(+), 4 deletions(-)
create mode 100644 src/classes/Uploader.php
create mode 100644 src/classes/exception/OpenApiUploaderException.php
create mode 100644 src/classes/utility/Uploader/Collection.php
diff --git a/src/OpenApi.php b/src/OpenApi.php
index a77a501..ba80854 100644
--- a/src/OpenApi.php
+++ b/src/OpenApi.php
@@ -106,6 +106,9 @@ private function getListaModuli(){
$moduli['ws.pecmassiva.com'] = "\\OpenApi\\classes\\PecMassiva";
$nomi['ws.pecmassiva.com'] = "pecMassiva";
+
+ $moduli['uploader.altravia.com'] = "\\OpenApi\\classes\\Uploader";
+ $nomi['uploader.altravia.com'] = "uploader";
return array($moduli,$nomi);
}
diff --git a/src/classes/OpenApiBase.php b/src/classes/OpenApiBase.php
index dd046e0..5d506b8 100644
--- a/src/classes/OpenApiBase.php
+++ b/src/classes/OpenApiBase.php
@@ -89,7 +89,7 @@ private function checkHasScope(string $url, string $type){
*
* @return mixed
*/
- protected function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $addHeader = NULL){
+ public function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $addHeader = NULL){
$url = $this->basePath;
$url = str_replace("https://","https://".$this->prefix,$url);
$url = str_replace("http://","http://".$this->prefix,$url);
@@ -132,15 +132,27 @@ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr =
$this->rawResponse = $response;
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$this->header = substr($response, 0, $header_size);
+ //var_dump($this->header);exit;
+ $this->parsedHEader = $this->parseHeader($this->header);
$return = substr($response, $header_size);
$httpCode = curl_getinfo ( $ch, CURLINFO_RESPONSE_CODE );;
curl_close($ch);
- $data = json_decode($return);
+
+ if(isset($this->parsedHEader['Content-Type']) && strtolower($this->parsedHEader['Content-Type']) == "application/json") {
+
+ $data = json_decode($return);
+ }else if(json_decode($return) != NULL){
+ $data = json_decode($return);
+
+ }else{
+ $data = $return;
+ }
+
if($data == NULL){
throw new \OpenApi\classes\exception\OpenApiConnectionsException("Connection to $url: Connection Error",40001);
}
- // var_dump($data);exit;
- if($data->success == false){
+
+ if(is_object($data) && $data->success == false){
$message = "Connection to $url: unknow error";
if(isset($data->message)) {
if(is_string(($data->message))){
@@ -166,4 +178,25 @@ protected function connect(string $endpoint, $type = "GET", $param = [], $ttr =
return $data;
}
+ private function parseHeader($headers){
+ $headers = explode("\n",$headers);
+ $parsedHeaders = array();
+ foreach ($headers as $header) {
+ $header = trim($header);
+
+ $header = explode(":",$header);
+
+ if(count($header) < 2){
+
+ continue;
+ }
+ $key = $header[0];
+ unset($header[0]);
+ $parsedHeaders[trim($key)] = trim(implode(":",$header));
+ }
+ // exit;
+
+ return $parsedHeaders;
+ }
+
}
\ No newline at end of file
diff --git a/src/classes/Uploader.php b/src/classes/Uploader.php
new file mode 100644
index 0000000..d8bbf3e
--- /dev/null
+++ b/src/classes/Uploader.php
@@ -0,0 +1,78 @@
+basePath = "https://uploader.altravia.com";
+ }
+
+ function newCollection(){
+
+ return new \OpenApi\classes\utility\Uploader\Collection([$this, 'connect']);
+ }
+
+ function gateway(){
+
+ $endpoint = isset($_GET['endpoint'])?$_GET['endpoint']:null;
+ if($endpoint == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("No endpoint GET",40018);
+ }
+
+ $method = $_SERVER['REQUEST_METHOD'];
+ $data = null;
+ if($method != "GET" && $method != "DELETE"){
+ $data = file_get_contents("php://input");
+ $data = json_decode($data);
+ }
+ $data = $this->connect($endpoint, $method,$data);
+ header("Content-Type: ",$this->parsedHEader['Content-Type']);
+ if(isset($this->parsedHEader['Content-Type']) && strtolower($this->parsedHEader['Content-Type']) == "application/json") {
+ echo json_encode($data);
+ }else{
+ echo $data;
+ }
+ }
+
+ function createCollection($outputFormat, $outputSize = null, $inputTypes = null, $inputCount = null, $public = null, $watermark = null, $watermarkPosition = NULL, $expireTimestamp = null) {
+ $collection = new \OpenApi\classes\utility\Uploader\Collection([$this, 'connect']);
+ $collection->setOutput($outputFormat);
+ $collection->setOutputSize($outputSize);
+ $collection->setInputTypes($inputTypes);
+ $collection->setInputCount($inputCount);
+ $collection->setPublic($public);
+ $collection->setWaterMark($watermark);
+ $collection->setWaterMarkPosition($watermarkPosition);
+ $collection->setExpireTimestamp($expireTimestamp);
+ $collection->save();
+ }
+
+ function getCollectionById($id){
+ $coll = $this->connect("collections/$id","GET");
+ $collection = new \OpenApi\classes\utility\Uploader\Collection([$this, 'connect']);
+ if(isset($coll->data)){
+ $collection->parseData($coll->data);
+ return $collection;
+ }
+ return null;
+ }
+
+ function deleteCollectionById($id){
+ return $this->connect("collections/$id","DELETE");
+ }
+
+ function getCollections(){
+ $collections = $this->connect("collections","GET");
+ foreach($collections->data as $d){
+ $d->id =$d->_id->{'$oid'};
+ unset($d->_id);
+ }
+ return $collections;
+ }
+
+}
\ No newline at end of file
diff --git a/src/classes/exception/OpenApiUploaderException.php b/src/classes/exception/OpenApiUploaderException.php
new file mode 100644
index 0000000..eb79aa0
--- /dev/null
+++ b/src/classes/exception/OpenApiUploaderException.php
@@ -0,0 +1,19 @@
+connect = $connect;
+ }
+
+ function save($state = false){
+ $state = (bool)$state;
+ if($this->getOutput() == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Output format not setted",40017);
+ }
+ $this->state = $state;
+ $data['output_format'] = $this->getOutput();
+ if($this->getOutputSize() != NULL){
+ $data['output_size'] = $this->getOutputSize();
+ }
+ if($this->getInputTypes() != NULL){
+ $data['input_types'] = $this->getInputTypes();
+ }
+ if($this->getInputCount() != NULL){
+ $data['input_count'] = $this->getInputCount();
+ }
+ $data['public'] = $this->isPublic();
+ if($this->getWaterMark() != NULL){
+ $data['watermark'] = $this->getWaterMark();
+ $data['watermark_position'] = $this->getWaterMarkPosition();
+ }
+ if($this->getExpireTimestamp() != NULL){
+ $data['expire_timestamp'] = $this->getExpireTimestamp();
+ }
+ $data['state'] = $state;
+ if($this->id == null){
+
+ $ret = call_user_func_array ($this->connect,["collections","POST",$data]);
+ $this->id = $ret->id;
+ return $ret->id;
+ }else{
+
+ $ret = call_user_func_array ($this->connect,["collections/$this->id","PATCH",$data]);
+ $this->id = $ret->id;
+ return $ret->id;
+ }
+ }
+
+ function parseData($data){
+
+ $this->setOutput($data->output_format);
+ $this->setOutputSize($data->output_size);
+ $this->setInputTypes($data->input_types);
+ $this->setInputCount($data->input_count);
+ $this->setPublic($data->public);
+ $this->setWaterMark($data->watermark);
+ $this->setWaterMarkPosition($data->watermark_position);
+ $this->setExpireTimestamp($data->expire_timestamp);
+ $this->email = $data->email;
+ $this->creation_timestamp = $data->creation_timestamp;
+ $this->update_timestamp = $data->update_timestamp;
+ $this->documents_count = $data->documents_count;
+ $this->documents_bytes = $data->documents_bytes;
+ $this->documents = $data->documents;
+ $this->state = $data->state;
+ $this->id = $data->_id->{'$oid'};
+
+ }
+
+ function getState(){
+ return $this->state;
+ }
+
+ function getDocuments(){
+ $this->documents;
+ }
+
+ function getDocumentBytes(){
+ $this->documents_bytes;
+ }
+
+ function getDocumentCount(){
+ $this->documents_count;
+ }
+
+ function getUpdateTimestamp(){
+ $this->update_timestamp;
+ }
+
+ function getCreationTimestamp(){
+ $this->creation_timestamp;
+ }
+
+ function getEmail(){
+ $this->email;
+ }
+
+ function getId(){
+ return $this->id;
+ }
+ function setOutput($output){
+ if($output != "image/png" && $output != "image/jpeg" && $output != "application/pdf"){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Output format not valid",40013);
+ }
+ if($output == "image/png" || $output == "image/jpeg") {
+ $this->outputGroup = false;
+ $this->cropSize = null;
+ }
+ $this->output = $output;
+ $this->checkOutputSize();
+ }
+
+ function getOutputSize(){
+ return $this->outputSize;
+ }
+
+ function getInputCount(){
+ return $this->inputCount;
+ }
+
+ function getWaterMark(){
+ return $this->watermark;
+ }
+
+ function setWaterMark($watermark){
+ $this->watermark = $watermark;
+ }
+
+ function getWaterMarkPosition(){
+ return $this->watermarkPosition;
+ }
+
+
+ function setWaterMarkPosition($watermarkPosition){
+ $this->watermarkPosition = $watermarkPosition;
+ }
+
+ function setExpireTimestamp($expireTimestamp){
+ if($expireTimestamp == NULL){
+ $this->expireTimestamp = NULL;
+ return;
+ }
+ $this->expireTimestamp = (int)$expireTimestamp;
+ }
+
+ function getExpireTimestamp(){
+ return $this->expireTimestamp;
+ }
+
+ function setInputCount($ic){
+ if($ic == NULL){
+ $this->inputCount = NULL;
+ return;
+ }
+ $this->inputCount = (int)$ic;
+ }
+ function setOutputGroup($outputGroup){
+ if($outputGroup && ($this->output == "image/png" || $this->output == "image/jpeg")){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Output group not valid",40015);
+ }
+ $this->outputGroup = $outputGroup;
+ }
+
+ function getOutputGroup(){
+ return $this->outputGroup;
+ }
+
+ function setPublic($public = true){
+ $this->public = $public;
+ }
+
+ function setPrivate($private = TRUE){
+ $this->public = !$private;
+ }
+
+ function isPublic(){
+ return $this->public;
+ }
+
+ function isPrivate(){
+ return !$this->public;
+ }
+
+ function setInputTypes($types){
+ if(!is_array($types)){
+ $types = [$types];
+ }
+ foreach($types as $t){
+ if($t != "image/png" && $t != "image/jpeg" && $t != "application/pdf"){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Input type not valid",40016);
+ }
+ }
+ $this->inputTypes = $types;
+ }
+
+ function getInputTypes(){
+ return $this->inputTypes;
+ }
+
+ function setOutputSize($outputSize){
+ $this->outputSize = $outputSize;
+ $this->checkOutputSize();
+ }
+
+ private function checkOutputSize(){
+ if($this->output == null || $this->outputSize == NULL){
+ return TRUE;
+ }
+ if($this->output == "application/pdf"){
+ if(!in_array($this->outputSize,$this->validPdfFormats)){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Output size not valid",40014);
+ }
+ }else{
+ if(!is_array($this->outputSize) || !isset($this->outputSize[0]) || !isset($this->outputSize[1]) || !is_int($this->outputSize[0]) || !is_int($this->outputSize[1])){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Output size not valid",40014);
+ }
+ }
+ }
+
+ function setOutputJpeg(){
+ $this->setOutput("image/jpeg");
+ }
+
+ function setOutputPng(){
+ $this->setOutput("image/png");
+ }
+
+ function setOutputPdf(){
+ $this->setOutput("application/pdf");
+ }
+
+ function getOutput(){
+ return $this->output;
+ }
+
+ function addDocument($name, $type,$file,$crop_size = null){
+ if($this->id == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Impossible to add File",40019);
+ }
+
+ $data['name'] = $name;
+ $data['type'] = $type;
+ $data['file'] = $file;
+ $data['crop_size'] = $crop_size;
+
+ $ret = call_user_func_array ($this->connect,["collections/$this->id","POST",$data]);
+
+ $this->updateCollection();
+ return $ret->id;
+ }
+
+ function updateDocument($id_documento, $name = NULL,$type = NULL, $file = NULL, $crop_size = NULL){
+ if($this->id == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Impossible to add File",40019);
+ }
+ if($name != NULL){
+ $data['name'] = $name;
+ }
+ if($type != NULL){
+ $data['type'] = $type;
+ }
+ if($file != NULL){
+ $data['file'] = $file;
+ }
+ if($crop_size != NULL){
+ $data['crop_size'] = $crop_size;
+ }
+
+ $ret = call_user_func_array ($this->connect,["collections/$this->id/$id_documento","PATCH",$data]);
+
+ $this->updateCollection();
+ return $ret->success;
+ }
+
+ function deleteDocument($id_documento){
+ if($this->id == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Impossible to add File",40019);
+ }
+
+
+ $ret = call_user_func_array ($this->connect,["collections/$this->id/$id_documento","DELETE"]);
+
+ $this->updateCollection();
+ return $ret->success;
+ }
+
+ private function updateCollection(){
+
+ $coll = call_user_func_array ($this->connect,["collections/$this->id","GET"]);
+ if(isset($coll->data)){
+ $this->parseData($coll->data);
+
+ }
+ }
+
+ function getDocumento($id_documento){
+ if($this->id == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Impossible to add File",40019);
+ }
+
+
+ $ret = call_user_func_array ($this->connect,["collections/$this->id/$id_documento","GET"]);
+
+ $this->updateCollection();
+ return $ret;
+ }
+}
\ No newline at end of file
From 6a8087e665e16890ce21c110f8edfe3a51f4832b Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Tue, 2 Feb 2021 11:35:28 +0100
Subject: [PATCH 19/85] =?UTF-8?q?aggiunte=20funzionalit=C3=A0=20UfficioPos?=
=?UTF-8?q?tale?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/classes/Comuni.php | 14 +++
src/classes/FirmaDigitale.php | 11 ++-
src/classes/MarcheTemporali.php | 4 +-
src/classes/OpenApiBase.php | 7 +-
src/classes/UfficioPostale.php | 5 +-
src/classes/Uploader.php | 5 ++
src/classes/VisEngine.php | 85 ++++++++++++++-----
src/classes/exception/OpenApiUPException.php | 14 +++
.../UfficioPostale/Objects/Recipient.php | 14 ++-
.../utility/UfficioPostale/Objects/Sender.php | 16 ++--
.../utility/UfficioPostale/Raccomandata.php | 48 +++++++++++
.../utility/UfficioPostale/ServiziPostali.php | 85 ++++++++++++++++++-
src/classes/utility/VisEngine/VisRequest.php | 18 ++--
13 files changed, 286 insertions(+), 40 deletions(-)
create mode 100644 src/classes/exception/OpenApiUPException.php
diff --git a/src/classes/Comuni.php b/src/classes/Comuni.php
index a86fca1..b9d1e50 100644
--- a/src/classes/Comuni.php
+++ b/src/classes/Comuni.php
@@ -27,6 +27,20 @@ function getCitiesByCap(string $cap, $ttl = 86400){
return $data->data;
}
+ /**
+ *
+ * A partire dal CAP restistuisce un'array di oggietti di tipo comune
+ *
+ * @param string $cap Il cap da ricercare
+ * @param int $ttl Il tempo di chache degli oggetti ritornati, 0 per no chche
+ *
+ * @return array
+ */
+ function getComuneByCatasto(string $codice_catastale, $ttl = 86400){
+ $data = $this->connect("catastale/$codice_catastale", "GET", [], $ttl);
+ return $data->data;
+ }
+
/**
* Restituisce la lista delle regioni italiani
*
diff --git a/src/classes/FirmaDigitale.php b/src/classes/FirmaDigitale.php
index 5f761ed..9e2abc0 100644
--- a/src/classes/FirmaDigitale.php
+++ b/src/classes/FirmaDigitale.php
@@ -37,17 +37,26 @@ function requestProduct($data){
$urgenza = isset($data['urgenza'])?$data['urgenza']:NULL;
$assistenza = isset($data['assistenza'])?$data['assistenza']:NULL;
$callback = isset($data['callback'])?$data['callback']:NULL;
+ $quantita = isset($data['quantita'])?$data['quantita']:NULL;
$params = [];
if($anagrafica != NULL){
- if($type == "lettore"){
+ if($type == "lettore" || $type == "vergine"){
$params['anagrafica_spedizione'] = $anagrafica;
+ }elseif($type == "spid"){
+ $params['email'] = $anagrafica->email;
+ $params['cellulare'] = $anagrafica->cellulare;
}else{
$params['anagrafica'] = $anagrafica;
}
}
+ if($quantita != NULL && ($type == "lettore" || $type == "vergine")){
+ $params['quantita'] = $quantita;
+ }
+
+
if($spedizione != NULL && ($type == "lettore" || $type == "firma")){
$params['spedizione'] = $spedizione;
}
diff --git a/src/classes/MarcheTemporali.php b/src/classes/MarcheTemporali.php
index f7466ea..b945083 100644
--- a/src/classes/MarcheTemporali.php
+++ b/src/classes/MarcheTemporali.php
@@ -17,7 +17,7 @@ function availability(string $type, int $qty){
return $data->data;
}
- function checkLotto($username, $password){
+ function checkLotto($username, $password, $tipo){
if(substr($username,0,4) == "FAKE" && substr($password,0,4) == "FAKE"){
$ret = new \stdClass();
@@ -29,7 +29,7 @@ function checkLotto($username, $password){
$ret->error = NULL;
return $ret->data;
}
- $data = $this->connect("check_lotto", "POST", ["username"=>$username, "password"=> $password]);
+ $data = $this->connect("check_lotto", "POST", ["username"=>$username, "password"=> $password,'type'=>$tipo]);
return $data->data;
}
diff --git a/src/classes/OpenApiBase.php b/src/classes/OpenApiBase.php
index 5d506b8..4c014d6 100644
--- a/src/classes/OpenApiBase.php
+++ b/src/classes/OpenApiBase.php
@@ -137,7 +137,7 @@ public function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0,
$return = substr($response, $header_size);
$httpCode = curl_getinfo ( $ch, CURLINFO_RESPONSE_CODE );;
curl_close($ch);
-
+ //echo $return;exit;
if(isset($this->parsedHEader['Content-Type']) && strtolower($this->parsedHEader['Content-Type']) == "application/json") {
$data = json_decode($return);
@@ -178,7 +178,7 @@ public function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0,
return $data;
}
- private function parseHeader($headers){
+ protected function parseHeader($headers){
$headers = explode("\n",$headers);
$parsedHeaders = array();
foreach ($headers as $header) {
@@ -199,4 +199,7 @@ private function parseHeader($headers){
return $parsedHeaders;
}
+
+
+
}
\ No newline at end of file
diff --git a/src/classes/UfficioPostale.php b/src/classes/UfficioPostale.php
index 1bb0a49..5922159 100644
--- a/src/classes/UfficioPostale.php
+++ b/src/classes/UfficioPostale.php
@@ -18,7 +18,10 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
* @return object
*/
function createRaccomandata(){
- return new \OpenApi\classes\utility\UfficioPostale\Raccomandata($this->connect);
+ return new \OpenApi\classes\utility\UfficioPostale\Raccomandata(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
+
+ return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
+ });
}
//function createRaccomandataByData()
diff --git a/src/classes/Uploader.php b/src/classes/Uploader.php
index d8bbf3e..dabf401 100644
--- a/src/classes/Uploader.php
+++ b/src/classes/Uploader.php
@@ -23,6 +23,7 @@ function gateway(){
if($endpoint == NULL){
throw new \OpenApi\classes\exception\OpenApiUploaderException("No endpoint GET",40018);
}
+ //echo $endpoint;exit;
$method = $_SERVER['REQUEST_METHOD'];
$data = null;
@@ -30,7 +31,11 @@ function gateway(){
$data = file_get_contents("php://input");
$data = json_decode($data);
}
+
$data = $this->connect($endpoint, $method,$data);
+ //var_dump($data);exit;
+
+
header("Content-Type: ",$this->parsedHEader['Content-Type']);
if(isset($this->parsedHEader['Content-Type']) && strtolower($this->parsedHEader['Content-Type']) == "application/json") {
echo json_encode($data);
diff --git a/src/classes/VisEngine.php b/src/classes/VisEngine.php
index f55fd59..e67fcd0 100644
--- a/src/classes/VisEngine.php
+++ b/src/classes/VisEngine.php
@@ -22,17 +22,6 @@ function setHash(string $hash){
$this->hash = $hash;
}
- function getDatiFornitore($email){
- $data = $this->connect("fornitori/$email", "GET", []);
- return $data;
- }
-
- function getFornitori(){
- $data = $this->connect("fornitori", "GET", []);
- return $data;
-
- }
-
function getFormTool(){
if($this->hash == NULL){
throw new \OpenApi\classes\exception\OpenApiVisEngineException("Visengine hash is not setted",40005);
@@ -69,10 +58,10 @@ function createRequest($ttr = 500){
*
* @return object
*/
- function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req) {
+ function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req, $new_search = FALSE) {
-
+
if($req->getNew()){
$params = new \stdClass();
$params->state = $req->getState();
@@ -84,37 +73,59 @@ function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req) {
if($req->getCallbackData() != NULL){
$params->callback_data = $req->getCallbackData();
}
+ if($req->getFornitore() != NULL){
+ $params->callback = $req->getFornitore();
+ }
if($req->getTargetEmail() != NULL){
$params->email_target = $req->getTargetEmail();
}
$data = $this->connect("richiesta", "POST", $params);
-
+ //var_dump($data);exit;
$req->setNew(FALSE);
$req->setId($data->data->_id);
$req->setStatoRichiesta($data->data->stato_richiesta);
+
+ if(isset($data->data->callback)){
+ $req->setFornitore($data->data->callback);
+ }else{
+ $req->setFornitore(NULL);
+ }
if(isset($data->data->ricerche)){
$req->setRicerche($data->data->ricerche);
}
return $req;
}else{
-
+
$params = new \stdClass();
$params->state = $req->getState();
// $params->test = $req->getTest();
-
+ $id_visura = $req->getId();
if($req->getJson() != NULL){
$params->json_visura = $req->getJson();
}
- $id_visura = $req->getId();
+
//echo json_encode($params);exit;
//var_dump($params);exit;
+ $visura = $this->connect("richiesta/$id_visura", "GET");
+
+ if(!$new_search)
+ {
$data = $this->connect("richiesta/$id_visura", "PUT", $params);
-
+ }else{
+ $data = $this->connect("richiesta/$id_visura", "POST", $params);
+ }
+
+ // var_dump($data);exit;
+
+
$req->setNew(FALSE);
$req->setId($data->data->_id);
$req->setStatoRichiesta($data->data->stato_richiesta);
+ if(isset($data->data->callback)){
+ $req->setFornitore($data->data->callback);
+ }
if(isset($data->data->ricerche)){
$req->setRicerche($data->data->ricerche);
}
@@ -122,11 +133,33 @@ function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req) {
}
}
+ function getDatiFornitore($email){
+ $data = $this->connect("fornitori/$email", "GET", []);
+ return $data;
+ }
+
+ function getFornitori(){
+ $data = $this->connect("fornitori", "GET", []);
+ return $data;
+
+ }
+
function getRequestByIdVisura($id_visura){
$visura = $this->connect("richiesta/$id_visura", "GET");
+
+ /*if($visura->data->callback){
+ var_dump($visura->data->callback);exit;
+ }*/
+
return $this->getRequestByData($visura);
}
+ function cancelRequest($id_visura, $motivazione){
+ $visura = $this->connect("richiesta/$id_visura", "DELETE",["motivo"=>$motivazione]);
+ return $this->getRequestByIdVisura($id_visura);
+ }
+
+
function getRequestByData($visura){
$this->visura = $this->connect("visure/{$visura->data->hash_visura}", "GET", [], 0);
@@ -136,12 +169,22 @@ function getRequestByData($visura){
$request->setNew(FALSE);
$request->setId($visura->data->_id);
$request->setStatoRichiesta($visura->data->stato_richiesta);
-
if(isset($visura->data->ricerche)){
$request->setRicerche($visura->data->ricerche);
}else{
$request->setRicerche([]);
}
+ if($request->getStatoRichiesta() == "Dati disponibili" || $request->getStatoRichiesta() == "Visura evasa"){
+ $documento = $this->connect("documento/{$visura->data->_id}", "GET", [], 0);
+ $request->setDocument($documento->data);
+ }
+ if($visura->data->stato_richiesta == "Annullata"){
+ $request->setReasonCancellation($visura->data->motivo_annullamento);
+
+ }
+ if(isset($visura->data->callback) && $visura->data->callback){
+ $request->setFornitore($visura->data->callback);
+ }
return $request;
}
@@ -168,6 +211,10 @@ function setRicerca($id_visura, $id_ricerca, $index){
}
+ function getCatalog($ttr = 86400){
+ return $this->connect("visure", "GET", NULL, $ttr);
+ }
+
}
diff --git a/src/classes/exception/OpenApiUPException.php b/src/classes/exception/OpenApiUPException.php
new file mode 100644
index 0000000..b80d6ed
--- /dev/null
+++ b/src/classes/exception/OpenApiUPException.php
@@ -0,0 +1,14 @@
+validate = false;
- if($recipient == NULL){
+ if($recipient != NULL){
$this->createFromObject($recipient);
}
}
public function createFromObject($object){
+ if(is_array($object)){
+ $object = (object)$object;
+ }
+ //var_dump($object);Exit;
$this->data->title = isset($object->title)?$object->title:(isset($object->titolo)?$object->titolo:NULL);
$this->data->at = isset($object->at)?$object->at:(isset($object->co)?$object->co:NULL);
$this->data->firstName = isset($object->firstName)?$object->firstName:(isset($object->nome)?$object->nome:NULL);
@@ -58,9 +62,13 @@ public function createFromObject($object){
$this->data->city = isset($object->city)?$object->city:(isset($object->comune)?$object->comune:NULL);
$this->data->zip = isset($object->zip)?$object->zip:(isset($object->cap)?$object->cap:NULL);
$this->data->province = isset($object->province)?$object->province:(isset($object->provincia)?$object->provincia:NULL);
- $this->data->country = isset($object->country)?$object->country:(isset($object->nazione)?$object->nazione:"Italia");
+ $this->data->country = isset($object->country)?$object->country:(isset($object->nazione)?$object->nazione:"IT");
$this->data->email = isset($object->email)?$object->email:NULL;
+ $this->data->id = isset($object->id)?$object->id:NULL;
+ $this->data->state = isset($object->state)?$object->state:NULL;
+
+
$this->itData->co = $this->data->at;
$this->itData->titolo = $this->data->title;
@@ -75,6 +83,8 @@ public function createFromObject($object){
$this->itData->provincia = $this->data->province;
$this->itData->nazione = $this->data->country;
$this->itData->email = $this->data->email;
+ $this->itData->id= $this->data->id;
+ $this->itData->state= $this->data->state;
}
diff --git a/src/classes/utility/UfficioPostale/Objects/Sender.php b/src/classes/utility/UfficioPostale/Objects/Sender.php
index 8ec3690..b93ca55 100644
--- a/src/classes/utility/UfficioPostale/Objects/Sender.php
+++ b/src/classes/utility/UfficioPostale/Objects/Sender.php
@@ -18,7 +18,7 @@ function __construct($sender = NULL){
$this->data->city = NULL;
$this->data->zip = NULL;
$this->data->province = NULL;
- $this->data->country = "Italia";
+ $this->data->country = "IT";
$this->data->email = NULL;
@@ -32,17 +32,21 @@ function __construct($sender = NULL){
$this->itData->comune = NULL;
$this->itData->cap = NULL;
$this->itData->provincia = NULL;
- $this->itData->nazione = "Italia";
+ $this->itData->nazione = "IT";
$this->itData->email = NULL;
$this->validate = false;
- if($sender == NULL){
+ if($sender != NULL){
$this->createFromObject($sender);
}
}
public function createFromObject($object){
+ if(is_array($object)){
+ $object = (object)$object;
+ }
+ // var_dump($object);
$this->data->firstName = isset($object->firstName)?$object->firstName:(isset($object->nome)?$object->nome:NULL);
$this->data->secondName = isset($object->secondName)?$object->secondName:(isset($object->cognome)?$object->cognome:NULL);
$this->data->companyName = isset($object->companyName)?$object->companyName:(isset($object->ragione_sociale)?$object->ragione_sociale:NULL);
@@ -52,9 +56,9 @@ public function createFromObject($object){
$this->data->city = isset($object->city)?$object->city:(isset($object->comune)?$object->comune:NULL);
$this->data->zip = isset($object->zip)?$object->zip:(isset($object->cap)?$object->cap:NULL);
$this->data->province = isset($object->province)?$object->province:(isset($object->provincia)?$object->provincia:NULL);
- $this->data->country = isset($object->country)?$object->country:(isset($object->nazione)?$object->nazione:"Italia");
+ $this->data->country = isset($object->country)?$object->country:(isset($object->nazione)?$object->nazione:"IT");
$this->data->email = isset($object->email)?$object->email:NULL;
-
+ // var_dump($this->data);exit;
$this->itData->nome = $this->data->firstName;
$this->itData->cognome = $this->data->secondName;
@@ -182,7 +186,7 @@ public function validate(){
"code"=> "required",
"text"=>"zip field is required"
];
- } else if($this->data->country == "Italia" || $this->data->country == "Italy"){
+ } else if($this->data->country == "Italia" || $this->data->country == "Italy" || $this->data->country == "IT"){
$re = '/^\d{5}$/';
preg_match($re, $this->data->zip, $matches, PREG_OFFSET_CAPTURE, 0);
if(count($matches) == 0){
diff --git a/src/classes/utility/UfficioPostale/Raccomandata.php b/src/classes/utility/UfficioPostale/Raccomandata.php
index c551100..61ffce4 100644
--- a/src/classes/utility/UfficioPostale/Raccomandata.php
+++ b/src/classes/utility/UfficioPostale/Raccomandata.php
@@ -5,5 +5,53 @@ class Raccomandata extends ServiziPostali {
function __construct($connect){
parent::__construct($connect);
}
+
+ function confirm(){
+ if($this->getId() == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUPException("Id not present",40011);
+ }
+ if($this->getState() != "NEW"){
+ throw new \OpenApi\classes\exception\OpenApiUPException("State is not NEW",40012);
+ }
+ $param['confirmed'] = TRUE;
+ $ret = call_user_func_array($this->connect,["raccomandate/".$this->getId(),"PATCH",$param]);
+
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+
+ }
+
+ function send(){
+ $object = new \stdClass();;
+ $object->mittente = $this->sender->getObject(TRUE);
+ $object->destinatari = [];
+ foreach($this->getRecpients() as $r){
+ $object->destinatari[] = $r->getObject(TRUE);
+ }
+ $object->documento =$this->documents;
+ $object->opzioni = new \stdClass();
+ $object->opzioni->fronteretro = $this->getFronteRetro();
+ $object->opzioni->colori = $this->getColori();
+ $object->opzioni->ar = $this->getAR();
+ $object->opzioni->autoconfirm = $this->getAutoconfirm();
+ if($this->getCallback() != NULL){
+ $callback = $this->getCallback();
+ foreach($callback as $k => $v){
+ $object->opzioni->$k = $v;
+ }
+ }
+ // var_dump($object);exit;
+ $ret = call_user_func_array($this->connect,["raccomandate/","POST",$object]);
+ $this->pricing = $ret->data[0]->pricing;
+ $this->id = $ret->data[0]->id;
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+ //$ret= $this->connect->call($this,"raccomandate",$object,"POST");
+
+ }
}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/ServiziPostali.php b/src/classes/utility/UfficioPostale/ServiziPostali.php
index efd2780..5dfc177 100644
--- a/src/classes/utility/UfficioPostale/ServiziPostali.php
+++ b/src/classes/utility/UfficioPostale/ServiziPostali.php
@@ -8,6 +8,15 @@ class ServiziPostali {
protected $documents;
protected $textMessage;
protected $validRecipients;
+ protected $fronteretro;
+ protected $colori;
+ protected $ar;
+ protected $autoconfirm;
+ protected $pricing;
+ protected $id;
+ protected $confirmed;
+ protected $state;
+ protected $callback;
function __construct($connect){
$this->connect = $connect;
@@ -16,6 +25,61 @@ function __construct($connect){
$this->documents = [];
$this->textMessage = NULL;
$this->validRecipients = FALSE;
+ $this->fronteretro = FALSE;
+ $this->colori = FALSE;
+ $this->ar = FALSE;
+ $this->autoconfirm = FALSE;
+ $this->pricing = FALSE;
+ $this->id = FALSE;
+ $this->confirmed = FALSE;
+ $this->state = FALSE;
+ $this->callback = NULL;
+ }
+
+ function getPricing(){
+ return $this->pricing;
+ }
+
+ function getId(){
+ return $this->id;
+ }
+
+ function getConfirmed(){
+ return $this->confirmed;
+ }
+
+ function getState(){
+ return $this->state;
+ }
+ function setAutoconfirm($autoconfirm){
+ $this->autoconfirm = $autoconfirm;
+ }
+
+ function getAutoconfirm(){
+ return $this->autoconfirm;
+ }
+
+ function setColori($colori){
+ $this->colori = $colori;
+ }
+
+ function getColori(){
+ return $this->colori;
+ }
+ function setFronteRetro($fronteretro){
+ $this->fronteretro = $fronteretro;
+ }
+
+ function getFronteRetro(){
+ return $this->fronteretro;
+ }
+
+ function setAR($ar){
+ $this->ar = $ar;
+ }
+
+ function getAR(){
+ return $this->ar;
}
@@ -26,6 +90,7 @@ public function setSender($sender){
$this->sender = new \OpenApi\classes\utility\UfficioPostale\Objects\Sender($sender);
}
if(!$this->sender->validate()){
+ // var_dump($this->sender->getErrors());
return FALSE;
}
return TRUE;
@@ -75,21 +140,23 @@ public function setRecipients($recipients){
if(!$recipient->validate()){
$valid = FALSE;
}
- $this->recipient[] = $recipient;
+ $this->recipients[] = $recipient;
}
$this->validRecipients = $valid;
return $valid;
}
public function addRecipient($recipient){
+
if(!($recipient instanceof \OpenApi\classes\utility\UfficioPostale\Objects\Recipient)){
$recipient = new \OpenApi\classes\utility\UfficioPostale\Objects\Recipient($recipient);
}
+
$valid = TRUE;
if(!$recipient->validate()){
$valid = FALSE;
}
- $this->recipient[] = $recipient;
+ $this->recipients[] = $recipient;
$this->validRecipients = $valid;
return $valid;
}
@@ -109,4 +176,18 @@ public function addDocument($document){
public function clearDocuments(){
$this->documents = [];
}
+
+ public function setCallback($url, $custom = NULL,$callback_field = NULL){
+ $callback = new \stdClass();
+ $callback->callback_url = $url;
+ $callback->custom = $custom;
+ if($callback_field != NULL){
+ $callback->callback_field = $callback_field;
+ }
+ $this->callback = $callback;
+ }
+
+ public function getCallback(){
+ return $this->callback;
+ }
}
\ No newline at end of file
diff --git a/src/classes/utility/VisEngine/VisRequest.php b/src/classes/utility/VisEngine/VisRequest.php
index 50af857..447219b 100644
--- a/src/classes/utility/VisEngine/VisRequest.php
+++ b/src/classes/utility/VisEngine/VisRequest.php
@@ -22,18 +22,20 @@ function __construct($visura)
$this->ricerche = [];
$this->document = NULL;
$this->format_errror = [];
- $this->fornitore = [];
+ $this->opzioni = null;
foreach($visura->data->json_struttura->campi as $k => $v){
$this->variables[$k] = FALSE;
}
}
- function setFornitore($fornitore){
- $this->fornitore = $fornitore;
+ function setOpzioni($opzioni){
+ $this->opzioni = $opzioni;
}
- function getFornitore(){
- return $this->fornitore;
+
+ function getOpzioni(){
+ return $this->opzioni;
}
+
function setNew(bool $new){
return $this->new = $new;
}
@@ -170,6 +172,12 @@ function getSearchId(){
}
return $this->ricerche[count($this->ricerche) - 1]->id_ricerca;
}
+ function getSearch(){
+ if(count($this->ricerche) == NULL){
+ return FALSE;
+ }
+ return $this->ricerche[count($this->ricerche) - 1];
+ }
function getSearchCount(){
return count($this->ricerche);
From 5e1289e81c144d693c010e79379a07251347d9d6 Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Wed, 16 Jun 2021 14:20:09 +0200
Subject: [PATCH 20/85] Implementate ultime versioni API
---
composer.json | 38 +-
readme.md | 102 +--
src/OpenApi.php | 764 +++++++++---------
src/classes/FirmaDigitale.php | 13 +
src/classes/Imprese.php | 244 +++---
src/classes/OpenApiBase.php | 412 +++++-----
src/classes/Pec.php | 31 +
src/classes/PecMassiva.php | 152 ++--
src/classes/UfficioPostale.php | 84 +-
src/classes/Uploader.php | 43 +-
src/classes/VisEngine.php | 110 +--
.../exception/OpenApiConnectionsException.php | 32 +-
.../exception/OpenApiExceptionBase.php | 130 +--
.../exception/OpenApiPecMassivaException.php | 28 +-
.../exception/OpenApiTokenException.php | 30 +-
src/classes/utility/DummyCache.php | 44 +-
.../UfficioPostale/Objects/Recipient.php | 29 +
.../utility/UfficioPostale/Raccomandata.php | 26 +
.../utility/UfficioPostale/ServiziPostali.php | 9 +
src/classes/utility/Uploader/Collection.php | 17 +
20 files changed, 1241 insertions(+), 1097 deletions(-)
create mode 100644 src/classes/Pec.php
diff --git a/composer.json b/composer.json
index e91e179..51fc60f 100644
--- a/composer.json
+++ b/composer.json
@@ -1,19 +1,19 @@
-{
- "name": "altravia/openapi",
- "description": "OpenApi PHP Libraries (https://openapi.it)",
- "authors": [
- {
- "name": "Altravia",
- "email": "info@altravia.com"
- }
- ],
- "minimum-stability": "stable",
- "require": {
- "php": ">=7.2.0"
- },
- "autoload": {
- "psr-4": {
- "OpenApi\\": "src"
- }
- }
-}
+{
+ "name": "altravia/openapi",
+ "description": "OpenApi PHP Libraries (https://openapi.it)",
+ "authors": [
+ {
+ "name": "Altravia",
+ "email": "info@altravia.com"
+ }
+ ],
+ "minimum-stability": "stable",
+ "require": {
+ "php": ">=7.2.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "OpenApi\\": "src"
+ }
+ }
+}
diff --git a/readme.md b/readme.md
index c4f92d6..c6a0a76 100644
--- a/readme.md
+++ b/readme.md
@@ -1,51 +1,51 @@
-# OpenAPI Library
-
-## Usage
-
-### Instanza della classe
-
-```
- $this->openapi = new \OpenApi\OpenApi($scopes,$user,$apikey,"test");
-```
-
-Dove ```$scopes``` è un array di stringhe o di oggetti in uno dei seguenti formati:
-
-```php
-$scopes=[
-"GET:ws.ufficiopostale.com/comuni",
-["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
-];
-```
-
-A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
-
-```php
-$this->openapi->ufficiopostale
-$this->openapi->imprese
-...
-```
-
-che possono essere usati al seguente modo:
-
-```php
-$this->openapi->ufficioposale->getCitiesByCap('00132');
-```
-
-# Modulo ufficio postale
-
-# Modulo visure
-
-# Modulo imprese
-
-## `getByPartitaIva`
-
-### Introduction
-
-La funzione consente di recuperare i dati aziendali a partire dalla partita IVA
-
-### Description
-
-`function getByPartitaIva(string $partitaIva, $ttl = 86400):object`
-
-* $partitaIva: La partita IVA da cercare
-* $ttl: Time To Release, per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+# OpenAPI Library
+
+## Usage
+
+### Instanza della classe
+
+```
+ $this->openapi = new \OpenApi\OpenApi($scopes,$user,$apikey,"test");
+```
+
+Dove ```$scopes``` è un array di stringhe o di oggetti in uno dei seguenti formati:
+
+```php
+$scopes=[
+"GET:ws.ufficiopostale.com/comuni",
+["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
+];
+```
+
+A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
+
+```php
+$this->openapi->ufficiopostale
+$this->openapi->imprese
+...
+```
+
+che possono essere usati al seguente modo:
+
+```php
+$this->openapi->ufficioposale->getCitiesByCap('00132');
+```
+
+# Modulo ufficio postale
+
+# Modulo visure
+
+# Modulo imprese
+
+## `getByPartitaIva`
+
+### Introduction
+
+La funzione consente di recuperare i dati aziendali a partire dalla partita IVA
+
+### Description
+
+`function getByPartitaIva(string $partitaIva, $ttl = 86400):object`
+
+* $partitaIva: La partita IVA da cercare
+* $ttl: Time To Release, per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
diff --git a/src/OpenApi.php b/src/OpenApi.php
index ba80854..89a6d44 100644
--- a/src/OpenApi.php
+++ b/src/OpenApi.php
@@ -1,380 +1,384 @@
-"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"] oppure "GET:ws.ufficiopostale.com/comuni NOTA: il dominio NON deve mai avere lo stage
- * @param string $username Username openapi
- * @param string $apikey ApiKey openapi
- * @param mixed $environment='test' uno tra: dev, test (default), production
- */
- function __construct(array $scopes, string $username, string $apikey, $environment='test', $store = NULL){
- if($store == NULL) {
- $store = new \OpenApi\classes\utility\sessionStoreToken;
- }
- $this->cache = new \OpenApi\classes\utility\DummyCache;
- $this->store = $store;
- $this->header = null;
- $this->rawResponse = null;
- $realScopes = [];
- $domainsRealScopes = [];
- $prefix = $environment=="production"?"":$environment.".";
- $domains = [];
- //var_dump($scopes);exit;
- foreach($scopes as $s){
- if($s == NULL){
- continue;
- }
- if(is_array($s)){
- $domain = $s['domain'];
- $realScope = $s['mode'].":".$prefix.$s['domain']."/".$s['method'];
- }else{
- $realScope = str_replace(":",":{$prefix}", $s) ;
- $domain = explode(":", $s)[1];
- $domain = explode("/", $domain)[0];
- }
- if(!in_array($domain, $domains)){
- $domains[] = $domain;
- $domainsRealScopes[$domain] = [];
- }
-
- if(!in_array($realScope,$realScopes)){
- $realScopes[] = $realScope;
- $domainsRealScopes[$domain][] = $realScope;
- }
-
- }
-
- $this->username = $username;
- $this->apikey = $apikey;
- $this->prefix = $prefix;
- $this->scopes = $realScopes;
- $token = $this->getToken();
-
- list($moduli,$nomi) = $this->getListaModuli();
- $this->clients = [];
- foreach($domains as $d){
- if(isset($moduli[$d])){
- $modulo = $moduli[$d];
- $nome = $nomi[$d];
- $this->$nome = new $modulo($token->token, $domainsRealScopes[$d], $this->cache, $prefix);
- $this->clients[] = $nome;
- }
- }
-
- $this->validations = new \OpenApi\classes\utility\Plugins\Validations();
- $this->fiscalCode = new \OpenApi\classes\utility\Plugins\FiscalCode();
- //$this->geocoding = new \OpenApi\classes\Geocoding($token->token, [], $this->cache, "");
- }
-
- /**
- *
- * Restituisce la lista dei moduli disponibili
- *
- * @return array
- */
- private function getListaModuli(){
- $moduli = [];
- $nomi = [];
- $moduli['ws.ufficiopostale.com'] = "\\OpenApi\\classes\\UfficioPostale";
- $nomi['ws.ufficiopostale.com'] = "ufficiopostale";
- $moduli['imprese.altravia.com'] = "\\OpenApi\\classes\\Imprese";
- $nomi['imprese.altravia.com'] = "imprese";
-
- $moduli['visengine2.altravia.com'] = "\\OpenApi\\classes\\VisEngine";
- $nomi['visengine2.altravia.com'] = "visengine";
-
-
- $moduli['comuni.openapi.it'] = "\\OpenApi\\classes\\Comuni";
- $nomi['comuni.openapi.it'] = "comuni";
-
-
- $moduli['ws.marchetemporali.com'] = "\\OpenApi\\classes\\MarcheTemporali";
- $nomi['ws.marchetemporali.com'] = "marcheTemporali";
-
-
- $moduli['geocoding.realgest.it'] = "\\OpenApi\\classes\\Geocoding";
- $nomi['geocoding.realgest.it'] = "geocoding";
-
- $moduli['ws.messaggisms.com'] = "\\OpenApi\\classes\\Sms";
- $nomi['ws.messaggisms.com'] = "SMS";
-
-
- $moduli['ws.firmadigitale.com'] = "\\OpenApi\\classes\\FirmaDigitale";
- $nomi['ws.firmadigitale.com'] = "firmaDigitale";
-
- $moduli['ws.pecmassiva.com'] = "\\OpenApi\\classes\\PecMassiva";
- $nomi['ws.pecmassiva.com'] = "pecMassiva";
-
- $moduli['uploader.altravia.com'] = "\\OpenApi\\classes\\Uploader";
- $nomi['uploader.altravia.com'] = "uploader";
- return array($moduli,$nomi);
- }
-
- /**
- * Imposta la calsse da utilizzare sistema di cache, deve essere una classe che estende
- * {@see OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
- *
- * @param mixed $cacheSys Istanza della classe da usare come sistema di cache
- * @return void
- */
- function setCacheSystem($cacheSys){
- $this->cache = $cacheSys;
- foreach($this->clients as $c){
- $this->$c->setCacheSystem($cacheSys);
- }
- }
-
-
- /**
- *
- * Restituisce il token attualemnte in sessione, se non presente o non più valido lo rigenera
- *
- * @param boolean $force=FALSE Se impostato a TRUE forza la rigenerazione del token
- * @return object il token
- */
- function getToken($force=FALSE){
- if(!$force && !$this->isTokenCompatible()){
-
- if(!$this->mustRfreshToken()){
- return $this->store->get()['token'];
- }
- $this->renewToken();
-
- return $this->store->get()['token'];
- }
- if($this->getOldToken()){
- if(!$this->mustRfreshToken()){
- return $this->store->get()['token'];
- }
- $this->renewToken();
- return $this->store->get()['token'];
- }
- return $this->generateNewToken();
- }
-
-
- /**
- * Rinnova il token in sessione
- *
- * @return object
- */
- private function renewToken(){
- $param = ["expire" => time() + 86400, "scopes" => $this->scopes];
- //var_dump($param);exit;
-
- $token = $this->connect("token/".$this->store->get()['token']->token,$param,"PUT");
-
- if($token == NULL){
- throw new \OpenApi\classes\exception\OpenApiTokenException("Renew Token: Connection Error",40001);
- }
- if($token->success == false){
- $message = "REnew Token: unknow error";
- if(isset($token->message)) {
- $message = "REnew Token: $token->message";
- }
- $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40002);
- $except->setServerResponse($token, $this->header, $this->rawResponse);
-
- throw $except;
- }
- if(isset($token->data) && isset($token->data[0]))
- {
- $token = $token->data[0];
- $this->store->get()['token'] = $token;
- return $token;
- }
-
- }
-
-
- /**
- * Controlla se il token in sessione deve essere o meno rinnovato in base alla sua data di scadenza
- *
- * @return bool
- */
- private function mustRfreshToken(){
- $token = $this->store->get()['token'];
- $diff = $token->expire-date("U");
- if($diff <= 6000){
- return TRUE;
- }
- return FALSE;
- }
-
-
- /**
- *
- * Recupera la lista di token per verificare se esiste uno utilizzabile con gli scopes di interesse,
- * se si lo mette in sessione e ritorna TRUE
- *
- * @return boolean
- */
- function getOldToken(){
- $param = ["scope" => $this->scopes];
- $token = $this->connect("token",$param,"GET");
-
- $finded_token = NULL;
-
- if($token != NULL && isset($token->data)){
- foreach($token->data AS $token){
- if($this->hasValidScopes($token)){
- $finded_token = $token;
- break 1;
- }
- }
-
- if($finded_token != NULL){
- $tostore['token'] = $finded_token;
- $tostore['apikey'] = $this->apikey;
- $tostore['scopes'] = serialize($this->scopes);
- $tostore['username'] = $this->username;
- $tostore['prefix'] = $this->prefix;
- $this->store->save($tostore);
- return TRUE;
- }
- return FALSE;
- }
- }
-
- function hasValidScopes($token){
- foreach($this->scopes as $s){
- if(!in_array($s, $token->scopes)){
- return false;
- }
- }
- return true;
- }
-
- /**
- * Genera un nuovo token
- * @return object il token
- */
- private function generateNewToken(){
- $param = ["scopes" => $this->scopes];
- $token = $this->connect("token",$param,"POST");
- if($token == NULL){
- throw new \OpenApi\classes\exception\OpenApiTokenException("Getting Token: Connection Error",40001);
- }
- if($token->success == false){
- $message = "Getting Token: unknow error";
- if(isset($token->message)) {
- $message = "Getting Token: $token->message";
- }
- $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40002);
- $except->setServerResponse($token, $this->header, $this->rawResponse);
-
- throw $except;
- }
-
- $invalid_scopes = [];
- foreach($this->scopes as $s){
- if(!in_array($s, $token->scopes)){
- $invalid_scopes[] = $s;
- }
- }
- if(count($invalid_scopes)>0){
- $message = "Getting Token: unknow error";
- if(isset($token->message)) {
-
- }
- $message = "Getting Token: invalid scopes (".implode($invalid_scopes).")";
- $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40003);
- $except->setServerResponse($token, $this->header, $this->rawResponse);
- throw $except;
- }
- $tostore['token'] = $token;
- $tostore['apikey'] = $this->apikey;
- $tostore['scopes'] = serialize($this->scopes);
- $tostore['username'] = $this->username;
- $tostore['prefix'] = $this->prefix;
-
- $this->store->save($tostore);
-
- return $token;
- }
-
-
- /**
- *
- * Constrolla se il token in sessione è compatibile con la richiesta
- *
- * @return boolean
- */
- private function isTokenCompatible() {
- if(!$this->store->isset()|| !isset($this->store->get()['token'])){
- return TRUE;
- }
- if($this->store->get()['prefix'] != $this->prefix || $this->store->get()['apikey'] != $this->apikey || $this->store->get()['username'] != $this->username){
- return TRUE;
- }
- $sessionScopes = unserialize($this->store->get()['scopes']);
- if(!is_array($sessionScopes)){
- return TRUE;
- }
- foreach($this->scopes as $s){
- if(!in_array($s, $sessionScopes)){
- return TRUE;
- }
- }
- return FALSE;
- }
-
-
- /**
- * Effettua una connessione al server oauth
- *
- * @param string $endpoint path da recuperare
- * @param array $param Lista dei parametri da passare
- * @param mixed $mode metodo http da usare per la chiamata
- * @return object
- */
- private function connect(string $endpoint, $param = [], $mode="POST"){
-
- $this->header = null;
- $this->rawResponse = null;
- $basePath = "https://".$this->prefix."oauth.altravia.com";
- $url = $basePath."/".$endpoint;
- if($mode == "GET")
- {
- $param = http_build_query($param);
- $param = preg_replace('/(%5B)\d+(%5D=)/i', '$1$2', $param);
- $url .= "?".$param;
- }
-
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode);
- if($mode == "POST" || $mode == "PUT")
- {
- curl_setopt($ch, CURLOPT_POST, TRUE);
- }
- if($mode != "GET")
- {
- $param = json_encode($param);
-
- curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
- }
-
- $baseauth = base64_encode($this->username.":".$this->apikey);
- $headers = array(
- 'Content-Type:application/json',
- 'Authorization: Basic '. $baseauth
- );
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
-
-
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
-
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- $response = curl_exec($ch);
- $this->rawResponse = $response;
-
- $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
- $this->header = substr($response, 0, $header_size);
- $return = substr($response, $header_size);
- curl_close($ch);
- return json_decode($return);
- }
-}
+"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"] oppure "GET:ws.ufficiopostale.com/comuni NOTA: il dominio NON deve mai avere lo stage
+ * @param string $username Username openapi
+ * @param string $apikey ApiKey openapi
+ * @param mixed $environment='test' uno tra: dev, test (default), production
+ */
+ function __construct(array $scopes, string $username, string $apikey, $environment='test', $store = NULL){
+ if($store == NULL) {
+ $store = new \OpenApi\classes\utility\sessionStoreToken;
+ }
+ $this->cache = new \OpenApi\classes\utility\DummyCache;
+ $this->store = $store;
+ $this->header = null;
+ $this->rawResponse = null;
+ $realScopes = [];
+ $domainsRealScopes = [];
+ $prefix = $environment=="production"?"":$environment.".";
+ $domains = [];
+ //var_dump($scopes);exit;
+ foreach($scopes as $s){
+ if($s == NULL){
+ continue;
+ }
+ if(is_array($s)){
+ $domain = $s['domain'];
+ $realScope = $s['mode'].":".$prefix.$s['domain']."/".$s['method'];
+ }else{
+ $realScope = str_replace(":",":{$prefix}", $s) ;
+ $domain = explode(":", $s)[1];
+ $domain = explode("/", $domain)[0];
+ }
+ if(!in_array($domain, $domains)){
+ $domains[] = $domain;
+ $domainsRealScopes[$domain] = [];
+ }
+
+ if(!in_array($realScope,$realScopes)){
+ $realScopes[] = $realScope;
+ $domainsRealScopes[$domain][] = $realScope;
+ }
+
+ }
+
+ $this->username = $username;
+ $this->apikey = $apikey;
+ $this->prefix = $prefix;
+ $this->scopes = $realScopes;
+ $token = $this->getToken();
+ /*
+ if($_SERVER['REMOTE_ADDR'] == "37.163.55.217"){
+ var_dump($token);exit;
+ }
+ */
+ //var_dump($token);
+ list($moduli,$nomi) = $this->getListaModuli();
+ $this->clients = [];
+ foreach($domains as $d){
+ if(isset($moduli[$d])){
+ $modulo = $moduli[$d];
+ $nome = $nomi[$d];
+ $this->$nome = new $modulo($token->token, $domainsRealScopes[$d], $this->cache, $prefix);
+ $this->clients[] = $nome;
+ }
+ }
+
+ $this->validations = new \OpenApi\classes\utility\Plugins\Validations();
+ $this->fiscalCode = new \OpenApi\classes\utility\Plugins\FiscalCode();
+ // $this->ufficiopostale = new \OpenApi\classes\UfficioPostale($token->token, $domainsRealScopes[$d], $this->cache, $prefix);
+ }
+
+ /**
+ *
+ * Restituisce la lista dei moduli disponibili
+ *
+ * @return array
+ */
+ private function getListaModuli(){
+ $moduli = [];
+ $nomi = [];
+ $moduli['ws.ufficiopostale.com'] = "\\OpenApi\\classes\\UfficioPostale";
+ $nomi['ws.ufficiopostale.com'] = "ufficiopostale";
+
+ $moduli['imprese.altravia.com'] = "\\OpenApi\\classes\\Imprese";
+ $nomi['imprese.altravia.com'] = "imprese";
+
+ $moduli['visengine2.altravia.com'] = "\\OpenApi\\classes\\VisEngine";
+ $nomi['visengine2.altravia.com'] = "visengine";
+
+
+ $moduli['comuni.openapi.it'] = "\\OpenApi\\classes\\Comuni";
+ $nomi['comuni.openapi.it'] = "comuni";
+
+
+ $moduli['ws.marchetemporali.com'] = "\\OpenApi\\classes\\MarcheTemporali";
+ $nomi['ws.marchetemporali.com'] = "marcheTemporali";
+
+
+ $moduli['geocoding.realgest.it'] = "\\OpenApi\\classes\\Geocoding";
+ $nomi['geocoding.realgest.it'] = "geocoding";
+
+ $moduli['uploader.altravia.com'] = "\\OpenApi\\classes\\Uploader";
+ $nomi['uploader.altravia.com'] = "uploader";
+
+ $moduli['ws.messaggisms.com'] = "\\OpenApi\\classes\\Sms";
+ $nomi['ws.messaggisms.com'] = "SMS";
+
+ $moduli['pec.openapi.it'] = "\\OpenApi\\classes\\Pec";
+ $nomi['pec.openapi.it'] = "PEC";
+ $moduli['ws.firmadigitale.com'] = "\\OpenApi\\classes\\FirmaDigitale";
+ $nomi['ws.firmadigitale.com'] = "firmaDigitale";
+ return array($moduli,$nomi);
+ }
+
+ /**
+ * Imposta la calsse da utilizzare sistema di cache, deve essere una classe che estende
+ * {@see OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
+ *
+ * @param mixed $cacheSys Istanza della classe da usare come sistema di cache
+ * @return void
+ */
+ function setCacheSystem($cacheSys){
+ $this->cache = $cacheSys;
+ foreach($this->clients as $c){
+ $this->$c->setCacheSystem($cacheSys);
+ }
+ }
+
+
+ /**
+ *
+ * Restituisce il token attualemnte in sessione, se non presente o non più valido lo rigenera
+ *
+ * @param boolean $force=FALSE Se impostato a TRUE forza la rigenerazione del token
+ * @return object il token
+ */
+ function getToken($force=FALSE){
+ if(!$force && !$this->isTokenCompatible()){
+
+ if(!$this->mustRfreshToken()){
+ return $this->store->get()['token'];
+ }
+ $this->renewToken();
+
+ return $this->store->get()['token'];
+ }
+ if($this->getOldToken()){
+ if(!$this->mustRfreshToken()){
+ return $this->store->get()['token'];
+ }
+ $this->renewToken();
+ return $this->store->get()['token'];
+ }
+ return $this->generateNewToken();
+ }
+
+
+ /**
+ * Rinnova il token in sessione
+ *
+ * @return object
+ */
+ private function renewToken(){
+ $param = ["expire" => time() + 86400, "scopes" => $this->scopes];
+ //var_dump($param);exit;
+
+ $token = $this->connect("token/".$this->store->get()['token']->token,$param,"PUT");
+
+ if($token == NULL){
+ throw new \OpenApi\classes\exception\OpenApiTokenException("Renew Token: Connection Error",40001);
+ }
+ if($token->success == false){
+ $message = "REnew Token: unknow error";
+ if(isset($token->message)) {
+ $message = "REnew Token: $token->message";
+ }
+ $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40002);
+ $except->setServerResponse($token, $this->header, $this->rawResponse);
+
+ throw $except;
+ }
+ if(isset($token->data) && isset($token->data[0]))
+ {
+ $token = $token->data[0];
+ $this->store->get()['token'] = $token;
+ return $token;
+ }
+
+ }
+
+
+ /**
+ * Controlla se il token in sessione deve essere o meno rinnovato in base alla sua data di scadenza
+ *
+ * @return bool
+ */
+ private function mustRfreshToken(){
+ $token = $this->store->get()['token'];
+ $diff = $token->expire-date("U");
+ if($diff <= 6000){
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+
+ /**
+ *
+ * Recupera la lista di token per verificare se esiste uno utilizzabile con gli scopes di interesse,
+ * se si lo mette in sessione e ritorna TRUE
+ *
+ * @return boolean
+ */
+ function getOldToken(){
+ $param = ["scope" => $this->scopes];
+ $token = $this->connect("token",$param,"GET");
+
+ $finded_token = NULL;
+
+ if($token != NULL && isset($token->data)){
+ foreach($token->data AS $token){
+ if($this->hasValidScopes($token)){
+ $finded_token = $token;
+ break 1;
+ }
+ }
+
+ if($finded_token != NULL){
+ $tostore['token'] = $finded_token;
+ $tostore['apikey'] = $this->apikey;
+ $tostore['scopes'] = serialize($this->scopes);
+ $tostore['username'] = $this->username;
+ $tostore['prefix'] = $this->prefix;
+ $this->store->save($tostore);
+ return TRUE;
+ }
+ return FALSE;
+ }
+ }
+
+ function hasValidScopes($token){
+ foreach($this->scopes as $s){
+ if(!in_array($s, $token->scopes)){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Genera un nuovo token
+ * @return object il token
+ */
+ private function generateNewToken(){
+ $param = ["scopes" => $this->scopes];
+ $token = $this->connect("token",$param,"POST");
+ if($token == NULL){
+ throw new \OpenApi\classes\exception\OpenApiTokenException("Getting Token: Connection Error",40001);
+ }
+ if($token->success == false){
+ $message = "Getting Token: unknow error";
+ if(isset($token->message)) {
+ $message = "Getting Token: $token->message";
+ }
+ $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40002);
+ $except->setServerResponse($token, $this->header, $this->rawResponse);
+
+ throw $except;
+ }
+
+ $invalid_scopes = [];
+ foreach($this->scopes as $s){
+ if(!in_array($s, $token->scopes)){
+ $invalid_scopes[] = $s;
+ }
+ }
+ if(count($invalid_scopes)>0){
+ $message = "Getting Token: unknow error";
+ if(isset($token->message)) {
+
+ }
+ $message = "Getting Token: invalid scopes (".implode($invalid_scopes).")";
+ $except = new \OpenApi\classes\exception\OpenApiTokenException($message,40003);
+ $except->setServerResponse($token, $this->header, $this->rawResponse);
+ throw $except;
+ }
+ $tostore['token'] = $token;
+ $tostore['apikey'] = $this->apikey;
+ $tostore['scopes'] = serialize($this->scopes);
+ $tostore['username'] = $this->username;
+ $tostore['prefix'] = $this->prefix;
+
+ $this->store->save($tostore);
+
+ return $token;
+ }
+
+
+ /**
+ *
+ * Constrolla se il token in sessione è compatibile con la richiesta
+ *
+ * @return boolean
+ */
+ private function isTokenCompatible() {
+ if(!$this->store->isset()|| !isset($this->store->get()['token'])){
+ return TRUE;
+ }
+ if($this->store->get()['prefix'] != $this->prefix || $this->store->get()['apikey'] != $this->apikey || $this->store->get()['username'] != $this->username){
+ return TRUE;
+ }
+ $sessionScopes = unserialize($this->store->get()['scopes']);
+ if(!is_array($sessionScopes)){
+ return TRUE;
+ }
+ foreach($this->scopes as $s){
+ if(!in_array($s, $sessionScopes)){
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+
+
+ /**
+ * Effettua una connessione al server oauth
+ *
+ * @param string $endpoint path da recuperare
+ * @param array $param Lista dei parametri da passare
+ * @param mixed $mode metodo http da usare per la chiamata
+ * @return object
+ */
+ private function connect(string $endpoint, $param = [], $mode="POST"){
+
+ $this->header = null;
+ $this->rawResponse = null;
+ $basePath = "https://".$this->prefix."oauth.altravia.com";
+ $url = $basePath."/".$endpoint;
+ if($mode == "GET")
+ {
+ $param = http_build_query($param);
+ $param = preg_replace('/(%5B)\d+(%5D=)/i', '$1$2', $param);
+ $url .= "?".$param;
+ }
+
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode);
+ if($mode == "POST" || $mode == "PUT")
+ {
+ curl_setopt($ch, CURLOPT_POST, TRUE);
+ }
+ if($mode != "GET")
+ {
+ $param = json_encode($param);
+
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
+ }
+
+ $baseauth = base64_encode($this->username.":".$this->apikey);
+ $headers = array(
+ 'Content-Type:application/json',
+ 'Authorization: Basic '. $baseauth
+ );
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+
+
+ curl_setopt($ch, CURLOPT_TIMEOUT, 30);
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ $response = curl_exec($ch);
+ $this->rawResponse = $response;
+
+ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+ $this->header = substr($response, 0, $header_size);
+ $return = substr($response, $header_size);
+ curl_close($ch);
+ return json_decode($return);
+ }
+}
diff --git a/src/classes/FirmaDigitale.php b/src/classes/FirmaDigitale.php
index 9e2abc0..f0ed548 100644
--- a/src/classes/FirmaDigitale.php
+++ b/src/classes/FirmaDigitale.php
@@ -71,8 +71,21 @@ function requestProduct($data){
if($callback != NULL){
$params['callback'] = $callback;
}
+ if(isset($data['options'])){
+ foreach($data['options'] as $key =>$value){
+ $params[$key] = $value;
+ }
+ }
+//var_dump(json_encode($params));exit;
+
$ret = $this->connect("richiesta/$codice_prodotto","POST",$params);
return $ret;
}
+ function addVideoRiconoscimento($id_fd){
+ $param['id'] = $id_fd;
+ $ret = $this->connect("richiesta/VIDEORIC","POST",$param);
+ return $ret;
+ }
+
}
\ No newline at end of file
diff --git a/src/classes/Imprese.php b/src/classes/Imprese.php
index 22255ab..c4fa12f 100644
--- a/src/classes/Imprese.php
+++ b/src/classes/Imprese.php
@@ -1,122 +1,124 @@
-basePath = "https://imprese.altravia.com";
- }
-
- /**
- *
- * Consente di recuperare i dati di una azienda a partire dalla partita IVA
- *
- * @param string $partitaIva La partita IVa da ricercare
- * @param int $ttr Time to Release: per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
- *
- * @return object
- */
- function getByPartitaIva(string $partitaIva, $ttr = 86400){
- $partitaIva = trim($partitaIva);
- try{
- $data = $this->connect("advance/$partitaIva", "GET", [], $ttr);
- return $data->data;
- }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
- if($e->getHTTPCode() == 404){
- return null;
- }
- throw $e;
-
-
- exit;
- }
-
-
- }
-
- function getClosed(string $partitaIva, $ttr = 86400){
- $partitaIva = trim($partitaIva);
- try{
- $data = $this->connect("closed/$partitaIva", "GET", [], $ttr);
- return $data->data;
- }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
-
- if($e->getHTTPCode() == 404){
- return null;
- }
- throw $e;
-
-
- exit;
- }
- }
-
- function getVatGroup(string $partitaIva, $ttr = 86400){
- $partitaIva = trim($partitaIva);
- try{
- $data = $this->connect("gruppoIva/$partitaIva", "GET", [], $ttr);
- return $data->data;
- }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
-
- if($e->getHTTPCode() == 404){
- return null;
- }
- throw $e;
-
-
- exit;
- }
- }
-
- function getPec(string $partitaIva, $ttr = 86400){
- $partitaIva = trim($partitaIva);
- try{
- $data = $this->connect("pec/$partitaIva", "GET", [], $ttr);
- return $data->data;
- }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
-
- if($e->getHTTPCode() == 404){
- return null;
- }
- throw $e;
-
-
- exit;
- }
- }
-
- /**
- *
- * Cerca un'azienda o più utilizzando vari parametri
- *
- * @param string $denominazione Denominazione azienda
- * @param string $provincia Provincia
- * @param string $partitaIva=NULL Partita IVA
- * @param string $codiceFiscale=NULL Codice Fiscale
- * @param int $ttr Time to Release: per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
- *
- * @return array Lista delle aziende individuate
- */
- function getBySearch(string $denominazione, string $provincia, $partitaIva= NULL , $codiceFiscale=NULL, $ttr = 86400){
- $params=[];
- if($denominazione != NULL){
- $params['denominazione'] = trim($denominazione);
- }
- if($provincia != NULL){
- $params['provincia'] = $provincia;
- }
- if($partitaIva != NULL){
- $params['piva'] = $partitaIva;
- }
- if($codiceFiscale != NULL){
- $params['cf'] = $codiceFiscale;
- }
-
- $data = $this->connect("advance/$partitaIva", "GET", $params, $ttr);
- return $data->data;
- }
+basePath = "https://imprese.altravia.com";
+ }
+
+ /**
+ *
+ * Consente di recuperare i dati di una azienda a partire dalla partita IVA
+ *
+ * @param string $partitaIva La partita IVa da ricercare
+ * @param int $ttr Time to Release: per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+ *
+ * @return object
+ */
+ function getByPartitaIva(string $partitaIva, $ttr = 86400, $force = false){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("advance/$partitaIva", "GET", [], $ttr, true);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+
+
+ }
+
+ function getClosed(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("closed/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
+ function getVatGroup(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("gruppoIva/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
+ function getPec(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("pec/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
+ /**
+ *
+ * Cerca un'azienda o più utilizzando vari parametri
+ *
+ * @param string $denominazione Denominazione azienda
+ * @param string $provincia Provincia
+ * @param string $partitaIva=NULL Partita IVA
+ * @param string $codiceFiscale=NULL Codice Fiscale
+ * @param int $ttr Time to Release: per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+ *
+ * @return array Lista delle aziende individuate
+ */
+ function getBySearch(string $denominazione, string $provincia, $partitaIva= NULL , $codiceFiscale=NULL, $ttr = 86400){
+ $params=[];
+ if($denominazione != NULL){
+ $params['denominazione'] = trim($denominazione);
+ }
+ if($provincia != NULL){
+ $params['provincia'] = $provincia;
+ }
+ if($partitaIva != NULL){
+ $params['piva'] = $partitaIva;
+ }
+ if($codiceFiscale != NULL){
+ $params['cf'] = $codiceFiscale;
+ }
+
+ $data = $this->connect("advance/$partitaIva", "GET", $params, $ttr);
+ return $data->data;
+ }
}
\ No newline at end of file
diff --git a/src/classes/OpenApiBase.php b/src/classes/OpenApiBase.php
index 4c014d6..705bec4 100644
--- a/src/classes/OpenApiBase.php
+++ b/src/classes/OpenApiBase.php
@@ -1,205 +1,209 @@
-token = $token;
- $this->cache = $cache;
- $this->scopes = $scopes;
- $this->prefix = $prefix;
- $this->basePath = null;
- }
-
- /**
- * Imposta la calsse da utilizzare sistema di cache, deve essere una classe che estende
- * {@see \OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
- *
- * @param object $cacheSys Istanza della classe da usare come sistema di cache
- * @return void
- */
- function setCacheSystem(object $cacheSys){
- $this->cache = $cacheSys;
- }
-
-
-
- /**
- * Salva un oggetto nella cache
- * @param string $key LA chiave utilizzata per salvare l'oggetto nella cache
- * @param object $value L'oggetto da salvare nella cache
- * @param int $ttr TEmpo in cui l'oggetto resta in cache
- *
- * @return void
- */
- protected function setCacheObject(string $key, object $value, int $ttr){
- $ttr += rand ( 0 , 120 );
- $this->cache->save($key, $value, $ttr);
- }
-
- /**
- *
- * Recupera un oggetto dalla cache se presente
- *
- * @param string $key LA chiave da utilizzare per recuperare l'oggetto in cache
- *
- * @return mixed L'oggetto o NUL se insesistente
- */
- protected function getCacheObject(string $key){
- $cached = $this->cache->get($key);
- if($cached){
- return $cached;
- }
- return false;
- }
-
- /**
- *
- * Controlla se si ha lo scope necessario per poter invocare il metodo, in caso contrario scatena un'eccezione
- *
- * @param string $url
- *
- * @return void
- */
- private function checkHasScope(string $url, string $type){
- $parsed = parse_url($url);
- $permission = $type.":".$parsed['host'];
- $path = $parsed['path'];
- $path = explode("/", $path);
- if(isset($path[1])){
- $permission .= "/".$path[1];
- }
- if(!in_array($permission, $this->scopes)){
- throw new \OpenApi\classes\exception\OpenApiConnectionsException("Scope missed: $permission",40004);
- }
-
- }
-
- /**
- * @param string $endpoint Endpoint da richiamare
- * @param string $type Tipo di chiamata
- * @param array $param Parametri da passare alla chiamata
- * @param int $ttr Tempo in cui la chiamata resta in cache (0 = no cache)
- *
- * @return mixed
- */
- public function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $addHeader = NULL){
- $url = $this->basePath;
- $url = str_replace("https://","https://".$this->prefix,$url);
- $url = str_replace("http://","http://".$this->prefix,$url);
- $url .= "/".$endpoint;
- if(!$force){
- $this->checkHasScope($url, $type);
- }
-
-
- if($type == "GET" && $ttr > 0 && $ret = $this->getCacheObject($url)) {
- return $ret;
- }
- $ch = curl_init();
- if($type == "POST" || $type == "PUT") {
- curl_setopt($ch, CURLOPT_POST, TRUE);
- }
- if($param != array()) {
- if($type == "GET") {
- $param = http_build_query($param);
- $url .= "?".$param;
-
- }else{
- $param = json_encode($param);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
- }
- }
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
- $header = array("Authorization: Bearer ".$this->token);
- if($addHeader != NULL && is_array($addHeader) && count($addHeader)>0){
- $header = array_merge($header, $addHeader);
- }
-
-
- curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- $response = curl_exec($ch);
- // var_dump($response);exit;
- $this->rawResponse = $response;
- $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
- $this->header = substr($response, 0, $header_size);
- //var_dump($this->header);exit;
- $this->parsedHEader = $this->parseHeader($this->header);
- $return = substr($response, $header_size);
- $httpCode = curl_getinfo ( $ch, CURLINFO_RESPONSE_CODE );;
- curl_close($ch);
- //echo $return;exit;
- if(isset($this->parsedHEader['Content-Type']) && strtolower($this->parsedHEader['Content-Type']) == "application/json") {
-
- $data = json_decode($return);
- }else if(json_decode($return) != NULL){
- $data = json_decode($return);
-
- }else{
- $data = $return;
- }
-
- if($data == NULL){
- throw new \OpenApi\classes\exception\OpenApiConnectionsException("Connection to $url: Connection Error",40001);
- }
-
- if(is_object($data) && $data->success == false){
- $message = "Connection to $url: unknow error";
- if(isset($data->message)) {
- if(is_string(($data->message))){
- if($dataMessage = json_decode($data->message)){
- $data = $dataMessage;
- }
- $message = "Connection to $url: $data->message";
- }else{
- $message = "Connection to $url error";
- }
-
-
- }
- //var_dump($this->rawResponse);
- $except = new \OpenApi\classes\exception\OpenApiConnectionsException($message,40002);
- $except->setServerResponse($data, $this->header, $this->rawResponse, $httpCode);
-
- throw $except;
- }
- if($type == "GET" && $ttr > 0) {
- $this->setCacheObject($url, $data, $ttr);
- }
- return $data;
- }
-
- protected function parseHeader($headers){
- $headers = explode("\n",$headers);
- $parsedHeaders = array();
- foreach ($headers as $header) {
- $header = trim($header);
-
- $header = explode(":",$header);
-
- if(count($header) < 2){
-
- continue;
- }
- $key = $header[0];
- unset($header[0]);
- $parsedHeaders[trim($key)] = trim(implode(":",$header));
- }
- // exit;
-
- return $parsedHeaders;
- }
-
-
-
-
+token = $token;
+ $this->cache = $cache;
+ $this->scopes = $scopes;
+ $this->prefix = $prefix;
+ $this->basePath = null;
+ }
+
+ /**
+ * Imposta la calsse da utilizzare sistema di cache, deve essere una classe che estende
+ * {@see \OpenApi\clasess\utility\DummyCache} o comunque compatibile con essa (stessi metodi)
+ *
+ * @param object $cacheSys Istanza della classe da usare come sistema di cache
+ * @return void
+ */
+ function setCacheSystem(object $cacheSys){
+ $this->cache = $cacheSys;
+ }
+
+
+
+ /**
+ * Salva un oggetto nella cache
+ * @param string $key LA chiave utilizzata per salvare l'oggetto nella cache
+ * @param object $value L'oggetto da salvare nella cache
+ * @param int $ttr TEmpo in cui l'oggetto resta in cache
+ *
+ * @return void
+ */
+ protected function setCacheObject(string $key, object $value, int $ttr){
+ $ttr += rand ( 0 , 120 );
+ $this->cache->save($key, $value, $ttr);
+ }
+
+ /**
+ *
+ * Recupera un oggetto dalla cache se presente
+ *
+ * @param string $key LA chiave da utilizzare per recuperare l'oggetto in cache
+ *
+ * @return mixed L'oggetto o NUL se insesistente
+ */
+ protected function getCacheObject(string $key){
+ $cached = $this->cache->get($key);
+ if($cached){
+ return $cached;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * Controlla se si ha lo scope necessario per poter invocare il metodo, in caso contrario scatena un'eccezione
+ *
+ * @param string $url
+ *
+ * @return void
+ */
+ private function checkHasScope(string $url, string $type){
+ $parsed = parse_url($url);
+ $permission = $type.":".$parsed['host'];
+ $path = $parsed['path'];
+ $path = explode("/", $path);
+ if(isset($path[1])){
+ $permission .= "/".$path[1];
+ }
+ if(!in_array($permission, $this->scopes)){
+ throw new \OpenApi\classes\exception\OpenApiConnectionsException("Scope missed: $permission",40004);
+ }
+
+ }
+
+ /**
+ * @param string $endpoint Endpoint da richiamare
+ * @param string $type Tipo di chiamata
+ * @param array $param Parametri da passare alla chiamata
+ * @param int $ttr Tempo in cui la chiamata resta in cache (0 = no cache)
+ *
+ * @return mixed
+ */
+ public function connect(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $addHeader = NULL){
+ $url = $this->basePath;
+ //if($url != "https://imprese.altravia.com"){
+ $url = str_replace("https://","https://".$this->prefix,$url);
+ $url = str_replace("http://","http://".$this->prefix,$url);
+ $url .= "/".$endpoint;
+ if(!$force){
+ $this->checkHasScope($url, $type);
+ }
+
+
+ /* if($type == "GET" && $ttr > 0 && $ret = $this->getCacheObject($url)) {
+ return $ret;
+ }*/
+ $ch = curl_init();
+ if($type == "POST" || $type == "PUT") {
+ curl_setopt($ch, CURLOPT_POST, TRUE);
+ }
+ if($param != array()) {
+ if($type == "GET") {
+ $param = http_build_query($param);
+ $url .= "?".$param;
+
+ }else{
+ $param = json_encode($param);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
+ }
+ }
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
+ $header = array("Authorization: Bearer ".$this->token);
+ if($addHeader != NULL && is_array($addHeader) && count($addHeader)>0){
+ $header = array_merge($header, $addHeader);
+ }
+
+
+ curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ $response = curl_exec($ch);
+ // var_dump($response);exit;
+ $this->rawResponse = $response;
+ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+ $this->header = substr($response, 0, $header_size);
+ //var_dump($this->header);exit;
+ $this->parsedHEader = $this->parseHeader($this->header);
+ $return = substr($response, $header_size);
+ $httpCode = curl_getinfo ( $ch, CURLINFO_RESPONSE_CODE );;
+ curl_close($ch);
+ //echo $return;exit;
+ if(isset($this->parsedHEader['Content-Type']) && strtolower($this->parsedHEader['Content-Type']) == "application/json") {
+
+ $data = json_decode($return);
+ }else if(json_decode($return) != NULL){
+ $data = json_decode($return);
+
+ }else{
+ $data = $return;
+ }
+
+ if($data == NULL){
+
+ throw new \OpenApi\classes\exception\OpenApiConnectionsException("Connection to $url: Connection Error",40001);
+ }
+
+ if(is_object($data) && $data->success == false){
+
+
+ $message = "Connection to $url: unknow error";
+ if(isset($data->message)) {
+ if(is_string(($data->message))){
+ if($dataMessage = json_decode($data->message)){
+ $data = $dataMessage;
+ }
+ $message = "Connection to $url: $data->message";
+ }else{
+ $message = "Connection to $url error";
+ }
+
+
+ }
+ //var_dump($this->rawResponse);
+ $except = new \OpenApi\classes\exception\OpenApiConnectionsException($message,40002);
+ $except->setServerResponse($data, $this->header, $this->rawResponse, $httpCode);
+
+ throw $except;
+ }
+ if($type == "GET" && $ttr > 0) {
+ $this->setCacheObject($url, $data, $ttr);
+ }
+ return $data;
+ }
+
+ protected function parseHeader($headers){
+ $headers = explode("\n",$headers);
+ $parsedHeaders = array();
+ foreach ($headers as $header) {
+ $header = trim($header);
+
+ $header = explode(":",$header);
+
+ if(count($header) < 2){
+
+ continue;
+ }
+ $key = $header[0];
+ unset($header[0]);
+ $parsedHeaders[trim($key)] = trim(implode(":",$header));
+ }
+ // exit;
+
+ return $parsedHeaders;
+ }
+
+
+
+
}
\ No newline at end of file
diff --git a/src/classes/Pec.php b/src/classes/Pec.php
new file mode 100644
index 0000000..f88e565
--- /dev/null
+++ b/src/classes/Pec.php
@@ -0,0 +1,31 @@
+basePath = "https://pec.openapi.it";
+ }
+
+ function verify($pec){
+ try{
+ $data = $this->connect("verifica_pec/$pec", "GET");
+ return $data;
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ $res = $e->getServerResponse();
+ var_dump($res);
+ if(isset($res->message) && strpos($res->message,"not available") !== false){
+ return ["success"=>true,"data"=>["available" => false]];
+ }
+
+ return $res;
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/classes/PecMassiva.php b/src/classes/PecMassiva.php
index dcb7f6b..daafed0 100644
--- a/src/classes/PecMassiva.php
+++ b/src/classes/PecMassiva.php
@@ -1,77 +1,77 @@
-basePath = "https://ws.pecmassiva.com";
- $this->inizialized = FALSE;
-
- }
-
- function initialize(string $username, string $password){
- $this->username = $username;
- $this->password = $password;
- $this->inizialized = TRUE;
- }
-
- function getStatus($messageId){
- if(!$this->inizialized){
- throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
- }
-
-
- try{
- $header[] = 'x-username: '.$this->username;
- $header[] = 'x-password: '.$this->password;
- return $this->connect("send/$messageId","GET",[],0,false,$header);
-
- }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
- if(isset($e->getServerResponse()->message_id)){
- throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
- }
- throw $e;
-
- }
- }
-
- function send($recipient, $subject, $body, $attachments = [], $sender = NULL){
- if(!$this->inizialized){
- throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
- }
- $sender = $sender ? $sender : $this->username;
-
- $params['username'] = $this->username;
- $params['password'] = $this->password;
- $params['recipient'] = $recipient;
- $params['subject'] = $subject;
- $params['body'] = $body;
- if(count($attachments)>0){
- $params['attachments'] = $attachments;
- }
- $params['sender'] = $sender;
- try{
- return $this->connect("send","POST",$params);
- }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
- if(isset($e->getServerResponse()->message_id)){
- throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
- }
- throw $e;
-
- }
-
- }
-
-
+basePath = "https://ws.pecmassiva.com";
+ $this->inizialized = FALSE;
+
+ }
+
+ function initialize(string $username, string $password){
+ $this->username = $username;
+ $this->password = $password;
+ $this->inizialized = TRUE;
+ }
+
+ function getStatus($messageId){
+ if(!$this->inizialized){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
+ }
+
+
+ try{
+ $header[] = 'x-username: '.$this->username;
+ $header[] = 'x-password: '.$this->password;
+ return $this->connect("send/$messageId","GET",[],0,false,$header);
+
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if(isset($e->getServerResponse()->message_id)){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
+ }
+ throw $e;
+
+ }
+ }
+
+ function send($recipient, $subject, $body, $attachments = [], $sender = NULL){
+ if(!$this->inizialized){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
+ }
+ $sender = $sender ? $sender : $this->username;
+
+ $params['username'] = $this->username;
+ $params['password'] = $this->password;
+ $params['recipient'] = $recipient;
+ $params['subject'] = $subject;
+ $params['body'] = $body;
+ if(count($attachments)>0){
+ $params['attachments'] = $attachments;
+ }
+ $params['sender'] = $sender;
+ try{
+ return $this->connect("send","POST",$params);
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if(isset($e->getServerResponse()->message_id)){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
+ }
+ throw $e;
+
+ }
+
+ }
+
+
}
\ No newline at end of file
diff --git a/src/classes/UfficioPostale.php b/src/classes/UfficioPostale.php
index 5922159..6ff1dec 100644
--- a/src/classes/UfficioPostale.php
+++ b/src/classes/UfficioPostale.php
@@ -1,33 +1,53 @@
-basePath = "https://ws.ufficiopostale.com";
- }
-
-
- /**
- * Restiuisce un oggetto di tipo raccomandata
- * @return object
- */
- function createRaccomandata(){
- return new \OpenApi\classes\utility\UfficioPostale\Raccomandata(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
-
- return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
- });
- }
-
- //function createRaccomandataByData()
-
-
-
-
-
+basePath = "https://ws.ufficiopostale.com";
+ }
+
+
+ /**
+ * Restiuisce un oggetto di tipo raccomandata
+ * @return object
+ */
+ function createRaccomandata(){
+ return new \OpenApi\classes\utility\UfficioPostale\Raccomandata(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
+
+ return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
+ });
+
+
+ }
+
+ function getRaccomandataById($id){
+ $data = $this->connect("raccomandate/$id", "GET");
+
+ return $this->getRaccomandataByData($data->data);
+ }
+
+ function getRaccomandataByData($data){
+ $busta = $this->createRaccomandata();
+ $busta->creaRaccomandataByData($data);
+ return $busta;
+ }
+
+ function getPricing($type = NULL){
+ return $this->connect("pricing/$type", "GET");
+ }
+
+ function track($tracking_code){
+ return $this->connect("tracking/$tracking_code", "GET");
+ }
+
+
+
+
+
}
\ No newline at end of file
diff --git a/src/classes/Uploader.php b/src/classes/Uploader.php
index dabf401..1b5d67f 100644
--- a/src/classes/Uploader.php
+++ b/src/classes/Uploader.php
@@ -31,10 +31,47 @@ function gateway(){
$data = file_get_contents("php://input");
$data = json_decode($data);
}
-
- $data = $this->connect($endpoint, $method,$data);
- //var_dump($data);exit;
+ try{
+ $data = $this->connect($endpoint, $method,$data);
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ $message = $e->getMessage();
+ var_dump($message);
+ //var_dump($e->getServerRawResponse());
+ $message = explode("name (must be one of",$message);
+ $valid_ext = "";
+ if(isset($message[1])){
+ $message = substr($message[1],0,-1);
+
+ $message = explode(",",$message);
+ foreach($message as $m){
+ $m = trim($m);
+ $m = explode("/",$m);
+ if(isset($m[1])){
+ $m = $m[1];
+ if($m == "jpeg"){
+ $vext[] = "jpg";
+ }
+ $vext[] = $m;
+ }
+
+
+ }
+ $valid_ext = ", è possibile caricare esclusivamente file con formato: ".implode(", ",$vext);
+
+ }
+ $ret['success'] = FALSE;
+ $ret['message'] = "C'è stato un errore in fase di caricamento{$valid_ext}";
+ $ret['error'] = $e->getCode();
+ echo json_encode($ret);
+ exit;
+ }catch(\Exception $e){
+ $ret['success'] = FALSE;
+ $ret['message'] = "C'è stato un errore in fase di caricamento inaspettato, riprovare, se il problema persiste contattare la nostra assistenza";
+ echo json_encode($ret);
+ exit;
+ }
header("Content-Type: ",$this->parsedHEader['Content-Type']);
if(isset($this->parsedHEader['Content-Type']) && strtolower($this->parsedHEader['Content-Type']) == "application/json") {
diff --git a/src/classes/VisEngine.php b/src/classes/VisEngine.php
index e67fcd0..f55c496 100644
--- a/src/classes/VisEngine.php
+++ b/src/classes/VisEngine.php
@@ -58,74 +58,56 @@ function createRequest($ttr = 500){
*
* @return object
*/
- function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req, $new_search = FALSE) {
+ function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req) {
-
+
if($req->getNew()){
$params = new \stdClass();
- $params->state = $req->getState();
- $params->test = $req->getTest();
- $params->hash_visura = $this->hash;
- if($req->getJson() != NULL){
- $params->json_visura = $req->getJson();
- }
- if($req->getCallbackData() != NULL){
- $params->callback_data = $req->getCallbackData();
- }
- if($req->getFornitore() != NULL){
- $params->callback = $req->getFornitore();
- }
- if($req->getTargetEmail() != NULL){
- $params->email_target = $req->getTargetEmail();
- }
+ $params->state = $req->getState();
+ $params->test = $req->getTest();
+ $params->hash_visura = $this->hash;
+ if($req->getJson() != NULL){
+ $params->json_visura = $req->getJson();
+ }
+ if($req->getCallbackData() != NULL){
+ $params->callback_data = $req->getCallbackData();
+ }
+ if($req->getTargetEmail() != NULL){
+ $params->email_target = $req->getTargetEmail();
+ }
+ $opzioni = $req->getOpzioni();
+ if($opzioni != NULL){
+ $params->opzioni = $opzioni;
+ }
$data = $this->connect("richiesta", "POST", $params);
- //var_dump($data);exit;
+ //var_dump($data);
$req->setNew(FALSE);
$req->setId($data->data->_id);
$req->setStatoRichiesta($data->data->stato_richiesta);
-
- if(isset($data->data->callback)){
- $req->setFornitore($data->data->callback);
- }else{
- $req->setFornitore(NULL);
- }
if(isset($data->data->ricerche)){
$req->setRicerche($data->data->ricerche);
}
return $req;
}else{
-
+
$params = new \stdClass();
$params->state = $req->getState();
// $params->test = $req->getTest();
- $id_visura = $req->getId();
+
if($req->getJson() != NULL){
$params->json_visura = $req->getJson();
}
-
+ $id_visura = $req->getId();
//echo json_encode($params);exit;
//var_dump($params);exit;
- $visura = $this->connect("richiesta/$id_visura", "GET");
-
- if(!$new_search)
- {
$data = $this->connect("richiesta/$id_visura", "PUT", $params);
- }else{
- $data = $this->connect("richiesta/$id_visura", "POST", $params);
- }
-
- // var_dump($data);exit;
-
-
+
$req->setNew(FALSE);
$req->setId($data->data->_id);
$req->setStatoRichiesta($data->data->stato_richiesta);
- if(isset($data->data->callback)){
- $req->setFornitore($data->data->callback);
- }
if(isset($data->data->ricerche)){
$req->setRicerche($data->data->ricerche);
}
@@ -133,64 +115,38 @@ function sendRequest(\OpenApi\classes\utility\VisEngine\VisRequest $req, $new_se
}
}
- function getDatiFornitore($email){
- $data = $this->connect("fornitori/$email", "GET", []);
- return $data;
- }
-
- function getFornitori(){
- $data = $this->connect("fornitori", "GET", []);
- return $data;
-
- }
-
function getRequestByIdVisura($id_visura){
$visura = $this->connect("richiesta/$id_visura", "GET");
-
- /*if($visura->data->callback){
- var_dump($visura->data->callback);exit;
- }*/
-
return $this->getRequestByData($visura);
}
- function cancelRequest($id_visura, $motivazione){
- $visura = $this->connect("richiesta/$id_visura", "DELETE",["motivo"=>$motivazione]);
- return $this->getRequestByIdVisura($id_visura);
- }
-
-
function getRequestByData($visura){
-
+
+
$this->visura = $this->connect("visure/{$visura->data->hash_visura}", "GET", [], 0);
+
$this->hash = $visura->data->hash_visura;
defined("OPENAPI_CREATING_REQUEST") OR define("OPENAPI_CREATING_REQUEST", TRUE);
$request = new \OpenApi\classes\utility\VisEngine\VisRequest($this->visura);
$request->setNew(FALSE);
$request->setId($visura->data->_id);
$request->setStatoRichiesta($visura->data->stato_richiesta);
+
if(isset($visura->data->ricerche)){
+
$request->setRicerche($visura->data->ricerche);
}else{
$request->setRicerche([]);
}
- if($request->getStatoRichiesta() == "Dati disponibili" || $request->getStatoRichiesta() == "Visura evasa"){
- $documento = $this->connect("documento/{$visura->data->_id}", "GET", [], 0);
- $request->setDocument($documento->data);
- }
- if($visura->data->stato_richiesta == "Annullata"){
- $request->setReasonCancellation($visura->data->motivo_annullamento);
-
- }
- if(isset($visura->data->callback) && $visura->data->callback){
- $request->setFornitore($visura->data->callback);
- }
+ // var_dump($request);exit;
return $request;
}
function getDocument($id_visura){
+ ini_set("memory_limit","1024M");
$request = $this->getRequestByIdVisura($id_visura);
$documento = $this->connect("documento/{$id_visura}", "GET", [], 0);
+ //var_dump($documento);exit;
if($request->getStatoRichiesta() == "Dati disponibili" || $request->getStatoRichiesta() == "Visura evasa"){
$request->setDocument($documento->data);
@@ -211,10 +167,6 @@ function setRicerca($id_visura, $id_ricerca, $index){
}
- function getCatalog($ttr = 86400){
- return $this->connect("visure", "GET", NULL, $ttr);
- }
-
}
diff --git a/src/classes/exception/OpenApiConnectionsException.php b/src/classes/exception/OpenApiConnectionsException.php
index b8ef39f..15b5818 100644
--- a/src/classes/exception/OpenApiConnectionsException.php
+++ b/src/classes/exception/OpenApiConnectionsException.php
@@ -1,17 +1,17 @@
-serverData = NULL;
- $this->serverHeader = NULL;
- $this->serverRawResponse = NULL;
- $this->httpCode = NULL;
- }
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
-
-
- /**
- *
- * Imposta alcune variabili utili in fase di debugging degli errori
- *
- * @param object $serverData Response del server già decodato dalla versione json
- * @param string $serverHeader Stringa contentene gli header della response
- * @param string $serverRawResponse Stringa contente la risposta raw del server
- *
- * @return [type]
- */
- function setServerResponse(object $serverData, string $serverHeader, string $serverRawResponse, $httpCode = NULL){
- $this->serverData = $serverData;
- $this->serverHeader = $serverHeader;
- $this->serverRawResponse = $serverRawResponse;
- $this->httpCode = $httpCode;
- }
-
- /**
- *
- * Restituisce la risposta del server già decodata da json
- *
- * @return object
- */
- function getServerResponse(){
- return $this->serverData;
- }
-
- /**
- *
- * Restituisce gli header della rispopsta del server
- *
- * @return string
- */
- function getServerHeaderResponse(){
- return $this->serverHeader;
- }
-
- /**
- *
- * Restituisce la risposta in formato RAW del server
- * @return string
- */
- function getServerRawResponse(){
- return $this->serverRawResponse;
- }
-
- function getHttpCode(){
- return $this->httpCode;
- }
+serverData = NULL;
+ $this->serverHeader = NULL;
+ $this->serverRawResponse = NULL;
+ $this->httpCode = NULL;
+ }
+ public function __toString() {
+ return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
+ }
+
+
+ /**
+ *
+ * Imposta alcune variabili utili in fase di debugging degli errori
+ *
+ * @param object $serverData Response del server già decodato dalla versione json
+ * @param string $serverHeader Stringa contentene gli header della response
+ * @param string $serverRawResponse Stringa contente la risposta raw del server
+ *
+ * @return [type]
+ */
+ function setServerResponse(object $serverData, string $serverHeader, string $serverRawResponse, $httpCode = NULL){
+ $this->serverData = $serverData;
+ $this->serverHeader = $serverHeader;
+ $this->serverRawResponse = $serverRawResponse;
+ $this->httpCode = $httpCode;
+ }
+
+ /**
+ *
+ * Restituisce la risposta del server già decodata da json
+ *
+ * @return object
+ */
+ function getServerResponse(){
+ return $this->serverData;
+ }
+
+ /**
+ *
+ * Restituisce gli header della rispopsta del server
+ *
+ * @return string
+ */
+ function getServerHeaderResponse(){
+ return $this->serverHeader;
+ }
+
+ /**
+ *
+ * Restituisce la risposta in formato RAW del server
+ * @return string
+ */
+ function getServerRawResponse(){
+ return $this->serverRawResponse;
+ }
+
+ function getHttpCode(){
+ return $this->httpCode;
+ }
}
\ No newline at end of file
diff --git a/src/classes/exception/OpenApiPecMassivaException.php b/src/classes/exception/OpenApiPecMassivaException.php
index 31d9848..7f48b0e 100644
--- a/src/classes/exception/OpenApiPecMassivaException.php
+++ b/src/classes/exception/OpenApiPecMassivaException.php
@@ -1,15 +1,15 @@
-data->province = NULL;
$this->data->country = "Italia";
$this->data->email = NULL;
+ $this->data->id = NULL;
+ $this->data->IdRicevuta = NULL;
+ $this->data->tracking_code = NULL;
$this->itData = new \stdClass();
@@ -38,6 +41,9 @@ function __construct($recipient = NULL){
$this->itData->provincia = NULL;
$this->itData->nazione = "Italia";
$this->itData->email = NULL;
+ $this->itData->id = NULL;
+ $this->itData->IdRicevuta = NULL;
+ $this->itData->tracking_code = NULL;
$this->validate = false;
@@ -67,6 +73,8 @@ public function createFromObject($object){
$this->data->id = isset($object->id)?$object->id:NULL;
$this->data->state = isset($object->state)?$object->state:NULL;
+ $this->data->IdRicevuta = isset($object->IdRicevuta)?$object->IdRicevuta:NULL;
+ $this->data->tracking_code = isset($object->NumeroRaccomandata)?$object->NumeroRaccomandata:NULL;
@@ -86,6 +94,9 @@ public function createFromObject($object){
$this->itData->id= $this->data->id;
$this->itData->state= $this->data->state;
+ $this->itData->IdRicevuta = isset($object->IdRicevuta)?$object->IdRicevuta:NULL;
+ $this->itData->tracking_code = isset($object->NumeroRaccomandata)?$object->NumeroRaccomandata:NULL;
+
}
public function getObject($itNames = FALSE){
@@ -103,6 +114,11 @@ public function getAt(){
return $this->data->at;
}
+ public function getState(){
+ return $this->data->state;
+ }
+
+
public function getFirstName(){
return $this->data->firstName;
}
@@ -138,6 +154,19 @@ public function getEmail(){
return $this->data->email;
}
+ public function getId(){
+ return $this->data->id;
+ }
+ public function getIdRicevuta(){
+ return $this->data->IdRicevuta;
+ }
+
+
+
+ public function getTrackingCode(){
+ return $this->data->tracking_code;
+ }
+
public function setTitle(string $title){
$this->data->title = $title;
$this->itData->titolo = $title;
diff --git a/src/classes/utility/UfficioPostale/Raccomandata.php b/src/classes/utility/UfficioPostale/Raccomandata.php
index 61ffce4..44ccc53 100644
--- a/src/classes/utility/UfficioPostale/Raccomandata.php
+++ b/src/classes/utility/UfficioPostale/Raccomandata.php
@@ -23,6 +23,22 @@ function confirm(){
}
+ function creaRaccomandataByData($data){
+
+
+ $this->pricing = $data->pricing;
+ $this->id = $data->id;
+ $this->confirmed = $data->confirmed;
+ $this->state = $data->state;
+ $this->numero_pagine = $data->documento_validato->pagine;
+ $this->clearRecipients();
+ $this->setRecipients($data->destinatari);
+ $this->setSender($data->mittente);
+ $this->colori = $data->opzioni->colori;
+ $this->fronteretro = $data->opzioni->fronteretro;
+ $this->ar = $data->opzioni->ar;
+ $this->setCallback($data->opzioni->callback_url, $data->opzioni->custom);
+ }
function send(){
$object = new \stdClass();;
@@ -44,13 +60,23 @@ function send(){
}
}
// var_dump($object);exit;
+ if($this->getId() == NULL){
$ret = call_user_func_array($this->connect,["raccomandate/","POST",$object]);
+ }else{
+ $ret = call_user_func_array($this->connect,["raccomandate/".$this->getId(),"PATCH",$object]);
+ }
+
+ if(!isset($ret->data[0])){
+ return false;
+ }
$this->pricing = $ret->data[0]->pricing;
$this->id = $ret->data[0]->id;
$this->confirmed = $ret->data[0]->confirmed;
$this->state = $ret->data[0]->state;
+ $this->numero_pagine = $ret->data[0]->documento_validato->pagine;
$this->clearRecipients();
$this->setRecipients($ret->data[0]->destinatari);
+ return true;
//$ret= $this->connect->call($this,"raccomandate",$object,"POST");
}
diff --git a/src/classes/utility/UfficioPostale/ServiziPostali.php b/src/classes/utility/UfficioPostale/ServiziPostali.php
index 5dfc177..3e0c16b 100644
--- a/src/classes/utility/UfficioPostale/ServiziPostali.php
+++ b/src/classes/utility/UfficioPostale/ServiziPostali.php
@@ -17,6 +17,7 @@ class ServiziPostali {
protected $confirmed;
protected $state;
protected $callback;
+ protected $numero_pagine;
function __construct($connect){
$this->connect = $connect;
@@ -36,6 +37,10 @@ function __construct($connect){
$this->callback = NULL;
}
+ function getNumeroPagine(){
+ return $this->numero_pagine;
+ }
+
function getPricing(){
return $this->pricing;
}
@@ -107,6 +112,10 @@ public function getSenderError(){
return $this->sender->getErrors();
}
+ public function getRecipients(){
+ return $this->recipients;
+ }
+
public function getRecpients(){
return $this->recipients;
}
diff --git a/src/classes/utility/Uploader/Collection.php b/src/classes/utility/Uploader/Collection.php
index 9e903f2..99bc039 100644
--- a/src/classes/utility/Uploader/Collection.php
+++ b/src/classes/utility/Uploader/Collection.php
@@ -38,6 +38,11 @@ function save($state = false){
if($this->getOutputSize() != NULL){
$data['output_size'] = $this->getOutputSize();
}
+ if($this->outputGroup != NULL){
+ $data['output_group'] = $this->outputGroup;
+ }
+
+
if($this->getInputTypes() != NULL){
$data['input_types'] = $this->getInputTypes();
}
@@ -324,4 +329,16 @@ function getDocumento($id_documento){
$this->updateCollection();
return $ret;
}
+
+ function getDocumenti(){
+ if($this->id == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUploaderException("Impossible to add File",40019);
+ }
+
+
+ $ret = call_user_func_array ($this->connect,["collections/$this->id","GET"]);
+
+ $this->updateCollection();
+ return $ret;
+ }
}
\ No newline at end of file
From e728868ba53024d300f12a7e13eae4e36025b7ed Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Wed, 16 Jun 2021 14:20:37 +0200
Subject: [PATCH 21/85] Implementate ultime versioni API
---
src/classes/Pec.php | 31 -------------------------------
1 file changed, 31 deletions(-)
delete mode 100644 src/classes/Pec.php
diff --git a/src/classes/Pec.php b/src/classes/Pec.php
deleted file mode 100644
index f88e565..0000000
--- a/src/classes/Pec.php
+++ /dev/null
@@ -1,31 +0,0 @@
-basePath = "https://pec.openapi.it";
- }
-
- function verify($pec){
- try{
- $data = $this->connect("verifica_pec/$pec", "GET");
- return $data;
- }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
- $res = $e->getServerResponse();
- var_dump($res);
- if(isset($res->message) && strpos($res->message,"not available") !== false){
- return ["success"=>true,"data"=>["available" => false]];
- }
-
- return $res;
- }
-
- }
-
-}
\ No newline at end of file
From 35e81c280712785ba159a4559b70acb1e93b3cf4 Mon Sep 17 00:00:00 2001
From: lorenzo paderi <>
Date: Fri, 18 Jun 2021 13:10:53 +0200
Subject: [PATCH 22/85] aggiunte indicazioni sull'inizializzazione del progetto
---
readme.md | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/readme.md b/readme.md
index c6a0a76..4b8fef9 100644
--- a/readme.md
+++ b/readme.md
@@ -4,19 +4,22 @@
### Instanza della classe
-```
+```php
$this->openapi = new \OpenApi\OpenApi($scopes,$user,$apikey,"test");
```
-Dove ```$scopes``` è un array di stringhe o di oggetti in uno dei seguenti formati:
+Dove `$scopes` è un array di stringhe o di oggetti in uno dei seguenti formati:
```php
$scopes=[
-"GET:ws.ufficiopostale.com/comuni",
-["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
+ "GET:ws.ufficiopostale.com/comuni",
+ ["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
];
```
+...e `$environment` è l'ambiente sceltro tra `'test'` (default) e `'production'`
+```
+
A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
```php
@@ -49,3 +52,4 @@ La funzione consente di recuperare i dati aziendali a partire dalla partita IVA
* $partitaIva: La partita IVA da cercare
* $ttl: Time To Release, per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+
From 1b8cb7137931f189204da109eea365ed5a004526 Mon Sep 17 00:00:00 2001
From: lpaderiAltravia <85158884+lpaderiAltravia@users.noreply.github.com>
Date: Fri, 18 Jun 2021 13:15:09 +0200
Subject: [PATCH 23/85] Update readme.md
---
readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index 4b8fef9..d0b568c 100644
--- a/readme.md
+++ b/readme.md
@@ -18,7 +18,7 @@ $scopes=[
```
...e `$environment` è l'ambiente sceltro tra `'test'` (default) e `'production'`
-```
+
A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
From 9404c5b6d407b3fb24d8d5b7c3189fc77de66319 Mon Sep 17 00:00:00 2001
From: lorenzo paderi <>
Date: Fri, 18 Jun 2021 14:48:49 +0200
Subject: [PATCH 24/85] aggiunta indicazione sull'installazione del paccetto
composer
---
readme.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/readme.md b/readme.md
index 4b8fef9..8dab1aa 100644
--- a/readme.md
+++ b/readme.md
@@ -1,5 +1,11 @@
# OpenAPI Library
+## Installation
+
+```sh
+composer require altravia/openapi
+```
+
## Usage
### Instanza della classe
From 08863982519796ad2f9c920afe64a278a890e5c6 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 18 Jun 2021 17:56:42 +0200
Subject: [PATCH 25/85] aggiunto gitignore
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b44d4eb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+vendor/
+.env
\ No newline at end of file
From 47867f8056cc5b3eab0ab6f6928a6c4cf9060f6b Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 18 Jun 2021 17:57:49 +0200
Subject: [PATCH 26/85] dichiara le variabili di classe per la compatibilita'
con i linters
---
src/OpenApi.php | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/OpenApi.php b/src/OpenApi.php
index 89a6d44..792e947 100644
--- a/src/OpenApi.php
+++ b/src/OpenApi.php
@@ -2,6 +2,15 @@
class OpenApi {
+ public \OpenApi\classes\Imprese $imprese;
+ public \OpenApi\classes\ufficiopostale $ufficiopostale;
+ public \OpenApi\classes\comuni $comuni;
+ public \OpenApi\classes\visengine $visengine;
+ public \OpenApi\classes\marcheTemporali $marcheTemporali;
+ public \OpenApi\classes\geocoding $geocoding;
+ public \OpenApi\classes\SMS $SMS;
+ public \OpenApi\classes\firmaDigitale $firmaDigitale;
+ public \OpenApi\classes\pecMassiva $pecMassiva;
/**
* @param array $scopes Array con gli scopes da utilizzare nel formato: ["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"] oppure "GET:ws.ufficiopostale.com/comuni NOTA: il dominio NON deve mai avere lo stage
From 3b347f775a10b2df34933ac6701b3d3bb8e58d60 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 18 Jun 2021 18:14:35 +0200
Subject: [PATCH 27/85] aggiunti esempi di codice
---
readme.md | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/readme.md b/readme.md
index 4911d52..e1035c0 100644
--- a/readme.md
+++ b/readme.md
@@ -11,34 +11,67 @@ composer require altravia/openapi
### Instanza della classe
```php
- $this->openapi = new \OpenApi\OpenApi($scopes,$user,$apikey,"test");
+require_once 'vendor/autoload.php';
+
+$openapi = new \OpenApi\OpenApi($scopes, $user, $apikey, $environment);
```
Dove `$scopes` è un array di stringhe o di oggetti in uno dei seguenti formati:
```php
-$scopes=[
+$scopes = [
"GET:ws.ufficiopostale.com/comuni",
- ["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
+ [
+ "domain"=>"ws.ufficiopostale.com",
+ "method"=>"comuni",
+ "mode" =>"GET"
+ ]
];
```
...e `$environment` è l'ambiente sceltro tra `'test'` (default) e `'production'`
+OpenApi si occuperá di reperire automaticamente, o generare, un nuovo token quando necessario.
+
+A questo punto, in base agli scopes indicati vengono creati i seguenti oggetti:
-A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
```php
-$this->openapi->ufficiopostale
-$this->openapi->imprese
-...
+// Ogni oggetto verrá creato solo se disponibile nello scope.
+$openapi->ufficiopostale
+$openapi->comuni
+$openapi->imprese
+$openapi->visengine
+$openapi->marcheTemporali
+$openapi->geocoding
+$openapi->SMS
+$openapi->firmaDigitale
+$openapi->pecMassiva
```
-
che possono essere usati al seguente modo:
```php
$this->openapi->ufficioposale->getCitiesByCap('00132');
```
+### Esempi
+
+```php
+require_once 'vendor/autoload.php';
+
+// Dichiaro gli scopes necessari
+$scopes = [
+ 'GET:comuni.openapi.it/cap',
+ 'GET:imprese.altravia.com/advance',
+];
+
+$openapi = new OpenApi\OpenApi($scopes, 'my_username','my_api_key', 'production');
+
+// Prendi informazioni sul cap 00132
+$cap = $openapi->comuni->getCitiesByCap('00132');
+
+// Prendi informazioni su una specifica impresa
+$impresa = $openapi->imprese->getByPartitaIva('12485671007');
+```
# Modulo ufficio postale
From 49d25710ddb064b0b41c8094c3b7cc31e862acdb Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 18 Jun 2021 18:14:48 +0200
Subject: [PATCH 28/85] creata cartella di test
---
tests/example_test.php | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 tests/example_test.php
diff --git a/tests/example_test.php b/tests/example_test.php
new file mode 100644
index 0000000..9eeab7b
--- /dev/null
+++ b/tests/example_test.php
@@ -0,0 +1,38 @@
+load(__DIR__.'/../.env');
+
+$username = $_ENV['OPENAPI_USERNAME'];
+$api_key = $_ENV['API_KEY'];
+
+// Dichiaro gli scopes necessari
+$scopes = [
+ "GET:ws.ufficiopostale.com/telegrammi",
+ "GET:imprese.altravia.com/autocomplete",
+ "GET:imprese.openapi.it/base",
+ "GET:imprese.openapi.it/advance",
+ "GET:imprese.openapi.it/pec",
+ "GET:imprese.openapi.it/autocomplete",
+ "GET:imprese.openapi.it/closed",
+ "GET:imprese.openapi.it/gruppoiva",
+ "GET:comuni.openapi.it/cap",
+ "GET:comuni.openapi.it/istat",
+ "GET:comuni.openapi.it/regioni",
+ "GET:comuni.openapi.it/province",
+];
+
+$openapi = new OpenApi\OpenApi($scopes, $username, $api_key, 'test');
+
+// Prendi informazioni sul cap 00132
+$cap = $openapi->comuni->getCitiesByCap('00132');
+var_dump($cap);
+
+// Prendi informazioni su una specifica impresa
+$impresa = $openapi->imprese->getByPartitaIva('12485671007');
+var_dump($impresa);
+
+$cerca_impresa = $openapi->imprese->getBySearch('Altravia', 'RM');
+var_dump($cerca_impresa);
From 6fcf03850adc8bfe53722b29fd0419dde4086258 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 18 Jun 2021 18:18:52 +0200
Subject: [PATCH 29/85] aggiunto modulo dotenv per i test
---
.gitignore | 3 ++-
composer.json | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index b44d4eb..42c2c31 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
vendor/
-.env
\ No newline at end of file
+.env
+composer.lock
diff --git a/composer.json b/composer.json
index 51fc60f..d85d2ee 100644
--- a/composer.json
+++ b/composer.json
@@ -15,5 +15,8 @@
"psr-4": {
"OpenApi\\": "src"
}
+ },
+ "require-dev": {
+ "symfony/dotenv": "^5.3"
}
}
From 436ce27f193711209669e586e61da69814357c07 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Mon, 21 Jun 2021 10:03:48 +0200
Subject: [PATCH 30/85] usa phpunit per i test
---
composer.json | 3 ++-
tests/ClientTest.php | 61 ++++++++++++++++++++++++++++++++++++++++++
tests/example_test.php | 38 --------------------------
3 files changed, 63 insertions(+), 39 deletions(-)
create mode 100644 tests/ClientTest.php
delete mode 100644 tests/example_test.php
diff --git a/composer.json b/composer.json
index d85d2ee..6f87738 100644
--- a/composer.json
+++ b/composer.json
@@ -17,6 +17,7 @@
}
},
"require-dev": {
- "symfony/dotenv": "^5.3"
+ "symfony/dotenv": "^5.3",
+ "phpunit/phpunit": "^9.5"
}
}
diff --git a/tests/ClientTest.php b/tests/ClientTest.php
new file mode 100644
index 0000000..e87de6c
--- /dev/null
+++ b/tests/ClientTest.php
@@ -0,0 +1,61 @@
+dotenv = new Dotenv();
+ $this->dotenv->load(__DIR__.'/../.env');
+
+ $this->username = $_ENV['OPENAPI_USERNAME'];
+ $this->api_key = $_ENV['API_KEY'];
+
+ // Dichiaro gli scopes necessari
+ $this->scopes = [
+ "GET:ws.ufficiopostale.com/telegrammi",
+ "GET:imprese.altravia.com/autocomplete",
+ "GET:imprese.openapi.it/base",
+ "GET:imprese.openapi.it/advance",
+ "GET:imprese.openapi.it/pec",
+ "GET:imprese.openapi.it/autocomplete",
+ "GET:imprese.openapi.it/closed",
+ "GET:imprese.openapi.it/gruppoiva",
+ "GET:comuni.openapi.it/cap",
+ "GET:comuni.openapi.it/istat",
+ "GET:comuni.openapi.it/regioni",
+ "GET:comuni.openapi.it/province",
+ "POST:geocoding.realgest.it/geocode"
+ ];
+
+ $this->openapi = new OpenApi($this->scopes, $this->username, $this->api_key, 'test');
+ }
+
+
+ public function testClientInstance() {
+ $this->assertInstanceOf('OpenApi\OpenApi', $this->openapi);
+ }
+
+ public function testComuni() {
+ // Prendi informazioni sul cap 00132
+ $cap = $this->openapi->comuni->getCitiesByCap('00132');
+ $this->assertIsArray($cap);
+ }
+
+ public function testGeocoding() {
+ // Prendi informazioni sul cap 00132
+ $cap = $this->openapi->geocoding->geocode('Via Cristoforo Colombo, Roma RM');
+ $this->assertIsArray($cap);
+ }
+}
\ No newline at end of file
diff --git a/tests/example_test.php b/tests/example_test.php
deleted file mode 100644
index 9eeab7b..0000000
--- a/tests/example_test.php
+++ /dev/null
@@ -1,38 +0,0 @@
-load(__DIR__.'/../.env');
-
-$username = $_ENV['OPENAPI_USERNAME'];
-$api_key = $_ENV['API_KEY'];
-
-// Dichiaro gli scopes necessari
-$scopes = [
- "GET:ws.ufficiopostale.com/telegrammi",
- "GET:imprese.altravia.com/autocomplete",
- "GET:imprese.openapi.it/base",
- "GET:imprese.openapi.it/advance",
- "GET:imprese.openapi.it/pec",
- "GET:imprese.openapi.it/autocomplete",
- "GET:imprese.openapi.it/closed",
- "GET:imprese.openapi.it/gruppoiva",
- "GET:comuni.openapi.it/cap",
- "GET:comuni.openapi.it/istat",
- "GET:comuni.openapi.it/regioni",
- "GET:comuni.openapi.it/province",
-];
-
-$openapi = new OpenApi\OpenApi($scopes, $username, $api_key, 'test');
-
-// Prendi informazioni sul cap 00132
-$cap = $openapi->comuni->getCitiesByCap('00132');
-var_dump($cap);
-
-// Prendi informazioni su una specifica impresa
-$impresa = $openapi->imprese->getByPartitaIva('12485671007');
-var_dump($impresa);
-
-$cerca_impresa = $openapi->imprese->getBySearch('Altravia', 'RM');
-var_dump($cerca_impresa);
From fff010b0d22f7223e001ad12c310e3e583fdd791 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Mon, 21 Jun 2021 10:04:30 +0200
Subject: [PATCH 31/85] migliorato readme
---
readme.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/readme.md b/readme.md
index e1035c0..6effeab 100644
--- a/readme.md
+++ b/readme.md
@@ -66,10 +66,10 @@ $scopes = [
$openapi = new OpenApi\OpenApi($scopes, 'my_username','my_api_key', 'production');
-// Prendi informazioni sul cap 00132
+// Comuni: prendi informazioni sul cap 00132
$cap = $openapi->comuni->getCitiesByCap('00132');
-// Prendi informazioni su una specifica impresa
+// Imprese: prendi informazioni su una specifica impresa
$impresa = $openapi->imprese->getByPartitaIva('12485671007');
```
From 55f86042888da713eda10395cbf1e0372d72f278 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Mon, 21 Jun 2021 10:50:35 +0200
Subject: [PATCH 32/85] aggiunto test per ufficio postale
---
readme.md | 5 +++++
src/classes/UfficioPostale.php | 2 +-
tests/ClientTest.php | 38 ++++++++++++++++++++++++++++++----
3 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/readme.md b/readme.md
index 6effeab..0e333ba 100644
--- a/readme.md
+++ b/readme.md
@@ -71,9 +71,14 @@ $cap = $openapi->comuni->getCitiesByCap('00132');
// Imprese: prendi informazioni su una specifica impresa
$impresa = $openapi->imprese->getByPartitaIva('12485671007');
+
+// Ufficio Postale: ottieni informaizoni sul tracking
+$track = $this->openapi->ufficiopostale->track('123456789');
```
# Modulo ufficio postale
+## Creare raccomandata
+
# Modulo visure
diff --git a/src/classes/UfficioPostale.php b/src/classes/UfficioPostale.php
index 6ff1dec..530eae4 100644
--- a/src/classes/UfficioPostale.php
+++ b/src/classes/UfficioPostale.php
@@ -17,7 +17,7 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
* Restiuisce un oggetto di tipo raccomandata
* @return object
*/
- function createRaccomandata(){
+ function createRaccomandata() {
return new \OpenApi\classes\utility\UfficioPostale\Raccomandata(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
diff --git a/tests/ClientTest.php b/tests/ClientTest.php
index e87de6c..c7ecb2c 100644
--- a/tests/ClientTest.php
+++ b/tests/ClientTest.php
@@ -1,5 +1,7 @@
assertIsArray($cap);
}
- public function testGeocoding() {
- // Prendi informazioni sul cap 00132
- $cap = $this->openapi->geocoding->geocode('Via Cristoforo Colombo, Roma RM');
- $this->assertIsArray($cap);
+ // public function testGeocoding() {
+ // // Prendi informazioni sul cap 00132
+ // $cap = $this->openapi->geocoding->geocode('Via Cristoforo Colombo, Roma RM');
+ // $this->assertIsArray($cap);
+ // }
+
+ public function testUfficioPostale() {
+ $track = $this->openapi->ufficiopostale->track($_ENV['TRACK_TEST']);
+ $this->assertEquals(true, $track->success);
+ var_dump($track);
+
+ $raccomandata = $this->openapi->ufficiopostale->createRaccomandata();
+ var_dump($raccomandata);
+
+ $data = new stdClass();
+ $sender = new Sender([
+ 'firstName' => 'John',
+ 'secondName' => 'Doe',
+ 'companyName' => 'example-spa',
+ ]);
+
+ $recipient = new Recipient([
+ 'firstName' => 'John',
+ 'secondName' => 'Doe',
+ 'companyName' => 'example-spa',
+ ]);
+
+ $data->sender = $sender;
+ $data->recipient = $recipient;
+
+ $raccomandata->creaRaccomandataByData();
}
}
\ No newline at end of file
From 9b2a47ce894c995eb6fc7132fffb4f9db3adab76 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Mon, 21 Jun 2021 11:16:02 +0200
Subject: [PATCH 33/85] aggiunte infomrazioni sull'utilizzo di imprese
---
readme.md | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/readme.md b/readme.md
index 0e333ba..bebad29 100644
--- a/readme.md
+++ b/readme.md
@@ -83,17 +83,13 @@ $track = $this->openapi->ufficiopostale->track('123456789');
# Modulo visure
# Modulo imprese
-
-## `getByPartitaIva`
-
-### Introduction
-
-La funzione consente di recuperare i dati aziendali a partire dalla partita IVA
-
-### Description
-
-`function getByPartitaIva(string $partitaIva, $ttl = 86400):object`
-
-* $partitaIva: La partita IVA da cercare
-* $ttl: Time To Release, per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+## Utilizzo
+Il modulo imprese espone i seguenti metodi:
+* `getByPartitaIva`
+* `getClosed`
+* `getVatGroup`
+* `getPec`
+* `getBySearch`
+
+Per `getBySearch` e `getByPartitaIva` è richiesto accesso allo scope `/advance`
From aed9cd1fe4eb26e89237a0408f53f0481c4f77f6 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Mon, 21 Jun 2021 16:33:46 +0200
Subject: [PATCH 34/85] aggiunti esempi e test per modulo SMS e firma digitale
---
readme.md | 41 ++++++++++++-------
tests/ClientTest.php | 97 +++++++++++++++++++++++++++++---------------
2 files changed, 91 insertions(+), 47 deletions(-)
diff --git a/readme.md b/readme.md
index bebad29..3394ff4 100644
--- a/readme.md
+++ b/readme.md
@@ -38,15 +38,15 @@ A questo punto, in base agli scopes indicati vengono creati i seguenti oggetti:
```php
// Ogni oggetto verrá creato solo se disponibile nello scope.
-$openapi->ufficiopostale
-$openapi->comuni
-$openapi->imprese
-$openapi->visengine
-$openapi->marcheTemporali
-$openapi->geocoding
-$openapi->SMS
-$openapi->firmaDigitale
-$openapi->pecMassiva
+$openapi->ufficiopostale;
+$openapi->comuni;
+$openapi->imprese;
+$openapi->visengine;
+$openapi->marcheTemporali;
+$openapi->geocoding;
+$openapi->SMS;
+$openapi->firmaDigitale;
+$openapi->pecMassiva;
```
che possono essere usati al seguente modo:
@@ -64,7 +64,7 @@ $scopes = [
'GET:imprese.altravia.com/advance',
];
-$openapi = new OpenApi\OpenApi($scopes, 'my_username','my_api_key', 'production');
+$openapi = new OpenApi\OpenApi($scopes, 'my_username','my_api_key', 'test');
// Comuni: prendi informazioni sul cap 00132
$cap = $openapi->comuni->getCitiesByCap('00132');
@@ -76,14 +76,24 @@ $impresa = $openapi->imprese->getByPartitaIva('12485671007');
$track = $this->openapi->ufficiopostale->track('123456789');
```
-# Modulo ufficio postale
-## Creare raccomandata
+## Modulo ufficio postale
+### Creare raccomandata
-# Modulo visure
+## Modulo visure
+### Utilizzo
+Il modulo espone i seguenti metodi:
+* `sendRequest`
+* `getRequestByIdVisura`
+* `getRequestByData`
+* `getDocument`
+* `setRicerca`
-# Modulo imprese
-## Utilizzo
+### `sendRequest($VisRequest)`
+
+
+## Modulo imprese
+### Utilizzo
Il modulo imprese espone i seguenti metodi:
* `getByPartitaIva`
* `getClosed`
@@ -93,3 +103,4 @@ Il modulo imprese espone i seguenti metodi:
Per `getBySearch` e `getByPartitaIva` è richiesto accesso allo scope `/advance`
+## Modulo SMS
diff --git a/tests/ClientTest.php b/tests/ClientTest.php
index c7ecb2c..1f678c1 100644
--- a/tests/ClientTest.php
+++ b/tests/ClientTest.php
@@ -2,6 +2,7 @@
use OpenApi\classes\utility\UfficioPostale\Objects\Recipient;
use OpenApi\classes\utility\UfficioPostale\Objects\Sender;
+use OpenApi\classes\utility\VisEngine\VisRequest;
use OpenApi\OpenApi;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Dotenv\Dotenv;
@@ -26,20 +27,25 @@ public function __construct() {
// Dichiaro gli scopes necessari
$this->scopes = [
- "GET:ws.ufficiopostale.com/telegrammi",
+ "GET:ws.ufficiopostale.com/raccomandate",
"GET:imprese.altravia.com/autocomplete",
- "GET:imprese.openapi.it/base",
- "GET:imprese.openapi.it/advance",
- "GET:imprese.openapi.it/pec",
- "GET:imprese.openapi.it/autocomplete",
- "GET:imprese.openapi.it/closed",
- "GET:imprese.openapi.it/gruppoiva",
+ "GET:imprese.altravia.com/base",
+ "GET:imprese.altravia.com/advance",
+ "GET:imprese.altravia.com/pec",
+ "GET:imprese.altravia.com/autocomplete",
+ "GET:imprese.altravia.com/closed",
+ "GET:imprese.altravia.com/gruppoiva",
"GET:comuni.openapi.it/cap",
"GET:comuni.openapi.it/istat",
"GET:comuni.openapi.it/regioni",
"GET:comuni.openapi.it/province",
"GET:ws.ufficiopostale.com/tracking",
- "POST:geocoding.realgest.it/geocode"
+ "POST:geocoding.realgest.it/geocode",
+ "POST:ws.messaggisms.com/messages",
+ "GET:ws.messaggisms.com/messages",
+ "PUT:ws.messaggisms.com/messages",
+ "GET:ws.firmadigitale.com/richiesta",
+ "POST:ws.firmadigitale.com/richiesta",
];
$this->openapi = new OpenApi($this->scopes, $this->username, $this->api_key, 'test');
@@ -56,36 +62,63 @@ public function testComuni() {
$this->assertIsArray($cap);
}
+ // public function testImprese() {
+ // $impresa = $this->openapi->imprese->getByPartitaIva('00966950230');
+ // $autocomplete = $this->openapi->imprese->getBySearch('*multiservizi*', 'RM');
+ // $this->assertEquals($impresa->provincia, 'RM');
+ // $this->assertIsArray($autocomplete);
+ // }
+
// public function testGeocoding() {
// // Prendi informazioni sul cap 00132
// $cap = $this->openapi->geocoding->geocode('Via Cristoforo Colombo, Roma RM');
// $this->assertIsArray($cap);
// }
- public function testUfficioPostale() {
- $track = $this->openapi->ufficiopostale->track($_ENV['TRACK_TEST']);
- $this->assertEquals(true, $track->success);
- var_dump($track);
-
- $raccomandata = $this->openapi->ufficiopostale->createRaccomandata();
- var_dump($raccomandata);
-
- $data = new stdClass();
- $sender = new Sender([
- 'firstName' => 'John',
- 'secondName' => 'Doe',
- 'companyName' => 'example-spa',
- ]);
-
- $recipient = new Recipient([
- 'firstName' => 'John',
- 'secondName' => 'Doe',
- 'companyName' => 'example-spa',
- ]);
-
- $data->sender = $sender;
- $data->recipient = $recipient;
+ // public function testUfficioPostale() {
+ // $track = $this->openapi->ufficiopostale->track($_ENV['TRACK_TEST']);
+ // $this->assertEquals(true, $track->success);
+ // var_dump($track);
+
+ // $raccomandata = $this->openapi->ufficiopostale->createRaccomandata();
+ // var_dump($raccomandata);
+
+ // $data = new stdClass();
+ // $sender = new Sender([
+ // 'firstName' => 'John',
+ // 'secondName' => 'Doe',
+ // 'companyName' => 'example-spa',
+ // ]);
+
+ // $recipient = new Recipient([
+ // 'firstName' => 'John',
+ // 'secondName' => 'Doe',
+ // 'companyName' => 'example-spa',
+ // ]);
+
+ // $data->sender = $sender;
+ // $data->recipient = $recipient;
- $raccomandata->creaRaccomandataByData();
+ // $raccomandata->creaRaccomandataByData($data);
+ // }
+
+ // public function testSms() {
+ // $singleSms = $this->openapi->SMS->sendOne('prova', '3939989741', 'messaggio di prova', null, 1, null, true);
+ // $this->assertIsArray($singleSms);
+ // var_dump($singleSms);
+ // }
+
+ // public function testVisura() {
+ // // $visura = new VisRequest('eccbc87e4b5ce2fe28308fd9f2a7baf3');
+ // $response = $this->openapi->visengine->getRequestByIdVisura('eccbc87e4b5ce2fe28308fd9f2a7baf3');
+ // $this->assertNotEmpty($response);
+ // var_dump($response);
+ // }
+
+ public function testFirmaDigitale() {
+ $data = json_decode(file_get_contents(__DIR__.'/esempio_firma.json'), true);
+ $data['codice_prodotto'] = 'FIR';
+ $response = $this->openapi->firmaDigitale->requestProduct($data);
+ $this->assertNotEmpty($response);
}
}
\ No newline at end of file
From 886d9cecc6b9ae443b2ca808cb2cb24bf4199b12 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Tue, 22 Jun 2021 10:16:25 +0200
Subject: [PATCH 35/85] fix nome dell'endpoint
---
src/classes/Imprese.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/classes/Imprese.php b/src/classes/Imprese.php
index c4fa12f..172dd38 100644
--- a/src/classes/Imprese.php
+++ b/src/classes/Imprese.php
@@ -60,7 +60,7 @@ function getClosed(string $partitaIva, $ttr = 86400){
function getVatGroup(string $partitaIva, $ttr = 86400){
$partitaIva = trim($partitaIva);
try{
- $data = $this->connect("gruppoIva/$partitaIva", "GET", [], $ttr);
+ $data = $this->connect("gruppoiva/$partitaIva", "GET", [], $ttr);
return $data->data;
}catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
From 33a12d9a77438c55b603fad86cc534a689071da6 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Tue, 22 Jun 2021 10:17:01 +0200
Subject: [PATCH 36/85] specificato il ritorno della funzione per creare
raccomandate
---
src/classes/UfficioPostale.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/classes/UfficioPostale.php b/src/classes/UfficioPostale.php
index 530eae4..4d53656 100644
--- a/src/classes/UfficioPostale.php
+++ b/src/classes/UfficioPostale.php
@@ -15,7 +15,7 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
/**
* Restiuisce un oggetto di tipo raccomandata
- * @return object
+ * @return \OpenApi\classes\utility\UfficioPostale\Raccomandata
*/
function createRaccomandata() {
return new \OpenApi\classes\utility\UfficioPostale\Raccomandata(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
From 5ec404c3692fe798f65574f4a88f76143f55bd94 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Tue, 22 Jun 2021 10:18:07 +0200
Subject: [PATCH 37/85] aggiunti test per comuni ed imprese
---
tests/ClientTest.php | 51 ++++++++++++++++++++++++++++++--------------
1 file changed, 35 insertions(+), 16 deletions(-)
diff --git a/tests/ClientTest.php b/tests/ClientTest.php
index 1f678c1..d014b0e 100644
--- a/tests/ClientTest.php
+++ b/tests/ClientTest.php
@@ -39,6 +39,7 @@ public function __construct() {
"GET:comuni.openapi.it/istat",
"GET:comuni.openapi.it/regioni",
"GET:comuni.openapi.it/province",
+ "GET:comuni.openapi.it/catastale",
"GET:ws.ufficiopostale.com/tracking",
"POST:geocoding.realgest.it/geocode",
"POST:ws.messaggisms.com/messages",
@@ -56,19 +57,37 @@ public function testClientInstance() {
$this->assertInstanceOf('OpenApi\OpenApi', $this->openapi);
}
- public function testComuni() {
- // Prendi informazioni sul cap 00132
- $cap = $this->openapi->comuni->getCitiesByCap('00132');
- $this->assertIsArray($cap);
- }
+ // public function testComuni() {
+ // // Prendi informazioni sul cap 00132
+ // $cap = $this->openapi->comuni->getCitiesByCap('00132');
+ // $comune = $this->openapi->comuni->getComuneByCatasto('117');
+ // $comuni = $this->openapi->comuni->getComuni('RM');
+ // $regioni = $this->openapi->comuni->getRegioni();
+ // $provincie = $this->openapi->comuni->getProvince();
+
+ // $this->assertIsArray($cap);
+ // $this->assertIsArray($comune);
+ // $this->assertIsArray($comuni);
+ // $this->assertIsArray($regioni);
+ // $this->assertIsArray($provincie);
- // public function testImprese() {
- // $impresa = $this->openapi->imprese->getByPartitaIva('00966950230');
- // $autocomplete = $this->openapi->imprese->getBySearch('*multiservizi*', 'RM');
- // $this->assertEquals($impresa->provincia, 'RM');
- // $this->assertIsArray($autocomplete);
+ // var_dump($comuni[0]->nome);
// }
+ public function testImprese() {
+ $impresa = $this->openapi->imprese->getByPartitaIva('00966950230');
+ $autocomplete = $this->openapi->imprese->getBySearch('*multiservizi*', 'RM');
+ $closed = $this->openapi->imprese->getClosed('00966950230');
+ $vat = $this->openapi->imprese->getVatGroup('00966950230');
+ $Pec = $this->openapi->imprese->getPec('00966950230');
+
+ $this->assertEquals($impresa->provincia, 'RM');
+ $this->assertIsArray($autocomplete);
+ $this->assertIsBool($closed->cessata);
+ $this->assertIsObject($vat);
+ $this->assertIsObject($Pec);
+ }
+
// public function testGeocoding() {
// // Prendi informazioni sul cap 00132
// $cap = $this->openapi->geocoding->geocode('Via Cristoforo Colombo, Roma RM');
@@ -115,10 +134,10 @@ public function testComuni() {
// var_dump($response);
// }
- public function testFirmaDigitale() {
- $data = json_decode(file_get_contents(__DIR__.'/esempio_firma.json'), true);
- $data['codice_prodotto'] = 'FIR';
- $response = $this->openapi->firmaDigitale->requestProduct($data);
- $this->assertNotEmpty($response);
- }
+ // public function testFirmaDigitale() {
+ // $data = json_decode(file_get_contents(__DIR__.'/esempio_firma.json'), true);
+ // $data['codice_prodotto'] = 'FIR';
+ // $response = $this->openapi->firmaDigitale->requestProduct($data);
+ // $this->assertNotEmpty($response);
+ // }
}
\ No newline at end of file
From 2a4dada7d2926414d92ffd11a2a85ad5d9d00df9 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Tue, 22 Jun 2021 10:47:46 +0200
Subject: [PATCH 38/85] aggiunti ritorni di funzioni
---
src/classes/Imprese.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/classes/Imprese.php b/src/classes/Imprese.php
index 172dd38..9076cf9 100644
--- a/src/classes/Imprese.php
+++ b/src/classes/Imprese.php
@@ -40,7 +40,7 @@ function getByPartitaIva(string $partitaIva, $ttr = 86400, $force = false){
}
- function getClosed(string $partitaIva, $ttr = 86400){
+ function getClosed(string $partitaIva, $ttr = 86400): object{
$partitaIva = trim($partitaIva);
try{
$data = $this->connect("closed/$partitaIva", "GET", [], $ttr);
@@ -57,7 +57,7 @@ function getClosed(string $partitaIva, $ttr = 86400){
}
}
- function getVatGroup(string $partitaIva, $ttr = 86400){
+ function getVatGroup(string $partitaIva, $ttr = 86400): object {
$partitaIva = trim($partitaIva);
try{
$data = $this->connect("gruppoiva/$partitaIva", "GET", [], $ttr);
@@ -74,7 +74,7 @@ function getVatGroup(string $partitaIva, $ttr = 86400){
}
}
- function getPec(string $partitaIva, $ttr = 86400){
+ function getPec(string $partitaIva, $ttr = 86400): object {
$partitaIva = trim($partitaIva);
try{
$data = $this->connect("pec/$partitaIva", "GET", [], $ttr);
From 3bc7fc1ca527551cf859f089e0ce18105f49a9c2 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Tue, 22 Jun 2021 10:48:03 +0200
Subject: [PATCH 39/85] aggiunti test ed esempi per il modulo Marche Temporali
---
readme.md | 87 +++++++++++++++++++++++++++++++++++++++++---
tests/ClientTest.php | 38 +++++++++++++------
2 files changed, 108 insertions(+), 17 deletions(-)
diff --git a/readme.md b/readme.md
index 3394ff4..e1ebeaf 100644
--- a/readme.md
+++ b/readme.md
@@ -76,11 +76,44 @@ $impresa = $openapi->imprese->getByPartitaIva('12485671007');
$track = $this->openapi->ufficiopostale->track('123456789');
```
-## Modulo ufficio postale
-### Creare raccomandata
+
+## Modulo comuni
+Consente di prendere informazioni su comuni e provincie.
-## Modulo visure
+* `getCitiesByCap`
+* `getComuneByCatasto`
+* `getRegioni`
+* `getProvince`
+* `getComuni`
+
+### Esempi
+
+```php
+$provincia = 'RM';
+$comuni = $this->openapi->comuni->getComuni($provincia);
+
+var_dump($comuni['comuni']);
+/*
+
+["nome_provincia"]=>
+ string(4) "Roma"
+ ["sigla_provincia"]=>
+ string(2) "RM"
+ ["regione"]=>
+ string(5) "Lazio"
+ ["comuni"]=>
+ array(121) {
+ [0]=>
+ string(6) "Affile"
+ ...
+*/
+
+
+```
+
+
## Modulo imprese
@@ -103,4 +136,48 @@ Il modulo imprese espone i seguenti metodi:
Per `getBySearch` e `getByPartitaIva` è richiesto accesso allo scope `/advance`
-## Modulo SMS
+### Esempi
+Utilizziamo `getBySearch` per cercare un'azienda il cui nome inizia con `Altrav` a Roma
+
+```php
+$autocomplete = $this->openapi->imprese->getBySearch('Altrav*', 'RM');
+
+/*
+ [0]=>
+ object(stdClass)#41 (10) {
+ ["piva"]=>
+ string(11) "12485671007"
+ ["cf"]=>
+ string(11) "12485671007"
+ ["denominazione"]=>
+ string(20) "ALTRAVIA SERVIZI SRL"
+ [1]=>
+ object(stdClass)#42 (10) {
+ ["id"]=>
+ string(24) "4242424242"
+ ["denominazione"]=>
+ string(18) "xxx Altravia Esempio 2"
+ ...
+ */
+```
+
+## Modulo Marche Temporali
+* `availability`
+* `checkLotto`
+* `purcahse`
+
+### Esempi
+
+```php
+// Controlliamo la disponibilitá di una marca di inforcert o aruba
+$disponibilita = $this->openapi->marcheTemporali->availability('infocert', 1);
+
+// Se le marche sono disponibili, acquistiamone una
+if ($disponibilita->availability > 0) {
+ try {
+ $marca = $this->openapi->marcheTemporali->purcahse('infocert', 1);
+ } catch (\OpenApi\classes\exception\OpenApiMarcheTemporaliException $e) {
+ error_log(var_dump($e));
+ }
+}
+```
\ No newline at end of file
diff --git a/tests/ClientTest.php b/tests/ClientTest.php
index d014b0e..9bd2d47 100644
--- a/tests/ClientTest.php
+++ b/tests/ClientTest.php
@@ -47,6 +47,12 @@ public function __construct() {
"PUT:ws.messaggisms.com/messages",
"GET:ws.firmadigitale.com/richiesta",
"POST:ws.firmadigitale.com/richiesta",
+ "GET:ws.marchetemporali.com/availability",
+ "GET:ws.marchetemporali.com/marche",
+ "POST:ws.marchetemporali.com/check_lotto",
+ "POST:ws.marchetemporali.com/marca",
+ "POST:ws.marchetemporali.com/verifica",
+ "POST:ws.marchetemporali.com/analisi",
];
$this->openapi = new OpenApi($this->scopes, $this->username, $this->api_key, 'test');
@@ -74,18 +80,26 @@ public function testClientInstance() {
// var_dump($comuni[0]->nome);
// }
- public function testImprese() {
- $impresa = $this->openapi->imprese->getByPartitaIva('00966950230');
- $autocomplete = $this->openapi->imprese->getBySearch('*multiservizi*', 'RM');
- $closed = $this->openapi->imprese->getClosed('00966950230');
- $vat = $this->openapi->imprese->getVatGroup('00966950230');
- $Pec = $this->openapi->imprese->getPec('00966950230');
-
- $this->assertEquals($impresa->provincia, 'RM');
- $this->assertIsArray($autocomplete);
- $this->assertIsBool($closed->cessata);
- $this->assertIsObject($vat);
- $this->assertIsObject($Pec);
+ // public function testImprese() {
+ // $impresa = $this->openapi->imprese->getByPartitaIva('00966950230');
+ // $autocomplete = $this->openapi->imprese->getBySearch('Altrav*', 'RM');
+ // $closed = $this->openapi->imprese->getClosed('00966950230');
+ // $vat = $this->openapi->imprese->getVatGroup('00966950230');
+ // $Pec = $this->openapi->imprese->getPec('00966950230');
+
+ // $this->assertEquals($impresa->provincia, 'RM');
+ // $this->assertIsArray($autocomplete);
+ // var_dump($autocomplete);
+ // $this->assertIsBool($closed->cessata);
+ // $this->assertIsObject($vat);
+ // $this->assertIsObject($Pec);
+ // }
+
+ public function testMarche() {
+ $marca = $this->openapi->marcheTemporali->availability('infocert', 1);
+ $comprata = $this->openapi->marcheTemporali->purcahse('infocert', 1);
+
+ $this->assertIsInt($marca->availability);
}
// public function testGeocoding() {
From 00828db5be275e643bcb6ac00338c6f8988a432d Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Wed, 23 Jun 2021 16:32:09 +0200
Subject: [PATCH 40/85] aggiunti test ed esempi per il modulo SMS
---
readme.md | 41 +++++++++++++++++++++++++++++++++++++++++
tests/ClientTest.php | 31 ++++++++++++++++++++-----------
2 files changed, 61 insertions(+), 11 deletions(-)
diff --git a/readme.md b/readme.md
index e1ebeaf..b68db00 100644
--- a/readme.md
+++ b/readme.md
@@ -180,4 +180,45 @@ if ($disponibilita->availability > 0) {
error_log(var_dump($e));
}
}
+```
+
+## Modulo SMS
+* `getRecipients`
+* `getMessage`
+* `sendMore`
+* `sendOne`
+
+### Inviare un SMS
+Per inviare un SMS, per prima cosa definiamo i destinatari:
+
+```php
+$recipient = '+39-3939989741';
+// OR
+$recipients = [
+ [
+ 'number' => '+39-3939989741',
+ 'fields' => ['nome' => 'NomeDestinatario']
+ ]
+];
+```
+
+Possiamo ora procedere ad inviare un SMS:
+```php
+
+try {
+ $singleSms = $this->openapi->SMS->sendOne('Nome del mittente', $recipient, 'lorem ipsum', null, 1, null);
+} catch (\OpenApi\classes\exception\OpenApiConnectionsException $e) {
+ throw 'Non è stato possibile recapitare il messaggio';
+}
+```
+
+Possiamo anche speficiare i prefissi in modo indipendente:
+```php
+$this->openapi->SMS->sendOne('Nome del mittente', '3939989741', 'lorem ipsum', '+42', 1, null);
+```
+
+O passare delle opzioni
+```php
+$options = ['timestamp_send' => '2021-04-20']
+$this->openapi->SMS->sendOne('Nome del mittente', '3939989741', 'lorem ipsum', '+42', 1, $options);
```
\ No newline at end of file
diff --git a/tests/ClientTest.php b/tests/ClientTest.php
index 9bd2d47..e638ac6 100644
--- a/tests/ClientTest.php
+++ b/tests/ClientTest.php
@@ -37,8 +37,8 @@ public function __construct() {
"GET:imprese.altravia.com/gruppoiva",
"GET:comuni.openapi.it/cap",
"GET:comuni.openapi.it/istat",
- "GET:comuni.openapi.it/regioni",
"GET:comuni.openapi.it/province",
+ "GET:comuni.openapi.it/regioni",
"GET:comuni.openapi.it/catastale",
"GET:ws.ufficiopostale.com/tracking",
"POST:geocoding.realgest.it/geocode",
@@ -95,12 +95,12 @@ public function testClientInstance() {
// $this->assertIsObject($Pec);
// }
- public function testMarche() {
- $marca = $this->openapi->marcheTemporali->availability('infocert', 1);
- $comprata = $this->openapi->marcheTemporali->purcahse('infocert', 1);
+ // public function testMarche() {
+ // $marca = $this->openapi->marcheTemporali->availability('infocert', 1);
+ // $comprata = $this->openapi->marcheTemporali->purcahse('infocert', 1);
- $this->assertIsInt($marca->availability);
- }
+ // $this->assertIsInt($marca->availability);
+ // }
// public function testGeocoding() {
// // Prendi informazioni sul cap 00132
@@ -135,11 +135,20 @@ public function testMarche() {
// $raccomandata->creaRaccomandataByData($data);
// }
- // public function testSms() {
- // $singleSms = $this->openapi->SMS->sendOne('prova', '3939989741', 'messaggio di prova', null, 1, null, true);
- // $this->assertIsArray($singleSms);
- // var_dump($singleSms);
- // }
+ public function testSms() {
+ $recipients = [
+ [
+ 'number' => '+39-3939989741',
+ 'fields' => ['nome' => 'NomeDestinatario']
+ ]
+ ];
+ $singleSms = $this->openapi->SMS->sendOne('test', '+39-3939989741', 'prova', null, 1, null, true);
+
+ $message = $this->openapi->SMS->getMessage($singleSms->data->id);
+
+ $this->assertEquals(true, $singleSms->success);
+ $this->assertEquals(true, $message['success']);
+ }
// public function testVisura() {
// // $visura = new VisRequest('eccbc87e4b5ce2fe28308fd9f2a7baf3');
From b3a888f6327ed77ef66a42380c4fa0da7e5c7d69 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Wed, 23 Jun 2021 16:35:48 +0200
Subject: [PATCH 41/85] Corrette dichiarazioni variabili mancanti
---
readme.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index b68db00..7b157aa 100644
--- a/readme.md
+++ b/readme.md
@@ -206,7 +206,9 @@ Possiamo ora procedere ad inviare un SMS:
```php
try {
- $singleSms = $this->openapi->SMS->sendOne('Nome del mittente', $recipient, 'lorem ipsum', null, 1, null);
+ $priority = 1;
+ $options = null;
+ $singleSms = $this->openapi->SMS->sendOne('Nome del mittente', $recipient, 'lorem ipsum', null, $priority, $options);
} catch (\OpenApi\classes\exception\OpenApiConnectionsException $e) {
throw 'Non è stato possibile recapitare il messaggio';
}
From cb94f145c2ddc1813d02c5925ffea5e9c5b300d5 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Thu, 24 Jun 2021 12:24:12 +0200
Subject: [PATCH 42/85] fix paramentro opzioni non passato
---
src/classes/Sms.php | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/classes/Sms.php b/src/classes/Sms.php
index 0a05d9d..e21b37a 100644
--- a/src/classes/Sms.php
+++ b/src/classes/Sms.php
@@ -75,9 +75,11 @@ function sendMore($sender, $recipients, $text, $transaction = false, $priority =
$param['recipients'] = $recipients;
$param['body'] = $text;
$param['transaction'] = $transaction;
- if($options != NULL){
- $param['priority'] = $priority;
+ $param['priority'] = $priority;
+ if(sizeof($options)){
+ $param['options'] = $options;
}
+
try{
$data = $this->connect("messages/", "POST", $param);
if(isset($data->data[0]) && $transaction){
@@ -94,8 +96,10 @@ function sendMore($sender, $recipients, $text, $transaction = false, $priority =
}
}
-
- function sendOne($sender, $recipient, $text, $prefix = NULL, $priority = 1,$options = NULL, $test = false){
+ /**
+ * @param number $priority un moltiplicatore per la priorita di invio
+ */
+ function sendOne($sender, $recipient, $text, $prefix = NULL, $priority = 1,$options = [], $test = false){
if($prefix != NULL){
$recipient = $prefix."-".$recipient;
}
@@ -105,8 +109,9 @@ function sendOne($sender, $recipient, $text, $prefix = NULL, $priority = 1,$opti
$param['recipients'] = $recipient;
$param['body'] = $text;
$param['transaction'] = FALSE;
- if($options != NULL){
- $param['priority'] = $priority;
+ $param['priority'] = $priority;
+ if(sizeof($options)){
+ $param['options'] = $options;
}
try{
From 5af6819ac999153c6fb35ea82ca19554f996d961 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Thu, 24 Jun 2021 12:25:08 +0200
Subject: [PATCH 43/85] aggiunto commento descrittivo
---
src/classes/VisEngine.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/classes/VisEngine.php b/src/classes/VisEngine.php
index f55c496..5dcc9f1 100644
--- a/src/classes/VisEngine.php
+++ b/src/classes/VisEngine.php
@@ -154,6 +154,9 @@ function getDocument($id_visura){
return $request;
}
+ /**
+ * Nel caso arrivino dei risultati di ricerca, seleziona il risultato richiesto
+ */
function setRicerca($id_visura, $id_ricerca, $index){
$index = str_replace("indice_","",$index);
$request = $this->getRequestByIdVisura($id_visura);
From fb1287fad5a4adcf17f9ba668dc82e83e37e585f Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Thu, 24 Jun 2021 12:25:32 +0200
Subject: [PATCH 44/85] rimosso file errato
---
src/classes/FirrmaDigitale.php | 16 ----------------
1 file changed, 16 deletions(-)
delete mode 100644 src/classes/FirrmaDigitale.php
diff --git a/src/classes/FirrmaDigitale.php b/src/classes/FirrmaDigitale.php
deleted file mode 100644
index de518c5..0000000
--- a/src/classes/FirrmaDigitale.php
+++ /dev/null
@@ -1,16 +0,0 @@
-basePath = "https://ws.firmadigitale.com";
- }
-
-
-}
\ No newline at end of file
From 43676a9c693d7b73539d62552d27e98017c03ff6 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 25 Jun 2021 09:57:41 +0200
Subject: [PATCH 45/85] fix type del json visura
---
src/classes/utility/VisEngine/VisRequest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/classes/utility/VisEngine/VisRequest.php b/src/classes/utility/VisEngine/VisRequest.php
index 447219b..47e9d2e 100644
--- a/src/classes/utility/VisEngine/VisRequest.php
+++ b/src/classes/utility/VisEngine/VisRequest.php
@@ -51,7 +51,7 @@ function getNew(){
*
* @return boolean Ritorna TRUE nel caso in cui tutti i campi richiesti per la visura sono stati compilati (attenzione, viene effettuata la sola validazione sui required, per la validazione del formato occcorre inviare la visura)
*/
- function setJson(object $data){
+ function setJson(array $data){
foreach($data as $k => $v){
if(!isset($this->variables[$k])){
throw new \OpenApi\classes\exception\OpenApiVisEngineException("Visengine you are setting $k json key, but $k key is not presente for {$this->visura->data->nome_visura}",40006);
From c89420effb412a164aede3a3a824476ba501e2b1 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 25 Jun 2021 09:58:57 +0200
Subject: [PATCH 46/85] impostato ritorno di createRequest visura
---
src/classes/VisEngine.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/classes/VisEngine.php b/src/classes/VisEngine.php
index 5dcc9f1..cae9a03 100644
--- a/src/classes/VisEngine.php
+++ b/src/classes/VisEngine.php
@@ -39,7 +39,7 @@ function getFormTool(){
* Prepara un nuovo oggetto di tipo VisRequest da utilizzare per inviare una nuova richiesta e lo restituisce
* @param int $ttr Time to Release sulla richiesta dei dati della visura
*
- * @return object
+ * @return \OpenApi\classes\utility\VisEngine\VisRequest
*/
function createRequest($ttr = 500){
if($this->hash == NULL){
From e9b6040b87d8298986881574d82d455c3f114efd Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 25 Jun 2021 09:59:08 +0200
Subject: [PATCH 47/85] aggiunti test per visengine
---
tests/ClientTest.php | 94 +++++++++++++++++++++++++++++++++++---------
1 file changed, 76 insertions(+), 18 deletions(-)
diff --git a/tests/ClientTest.php b/tests/ClientTest.php
index e638ac6..44eb7d6 100644
--- a/tests/ClientTest.php
+++ b/tests/ClientTest.php
@@ -50,6 +50,16 @@ public function __construct() {
"GET:ws.marchetemporali.com/availability",
"GET:ws.marchetemporali.com/marche",
"POST:ws.marchetemporali.com/check_lotto",
+ "GET:visengine2.altravia.com/fornitori",
+ "GET:ws.leicode.info/lei-records",
+ "POST:ws.leicode.info/create-lei",
+ "POST:ws.leicode.info/renew-lei",
+ "DELETE:visengine2.altravia.com/richiesta",
+ "GET:visengine2.altravia.com/visure",
+ "POST:visengine2.altravia.com/richiesta",
+ "PUT:visengine2.altravia.com/richiesta",
+ "GET:visengine2.altravia.com/richiesta",
+ "GET:visengine2.altravia.com/documento",
"POST:ws.marchetemporali.com/marca",
"POST:ws.marchetemporali.com/verifica",
"POST:ws.marchetemporali.com/analisi",
@@ -135,32 +145,80 @@ public function testClientInstance() {
// $raccomandata->creaRaccomandataByData($data);
// }
- public function testSms() {
- $recipients = [
- [
- 'number' => '+39-3939989741',
- 'fields' => ['nome' => 'NomeDestinatario']
- ]
- ];
- $singleSms = $this->openapi->SMS->sendOne('test', '+39-3939989741', 'prova', null, 1, null, true);
+ // public function testSms() {
+ // $recipients = [
+ // [
+ // 'number' => '+39-3939989741',
+ // 'fields' => ['nome' => 'NomeDestinatario']
+ // ]
+ // ];
+ // $singleSms = $this->openapi->SMS->sendOne('test', '+39-3939989741', 'prova', null, 1, null, true);
- $message = $this->openapi->SMS->getMessage($singleSms->data->id);
+ // $message = $this->openapi->SMS->getMessage($singleSms->data->id);
- $this->assertEquals(true, $singleSms->success);
- $this->assertEquals(true, $message['success']);
- }
-
- // public function testVisura() {
- // // $visura = new VisRequest('eccbc87e4b5ce2fe28308fd9f2a7baf3');
- // $response = $this->openapi->visengine->getRequestByIdVisura('eccbc87e4b5ce2fe28308fd9f2a7baf3');
- // $this->assertNotEmpty($response);
- // var_dump($response);
+ // $this->assertEquals(true, $singleSms->success);
+ // $this->assertEquals(true, $message['success']);
// }
+ public function testVisura() {
+ $this->openapi->visengine->setHash('eccbc87e4b5ce2fe28308fd9f2a7baf3');
+ $visura = $this->openapi->visengine->createRequest();
+ var_dump($visura);
+
+ $response = $this->openapi->visengine->getRequestByIdVisura('eccbc87e4b5ce2fe28308fd9f2a7baf3');
+ $this->assertNotEmpty($response);
+ // var_dump($response);
+ }
+
// public function testFirmaDigitale() {
// $data = json_decode(file_get_contents(__DIR__.'/esempio_firma.json'), true);
// $data['codice_prodotto'] = 'FIR';
// $response = $this->openapi->firmaDigitale->requestProduct($data);
// $this->assertNotEmpty($response);
// }
+ // public function testcreaVisura() {
+
+ // $this->openapi->visengine->setHash($visura->hash);
+ // $request = $this->openapi->visengine->createRequest();
+ // $res = $request->setJson((object)$json);
+ // if($request->isValidJson() && !$visura->show_form){
+ // $request->setState(1);
+ // $request->setCallbackData(site_url("callbacks/ordini/visure"),(object)["order_id"=>"".$order_id, "detail_key"=>$detail_key]);
+ // $request = $this->openapi->visengine->sendRequest($request);
+ // }
+ // }
+
+ // public function callbackVisura(Request $data) {
+ // $data =json_decode(file_get_contents('php://input'));
+ // $request = $this->openapi->visengine->getRequestByData($data);
+ // $ret['id'] = $request->getId();
+ // $ret['stato'] = $request->getStatoRichiesta();
+ // $ret['stato_ricerca'] = $request->getStatoRicerca();
+ // if($request->hasSearchResult()){
+ // $ret['ricerche'] = $request->getSearchResult();
+ // $ret['search_count'] = $request->getSearchCount();
+ // $ret['has_search_result'] = TRUE;
+ // $ret['search_id'] = $request->getSearchId();
+ // }else{
+ // if($request->getStatoRichiesta() == "Dati disponibili" || $request->getStatoRichiesta() == "Visura evasa"){
+ // $document = $this->openapi->visengine->getDocument($id_visura)->getDocument();
+ // if($document != NULL && $document->file != ""){
+ // $has_document = TRUE;
+ // //salviamo il file
+ // file_put_contents("writable/documenti/{$id_visura}.bin", $document->file);
+ // }
+ // }
+ // }
+ // }
+
+ public function testcreaVisura() {
+
+ $this->openapi->visengine->setHash('8f14e45fceea167a5a36dedd4bea2543');
+ $request = $this->openapi->visengine->createRequest();
+ $request->setState(1);
+ $request->setCallbackData('https://example.com', new stdClass(), 'POST');
+ $request->setJson(['$0' => 'abcd', '$1' => '12485671007']);
+ $visura = $this->openapi->visengine->sendRequest($request);
+
+ }
}
\ No newline at end of file
From 3815404df893b8d06693f3f81eb011a6245fd2a5 Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 25 Jun 2021 09:59:25 +0200
Subject: [PATCH 48/85] migliorato readme con esempi visengine
---
readme.md | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/readme.md b/readme.md
index 7b157aa..cca18e2 100644
--- a/readme.md
+++ b/readme.md
@@ -223,4 +223,27 @@ O passare delle opzioni
```php
$options = ['timestamp_send' => '2021-04-20']
$this->openapi->SMS->sendOne('Nome del mittente', '3939989741', 'lorem ipsum', '+42', 1, $options);
+```
+
+## Modulo Visengine
+Come prima cosa, settiamo l'hash della visura che vogliamo richiedere
+
+```php
+// https://developers.openapi.it/services/visengine
+$this->openapi->visengine->setHash($visura->hash);
+```
+
+A questo punto, possiamo lanciare `createRequest`, che ritornerà una istanza vuota della visura che andremo a creare della struttura richiesta
+
+```php
+$request = $this->openapi->visengine->createRequest();
+```
+
+Prodediamo a completare l'oggetto, che potremmo passare a sendRequest quando pronto
+
+```php
+$request->setJson(['$0' => 'abcd', '$1' => '12485671007']);
+ // url di callback, oggetto con dati aggiuntivi, metodo
+$request->setCallbackData('https://example.com', new stdClass(), 'POST');
+$visura = $this->openapi->visengine->sendRequest($request);
```
\ No newline at end of file
From 9f10a877577a7015c7fa51fdde5b25a565583b7d Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 25 Jun 2021 10:01:55 +0200
Subject: [PATCH 49/85] generata TOC
---
readme.md | 59 +++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 42 insertions(+), 17 deletions(-)
diff --git a/readme.md b/readme.md
index cca18e2..e96b0df 100644
--- a/readme.md
+++ b/readme.md
@@ -1,14 +1,39 @@
# OpenAPI Library
-## Installation
+
+* 1. [Installation](#Installation)
+* 2. [Usage](#Usage)
+ * 2.1. [Instanza della classe](#Instanzadellaclasse)
+ * 2.2. [Esempi](#Esempi)
+ * 2.3. [Creare raccomandata -->](#Creareraccomandata--)
+* 3. [Modulo comuni](#Modulocomuni)
+ * 3.1. [Esempi](#Esempi-1)
+ * 3.2. [Utilizzo](#Utilizzo)
+ * 3.3. [`sendRequest($VisRequest)` -->](#sendRequestVisRequest--)
+* 4. [Modulo imprese](#Moduloimprese)
+ * 4.1. [Utilizzo](#Utilizzo-1)
+ * 4.2. [Esempi](#Esempi-1)
+* 5. [Modulo Marche Temporali](#ModuloMarcheTemporali)
+ * 5.1. [Esempi](#Esempi-1)
+* 6. [Modulo SMS](#ModuloSMS)
+ * 6.1. [Inviare un SMS](#InviareunSMS)
+* 7. [Modulo Visengine](#ModuloVisengine)
+
+
+
+
+## 1. Installation
```sh
composer require altravia/openapi
```
-## Usage
+## 2. Usage
-### Instanza della classe
+### 2.1. Instanza della classe
```php
require_once 'vendor/autoload.php';
@@ -53,7 +78,7 @@ che possono essere usati al seguente modo:
```php
$this->openapi->ufficioposale->getCitiesByCap('00132');
```
-### Esempi
+### 2.2. Esempi
```php
require_once 'vendor/autoload.php';
@@ -77,9 +102,9 @@ $track = $this->openapi->ufficiopostale->track('123456789');
```
+### 2.3. Creare raccomandata -->
-## Modulo comuni
+## 3. Modulo comuni
Consente di prendere informazioni su comuni e provincie.
* `getCitiesByCap`
@@ -88,7 +113,7 @@ Consente di prendere informazioni su comuni e provincie.
* `getProvince`
* `getComuni`
-### Esempi
+### 3.1. Esempi
```php
$provincia = 'RM';
@@ -114,7 +139,7 @@ var_dump($comuni['comuni']);
```
+### 3.3. `sendRequest($VisRequest)` -->
-## Modulo imprese
-### Utilizzo
+## 4. Modulo imprese
+### 4.1. Utilizzo
Il modulo imprese espone i seguenti metodi:
* `getByPartitaIva`
* `getClosed`
@@ -136,7 +161,7 @@ Il modulo imprese espone i seguenti metodi:
Per `getBySearch` e `getByPartitaIva` è richiesto accesso allo scope `/advance`
-### Esempi
+### 4.2. Esempi
Utilizziamo `getBySearch` per cercare un'azienda il cui nome inizia con `Altrav` a Roma
```php
@@ -161,12 +186,12 @@ $autocomplete = $this->openapi->imprese->getBySearch('Altrav*', 'RM');
*/
```
-## Modulo Marche Temporali
+## 5. Modulo Marche Temporali
* `availability`
* `checkLotto`
* `purcahse`
-### Esempi
+### 5.1. Esempi
```php
// Controlliamo la disponibilitá di una marca di inforcert o aruba
@@ -182,13 +207,13 @@ if ($disponibilita->availability > 0) {
}
```
-## Modulo SMS
+## 6. Modulo SMS
* `getRecipients`
* `getMessage`
* `sendMore`
* `sendOne`
-### Inviare un SMS
+### 6.1. Inviare un SMS
Per inviare un SMS, per prima cosa definiamo i destinatari:
```php
@@ -225,7 +250,7 @@ $options = ['timestamp_send' => '2021-04-20']
$this->openapi->SMS->sendOne('Nome del mittente', '3939989741', 'lorem ipsum', '+42', 1, $options);
```
-## Modulo Visengine
+## 7. Modulo Visengine
Come prima cosa, settiamo l'hash della visura che vogliamo richiedere
```php
From 2bba961d462cf4ed3003c844c6ab9cf795cf631b Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Fri, 25 Jun 2021 10:04:12 +0200
Subject: [PATCH 50/85] corretta TOC
---
readme.md | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/readme.md b/readme.md
index e96b0df..139e3c8 100644
--- a/readme.md
+++ b/readme.md
@@ -5,13 +5,10 @@
* 2. [Usage](#Usage)
* 2.1. [Instanza della classe](#Instanzadellaclasse)
* 2.2. [Esempi](#Esempi)
- * 2.3. [Creare raccomandata -->](#Creareraccomandata--)
* 3. [Modulo comuni](#Modulocomuni)
* 3.1. [Esempi](#Esempi-1)
- * 3.2. [Utilizzo](#Utilizzo)
- * 3.3. [`sendRequest($VisRequest)` -->](#sendRequestVisRequest--)
* 4. [Modulo imprese](#Moduloimprese)
- * 4.1. [Utilizzo](#Utilizzo-1)
+ * 4.1. [Utilizzo](#Utilizzo)
* 4.2. [Esempi](#Esempi-1)
* 5. [Modulo Marche Temporali](#ModuloMarcheTemporali)
* 5.1. [Esempi](#Esempi-1)
@@ -25,6 +22,7 @@
/vscode-markdown-toc-config -->
+
## 1. Installation
```sh
@@ -101,8 +99,6 @@ $impresa = $openapi->imprese->getByPartitaIva('12485671007');
$track = $this->openapi->ufficiopostale->track('123456789');
```
-
## 3. Modulo comuni
Consente di prendere informazioni su comuni e provincie.
@@ -138,20 +134,8 @@ var_dump($comuni['comuni']);
```
-
-
-
## 4. Modulo imprese
-### 4.1. Utilizzo
+### 4.1. Utilizzo
Il modulo imprese espone i seguenti metodi:
* `getByPartitaIva`
* `getClosed`
From dfb8ef6a769c3caa17a6df341773a5ae88ab6de7 Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Tue, 29 Jun 2021 17:04:28 +0200
Subject: [PATCH 51/85] imprese openapi
---
src/OpenApi.php | 3 +
src/classes/ImpreseOpenapi.php | 143 +++++++++++++++++++++++++++++++++
2 files changed, 146 insertions(+)
create mode 100644 src/classes/ImpreseOpenapi.php
diff --git a/src/OpenApi.php b/src/OpenApi.php
index 89a6d44..f5fac3a 100644
--- a/src/OpenApi.php
+++ b/src/OpenApi.php
@@ -88,6 +88,9 @@ private function getListaModuli(){
$moduli['imprese.altravia.com'] = "\\OpenApi\\classes\\Imprese";
$nomi['imprese.altravia.com'] = "imprese";
+ $moduli['imprese.openapi.it'] = "\\OpenApi\\classes\\ImpreseOpenapi";
+ $nomi['imprese.openapi.it'] = "imprese";
+
$moduli['visengine2.altravia.com'] = "\\OpenApi\\classes\\VisEngine";
$nomi['visengine2.altravia.com'] = "visengine";
diff --git a/src/classes/ImpreseOpenapi.php b/src/classes/ImpreseOpenapi.php
new file mode 100644
index 0000000..a1b7f6f
--- /dev/null
+++ b/src/classes/ImpreseOpenapi.php
@@ -0,0 +1,143 @@
+basePath = "https://imprese.openapi.it";
+ }
+
+ /**
+ *
+ * Consente di recuperare i dati di una azienda a partire dalla partita IVA
+ *
+ * @param string $partitaIva La partita IVa da ricercare
+ * @param int $ttr Time to Release: per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+ *
+ * @return object
+ */
+ function getByPartitaIva(string $partitaIva, $ttr = 86400, $force = false){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("advance/$partitaIva", "GET", [], $ttr, true);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+
+
+ }
+
+ function getClosed(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("closed/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
+ function getVatGroup(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("gruppoIva/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
+ function getPec(string $partitaIva, $ttr = 86400){
+ $partitaIva = trim($partitaIva);
+ try{
+ $data = $this->connect("pec/$partitaIva", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
+ /**
+ *
+ * Cerca un'azienda o più utilizzando vari parametri
+ *
+ * @param string $denominazione Denominazione azienda
+ * @param string $provincia Provincia
+ * @param string $partitaIva=NULL Partita IVA
+ * @param string $codiceFiscale=NULL Codice Fiscale
+ * @param int $ttr Time to Release: per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+ *
+ * @return array Lista delle aziende individuate
+ */
+ function getBySearch(string $denominazione, string $provincia, $partitaIva= NULL , $codiceFiscale=NULL, $ttr = 86400){
+ $params=[];
+ if($denominazione != NULL){
+ $params['denominazione'] = trim($denominazione);
+ }
+ if($provincia != NULL){
+ $params['provincia'] = $provincia;
+ }
+ if($partitaIva != NULL){
+ $params['piva'] = $partitaIva;
+ }
+ if($codiceFiscale != NULL){
+ $params['cf'] = $codiceFiscale;
+ }
+
+ $data = $this->connect("advance/$partitaIva", "GET", $params, $ttr);
+ return $data->data;
+ }
+
+ function autocomplete($query, $ttr = 86400){
+ try{
+ $query = trim($query);
+ $query = str_replace(" ","*",$query);
+ $query = urlencode("*$query*");
+ $data = $this->connect("autocomplete/$query", "GET", [], $ttr);
+ if($data == null){
+ $data = [];
+ }else{
+ $data = $data->data;
+ }
+ return $data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ }
+ return [];
+
+ }
+}
\ No newline at end of file
From 099541b390b71a4ca621dc284f7492aa8c6ab2ac Mon Sep 17 00:00:00 2001
From: Paolo Bernardini
Date: Mon, 10 Jan 2022 09:18:02 +0100
Subject: [PATCH 52/85] - Bugfixing on API Ufficiopostale Raccomandata,
PecMassiva, VisEngine - API UfficioPostale: Posta Ordionaria, Posta
Prioritaria, Telegramma - API Catasto
---
src/OpenApi.php | 4 +
src/classes/Catasto.php | 95 ++++
src/classes/ImpreseOpenapi.php | 17 +
src/classes/PecMassiva.php | 152 +++---
src/classes/UfficioPostale.php | 249 +++++++---
src/classes/VisEngine.php | 6 +-
.../exception/OpenApiPecMassivaException.php | 28 +-
.../Objects/ErrorTranslation/errorLang.php | 23 +
.../Objects/ErrorTranslation/lng/it.json | 11 +
.../UfficioPostale/Objects/Recipient.php | 67 ++-
.../Objects/RecipientRaccomandate.php | 81 ++++
.../utility/UfficioPostale/PostaOrdinaria.php | 92 ++++
.../UfficioPostale/PostaPrioritaria.php | 90 ++++
.../utility/UfficioPostale/Raccomandata.php | 139 ++++--
.../utility/UfficioPostale/ServiziPostali.php | 42 +-
.../utility/UfficioPostale/Telegramma.php | 148 ++++++
src/classes/utility/VisRequest.php | 434 ++++++++++++++++++
17 files changed, 1482 insertions(+), 196 deletions(-)
create mode 100644 src/classes/Catasto.php
create mode 100644 src/classes/utility/UfficioPostale/Objects/ErrorTranslation/errorLang.php
create mode 100644 src/classes/utility/UfficioPostale/Objects/ErrorTranslation/lng/it.json
create mode 100644 src/classes/utility/UfficioPostale/Objects/RecipientRaccomandate.php
create mode 100644 src/classes/utility/UfficioPostale/PostaOrdinaria.php
create mode 100644 src/classes/utility/UfficioPostale/PostaPrioritaria.php
create mode 100644 src/classes/utility/UfficioPostale/Telegramma.php
create mode 100644 src/classes/utility/VisRequest.php
diff --git a/src/OpenApi.php b/src/OpenApi.php
index f5fac3a..f75db74 100644
--- a/src/OpenApi.php
+++ b/src/OpenApi.php
@@ -114,6 +114,10 @@ private function getListaModuli(){
$moduli['pec.openapi.it'] = "\\OpenApi\\classes\\Pec";
$nomi['pec.openapi.it'] = "PEC";
+
+ $moduli['catasto.openapi.it'] = "\\OpenApi\\classes\\Catasto";
+ $nomi['catasto.openapi.it'] = "catasto";
+
$moduli['ws.firmadigitale.com'] = "\\OpenApi\\classes\\FirmaDigitale";
$nomi['ws.firmadigitale.com'] = "firmaDigitale";
return array($moduli,$nomi);
diff --git a/src/classes/Catasto.php b/src/classes/Catasto.php
new file mode 100644
index 0000000..e07a613
--- /dev/null
+++ b/src/classes/Catasto.php
@@ -0,0 +1,95 @@
+basePath = "https://catasto.openapi.it";
+ }
+
+
+ function ufficiCatastali($ttl = 86400){
+ $data = $this->connect("territorio", "GET", [], $ttl);
+ return $data->data;
+ }
+
+ function getComuni($provincia, $ttl = 86400){
+ $data = $this->connect("territorio/$provincia", "GET", [], $ttl);
+ return $data->data;
+ }
+
+ function elencoImmobili($tipo_catasto, $provincia,$comune,$sezione, $foglio,$particella, $callback){
+ $param = [
+ "tipo_catasto" => $tipo_catasto,
+ "provincia" => trim($provincia),
+ "comune" => $comune,
+ "sezione" => $sezione,
+ "foglio" => $foglio,
+ "particella" => $particella,
+
+ ];
+ if($callback != NULL){
+ $param['callback'] = $callback;
+ }
+ $data = $this->connect("richiesta/elenco_immobili", "POST", $param);
+ return $data->data;
+ }
+
+ function getComune($provincia, $comune, $ttl = 86400){
+ $comune = urlencode($comune);
+ $data = $this->connect("territorio/$provincia/$comune", "GET", [], $ttl);
+ return $data->data;
+ }
+ function prospettoCatastale($tipo_catasto, $provincia,$comune,$sezione, $foglio,$particella,$subalterno, $callback=NULL){
+ $param = [
+ "tipo_catasto" => $tipo_catasto,
+ "provincia" => trim($provincia),
+ "comune" => $comune,
+ "sezione" => $sezione,
+ "foglio" => $foglio,
+ "particella" => $particella,
+ "subalterno" => $subalterno,
+ ];
+ if($callback != NULL){
+ $param['callback'] = $callback;
+ }
+ $data = $this->connect("richiesta/prospetto_catastale", "POST", $param);
+ return $data->data;
+ }
+
+ function ricercaPersona($tipo_catasto,$cf_piva,$provincia,$callback = NULL){
+ $param = [
+ "tipo_catasto" => $tipo_catasto,
+ "cf_piva" => trim($cf_piva),
+ "provincia" => $provincia,
+ ];
+ //var_dump($param);exit;
+ if($callback != NULL){
+ $param['callback'] = $callback;
+ }
+ $data = $this->connect("richiesta/ricerca_persona", "POST", $param);
+ return $data->data;
+ }
+
+ function ricercaNazionale($tipo_catasto,$cf_piva,$callback= NULL){
+ $param = [
+ "tipo_catasto" => $tipo_catasto,
+ "cf_piva" => trim($cf_piva)
+ ];
+ //var_dump($param);exit;
+ if($callback != NULL){
+ $param['callback'] = $callback;
+ }
+ $data = $this->connect("richiesta/ricerca_nazionale", "POST", $param);
+ return $data->data;
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/src/classes/ImpreseOpenapi.php b/src/classes/ImpreseOpenapi.php
index a1b7f6f..ad799d8 100644
--- a/src/classes/ImpreseOpenapi.php
+++ b/src/classes/ImpreseOpenapi.php
@@ -13,6 +13,23 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
$this->basePath = "https://imprese.openapi.it";
}
+ function getFormaGiuridica($codice, $ttr=86400){
+ $codice = trim($codice);
+ try{
+ $data = $this->connect("forma_giuridica/$codice", "GET", [], $ttr);
+ return $data->data;
+ }catch (\OpenApi\classes\exception\OpenApiConnectionsException $e){
+
+ if($e->getHTTPCode() == 404){
+ return null;
+ }
+ throw $e;
+
+
+ exit;
+ }
+ }
+
/**
*
* Consente di recuperare i dati di una azienda a partire dalla partita IVA
diff --git a/src/classes/PecMassiva.php b/src/classes/PecMassiva.php
index daafed0..dcb7f6b 100644
--- a/src/classes/PecMassiva.php
+++ b/src/classes/PecMassiva.php
@@ -1,77 +1,77 @@
-basePath = "https://ws.pecmassiva.com";
- $this->inizialized = FALSE;
-
- }
-
- function initialize(string $username, string $password){
- $this->username = $username;
- $this->password = $password;
- $this->inizialized = TRUE;
- }
-
- function getStatus($messageId){
- if(!$this->inizialized){
- throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
- }
-
-
- try{
- $header[] = 'x-username: '.$this->username;
- $header[] = 'x-password: '.$this->password;
- return $this->connect("send/$messageId","GET",[],0,false,$header);
-
- }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
- if(isset($e->getServerResponse()->message_id)){
- throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
- }
- throw $e;
-
- }
- }
-
- function send($recipient, $subject, $body, $attachments = [], $sender = NULL){
- if(!$this->inizialized){
- throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
- }
- $sender = $sender ? $sender : $this->username;
-
- $params['username'] = $this->username;
- $params['password'] = $this->password;
- $params['recipient'] = $recipient;
- $params['subject'] = $subject;
- $params['body'] = $body;
- if(count($attachments)>0){
- $params['attachments'] = $attachments;
- }
- $params['sender'] = $sender;
- try{
- return $this->connect("send","POST",$params);
- }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
- if(isset($e->getServerResponse()->message_id)){
- throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
- }
- throw $e;
-
- }
-
- }
-
-
+basePath = "https://ws.pecmassiva.com";
+ $this->inizialized = FALSE;
+
+ }
+
+ function initialize(string $username, string $password){
+ $this->username = $username;
+ $this->password = $password;
+ $this->inizialized = TRUE;
+ }
+
+ function getStatus($messageId){
+ if(!$this->inizialized){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
+ }
+
+
+ try{
+ $header[] = 'x-username: '.$this->username;
+ $header[] = 'x-password: '.$this->password;
+ return $this->connect("send/$messageId","GET",[],0,false,$header);
+
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if(isset($e->getServerResponse()->message_id)){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
+ }
+ throw $e;
+
+ }
+ }
+
+ function send($recipient, $subject, $body, $attachments = [], $sender = NULL){
+ if(!$this->inizialized){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("class must initialized calling initialize function", 40011);
+ }
+ $sender = $sender ? $sender : $this->username;
+
+ $params['username'] = $this->username;
+ $params['password'] = $this->password;
+ $params['recipient'] = $recipient;
+ $params['subject'] = $subject;
+ $params['body'] = $body;
+ if(count($attachments)>0){
+ $params['attachments'] = $attachments;
+ }
+ $params['sender'] = $sender;
+ try{
+ return $this->connect("send","POST",$params);
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ if(isset($e->getServerResponse()->message_id)){
+ throw new \OpenApi\classes\exception\OpenApiPecMassivaException("error occurred connecting to SMTP: ".$e->getServerResponse()->message_id, 40012);
+ }
+ throw $e;
+
+ }
+
+ }
+
+
}
\ No newline at end of file
diff --git a/src/classes/UfficioPostale.php b/src/classes/UfficioPostale.php
index 6ff1dec..9b31130 100644
--- a/src/classes/UfficioPostale.php
+++ b/src/classes/UfficioPostale.php
@@ -1,53 +1,198 @@
-basePath = "https://ws.ufficiopostale.com";
- }
-
-
- /**
- * Restiuisce un oggetto di tipo raccomandata
- * @return object
- */
- function createRaccomandata(){
- return new \OpenApi\classes\utility\UfficioPostale\Raccomandata(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
-
- return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
- });
-
-
- }
-
- function getRaccomandataById($id){
- $data = $this->connect("raccomandate/$id", "GET");
-
- return $this->getRaccomandataByData($data->data);
- }
-
- function getRaccomandataByData($data){
- $busta = $this->createRaccomandata();
- $busta->creaRaccomandataByData($data);
- return $busta;
- }
-
- function getPricing($type = NULL){
- return $this->connect("pricing/$type", "GET");
- }
-
- function track($tracking_code){
- return $this->connect("tracking/$tracking_code", "GET");
- }
-
-
-
-
-
+errorClass = NULL;
+ $this->setErrorLang('it');
+ $this->basePath = "https://ws.ufficiopostale.com";
+ }
+
+
+ /**
+ * Prende in ingresso la path di un json contenente le traduzioni degli errori
+ */
+ function setErrorLang($errorLang){
+ $this->errorClass = new \OpenApi\classes\utility\UfficioPostale\Objects\ErrorTranslation\errorLang($errorLang);
+ }
+
+ function getComuniByCAP($cap){
+ $data = $this->connect("comuni/$cap", "GET");
+ return $data->data;
+
+ }
+
+ function create( $prodotto){
+ if($prodotto == "raccomandata"){
+ return $this->createRaccomandata();
+ }
+ if($prodotto == "telegramma"){
+ return $this->createTelegramma();
+ }
+ if($prodotto == "posta-prioritaria"){
+ return $this->createPostaPrioritaria();
+ }
+ if($prodotto == "posta-ordinaria"){
+ return $this->createPostaOrdinaria();
+ }
+ $ex = new \OpenApi\classes\exception\OpenApiUPException("Il prodotto $prodotto non esiste",40014);
+ throw $ex;
+
+ }
+ /**
+ * Restiuisce un oggetto di tipo raccomandata
+ * @return object
+ */
+ function createRaccomandata(){
+ return new \OpenApi\classes\utility\UfficioPostale\Raccomandata(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
+
+ return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
+ },
+
+ function($code, $serverResponse){
+
+ return $this->errorClass->getError( $code, $serverResponse);
+ });
+ }
+
+ function createPostaPrioritaria(){
+ return new \OpenApi\classes\utility\UfficioPostale\PostaPrioritaria(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
+
+ return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
+ },
+
+ function($code, $serverResponse){
+
+ return $this->errorClass->getError( $code, $serverResponse);
+ });
+ }
+
+ function createPostaOrdinaria(){
+ return new \OpenApi\classes\utility\UfficioPostale\PostaOrdinaria(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
+
+ return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
+ },
+
+ function($code, $serverResponse){
+
+ return $this->errorClass->getError( $code, $serverResponse);
+ });
+ }
+
+ function createTelegramma(){
+ return new \OpenApi\classes\utility\UfficioPostale\Telegramma(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
+
+ return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);
+ },
+
+ function($code, $serverResponse){
+
+ return $this->errorClass->getError( $code, $serverResponse);
+ });
+ }
+
+
+ function track($tracking_code){
+ return $this->connect("tracking/$tracking_code", "GET");
+ }
+
+ function getById($id, $prodotto){
+ if($prodotto == "raccomandata"){
+ return $this->getRaccomandataById($id);
+ }
+ if($prodotto == "telegramma"){
+ return $this->getTelegrammaById($id);
+ }
+ if($prodotto == "posta-prioritaria"){
+ return $this->getPostaPrioritariaById($id);
+ }
+ if($prodotto == "posta-ordinaria"){
+ return $this->getPostaOrdinariaById($id);
+ }
+ $ex = new \OpenApi\classes\exception\OpenApiUPException("Il prodotto $prodotto non esiste",40014);
+ throw $ex;
+
+ }
+
+ function getByData($data, $prodotto){
+ if($prodotto == "raccomandata"){
+ return $this->getRaccomandataByData($data);
+ }
+ if($prodotto == "telegramma"){
+ return $this->getTelegrammaByData($data);
+ }
+ if($prodotto == "posta-prioritaria"){
+ return $this->getTelegrammaByData($data);
+ }
+ if($prodotto == "posta-ordinaria"){
+ return $this->getPostaOrdinariaByData($data);
+ }
+ $ex = new \OpenApi\classes\exception\OpenApiUPException("Il prodotto $prodotto non esiste",40014);
+ throw $ex;
+ }
+
+ function getRaccomandataById($id){
+ $data = $this->connect("raccomandate/$id", "GET");
+ return $this->getRaccomandataByData($data->data);
+ }
+
+ function getRaccomandataByData($data){
+ $busta = $this->createRaccomandata();
+ $busta->creaRaccomandataByData($data);
+ return $busta;
+ }
+
+ function getPostaPrioritariaById($id){
+ $data = $this->connect("prioritarie/$id", "GET");
+ return $this->getPostaPrioritariaByData($data->data);
+ }
+
+ function getPostaPrioritariaByData($data){
+ $busta = $this->createPostaPrioritaria();
+ $busta->creaPostaPrioritariaByData($data);
+ return $busta;
+ }
+
+ function getPostaOrdinariaById($id){
+ $data = $this->connect("ordinarie/$id", "GET");
+ return $this->getPostaOrdinariaByData($data->data);
+ }
+
+ function getPostaOrdinariaByData($data){
+ $busta = $this->createPostaOrdinaria();
+ $busta->creaPostaOrdinariaByData($data);
+ return $busta;
+ }
+
+
+ function getTelegrammaById($id){
+ $data = $this->connect("telegrammi/$id", "GET");
+
+ return $this->getTelegrammaByData($data->data);
+ }
+
+ function getTelegrammaByData($data){
+ $busta = $this->createTelegramma();
+ $busta->creaTelegrammaByData($data);
+ return $busta;
+ }
+ function getPricing($type = NULL){
+ return $this->connect("pricing/$type", "GET");
+ }
+
+
+ function getDug(){
+ return $this->connect("dug/", "GET");
+ }
+
+
+
+
+
}
\ No newline at end of file
diff --git a/src/classes/VisEngine.php b/src/classes/VisEngine.php
index f55c496..2869869 100644
--- a/src/classes/VisEngine.php
+++ b/src/classes/VisEngine.php
@@ -143,10 +143,14 @@ function getRequestByData($visura){
}
function getDocument($id_visura){
+
ini_set("memory_limit","1024M");
+
$request = $this->getRequestByIdVisura($id_visura);
+
$documento = $this->connect("documento/{$id_visura}", "GET", [], 0);
- //var_dump($documento);exit;
+
+
if($request->getStatoRichiesta() == "Dati disponibili" || $request->getStatoRichiesta() == "Visura evasa"){
$request->setDocument($documento->data);
diff --git a/src/classes/exception/OpenApiPecMassivaException.php b/src/classes/exception/OpenApiPecMassivaException.php
index 7f48b0e..31d9848 100644
--- a/src/classes/exception/OpenApiPecMassivaException.php
+++ b/src/classes/exception/OpenApiPecMassivaException.php
@@ -1,15 +1,15 @@
-errors = (array)json_decode(file_get_contents($json));
+ }
+
+ function getError($code, $serverResponse){
+ if(isset($this->errors[$code])){
+ return $this->errors[$code];
+ }else{
+ if(isset($serverResponse->message)){
+ return $serverResponse->message;
+ }
+ }
+
+ return NULL;
+ }
+
+}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/Objects/ErrorTranslation/lng/it.json b/src/classes/utility/UfficioPostale/Objects/ErrorTranslation/lng/it.json
new file mode 100644
index 0000000..bc591a9
--- /dev/null
+++ b/src/classes/utility/UfficioPostale/Objects/ErrorTranslation/lng/it.json
@@ -0,0 +1,11 @@
+{
+
+ "12080":"Il campo indirizzo è obbligatorio",
+ "15060":"Il campo indirizzo è obbligatorio",
+ "12090":"Il campo numero civico è obbligatorio",
+ "15070":"Il campo numero civico è obbligatorio",
+ "12140":"Il campo comune è obbligatorio",
+ "15080":"Il campo comune è obbligatorio",
+ "13020":"Caricare almeno un documento o un testo",
+ "12180":"Comune, CAP e provinca in conflitto"
+}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/Objects/Recipient.php b/src/classes/utility/UfficioPostale/Objects/Recipient.php
index 7b7d178..8c1e0e7 100644
--- a/src/classes/utility/UfficioPostale/Objects/Recipient.php
+++ b/src/classes/utility/UfficioPostale/Objects/Recipient.php
@@ -1,10 +1,10 @@
errors = null;
@@ -25,6 +25,8 @@ function __construct($recipient = NULL){
$this->data->id = NULL;
$this->data->IdRicevuta = NULL;
$this->data->tracking_code = NULL;
+ $this->data->post_office = NULL;
+ $this->data->post_office_box = NULL;
$this->itData = new \stdClass();
@@ -44,7 +46,15 @@ function __construct($recipient = NULL){
$this->itData->id = NULL;
$this->itData->IdRicevuta = NULL;
$this->itData->tracking_code = NULL;
-
+ $this->data->state = NULL;
+ $this->itData->state = NULL;
+ $this->itData->casella_postale = NULL;
+ $this->itData->ufficio_postale = NULL;
+
+ $this->itData->stateType = 'TRANSITORIO';
+ $this->data->stateType = 'TRANSITORIO';
+ $this->data->stateDescription = 'Inviato da Web';
+ $this->itData->stateDescription = 'Inviato da Web';
$this->validate = false;
if($recipient != NULL){
@@ -57,6 +67,30 @@ public function createFromObject($object){
$object = (object)$object;
}
//var_dump($object);Exit;
+ $stateType = 'TRANSITORIO';
+ $stateDescription = '';
+ // var_dump($object);exit;
+ if(isset($object->tracking))
+ {
+ $object->tracking = (array)$object->tracking;
+ if(is_array($object->tracking) && count($object->tracking)>1){
+
+ $lastT = $object->tracking[count($object->tracking)-1];
+
+ $stateType = $lastT->definitivo?'DEFINITIVO':'TRANSITORIO';
+ $stateDescription = $lastT->descrizione;
+
+ }
+ }else{
+ if(isset($object->stateType)){
+ $stateType = $object->stateType;
+ $stateDescription = $object->state;
+ }
+ }
+ $this->data->stateType = $stateType;
+ $this->data->stateDescription = $stateDescription;
+ $this->itData->stateType = $stateType;
+ $this->itData->stateDescription = $stateDescription;
$this->data->title = isset($object->title)?$object->title:(isset($object->titolo)?$object->titolo:NULL);
$this->data->at = isset($object->at)?$object->at:(isset($object->co)?$object->co:NULL);
$this->data->firstName = isset($object->firstName)?$object->firstName:(isset($object->nome)?$object->nome:NULL);
@@ -75,9 +109,13 @@ public function createFromObject($object){
$this->data->state = isset($object->state)?$object->state:NULL;
$this->data->IdRicevuta = isset($object->IdRicevuta)?$object->IdRicevuta:NULL;
$this->data->tracking_code = isset($object->NumeroRaccomandata)?$object->NumeroRaccomandata:NULL;
+ $this->data->post_office = isset($object->post_office)?$object->post_office:(isset($object->ufficio_postale)?$object->ufficio_postale:NULL);
+ $this->data->post_office_box = isset($object->post_office_box)?$object->post_office_box:(isset($object->casella_postale)?$object->casella_postale:NULL);
+ $this->itData->ufficio_postale = $this->data->post_office;
+ $this->itData->casella_postale = $this->data->post_office_box;
$this->itData->co = $this->data->at;
$this->itData->titolo = $this->data->title;
$this->itData->nome = $this->data->firstName;
@@ -96,7 +134,10 @@ public function createFromObject($object){
$this->itData->IdRicevuta = isset($object->IdRicevuta)?$object->IdRicevuta:NULL;
$this->itData->tracking_code = isset($object->NumeroRaccomandata)?$object->NumeroRaccomandata:NULL;
-
+ if($this->itData->tracking_code == NULL && $this->itData->IdRicevuta != NULL){
+ $this->itData->tracking_code = $this->itData->IdRicevuta;
+ $this->data->tracking_code = $this->itData->tracking_code;
+ }
}
public function getObject($itNames = FALSE){
@@ -118,7 +159,13 @@ public function getState(){
return $this->data->state;
}
+ public function getStateType(){
+ return $this->data->stateType;
+ }
+ public function getStateDescription(){
+ return $this->data->stateDescription;
+ }
public function getFirstName(){
return $this->data->firstName;
}
@@ -126,6 +173,10 @@ public function getSecondName(){
return $this->data->secondName;
}
+ public function getLastName(){
+ return $this->getSecondName();
+ }
+
public function getCompanyName(){
return $this->data->companyName;
}
@@ -182,6 +233,10 @@ public function setFirstName(string $firstName){
$this->itData->nome = $firstName;
}
+ public function setLastName(string $secondName){
+ $this->setSecondName($secondName);
+
+ }
public function setSecondName(string $secondName){
$this->data->secondName = $secondName;
$this->itData->cognome = $secondName;
diff --git a/src/classes/utility/UfficioPostale/Objects/RecipientRaccomandate.php b/src/classes/utility/UfficioPostale/Objects/RecipientRaccomandate.php
new file mode 100644
index 0000000..5ffa0f9
--- /dev/null
+++ b/src/classes/utility/UfficioPostale/Objects/RecipientRaccomandate.php
@@ -0,0 +1,81 @@
+tracking))
+ {
+ $object->tracking = (array)$object->tracking;
+ if(is_array($object->tracking) && count($object->tracking)>1){
+
+ $lastT = $object->tracking[count($object->tracking)-1];
+
+ $stateType = $lastT->definitivo?'DEFINITIVO':'TRANSITORIO';
+ $stateDescription = $lastT->descrizione;
+
+ }
+ }else{
+ if(isset($object->stateType)){
+ $stateType = $object->stateType;
+ $stateDescription = $object->state;
+ }
+ }
+ $this->data->stateType = $stateType;
+ $this->data->stateDescription = $stateDescription;
+ $this->itData->stateType = $stateType;
+ $this->itData->stateDescription = $stateDescription;
+ $this->data->title = isset($object->title)?$object->title:(isset($object->titolo)?$object->titolo:NULL);
+ $this->data->at = isset($object->at)?$object->at:(isset($object->co)?$object->co:NULL);
+ $this->data->firstName = isset($object->firstName)?$object->firstName:(isset($object->nome)?$object->nome:NULL);
+ $this->data->secondName = isset($object->secondName)?$object->secondName:(isset($object->cognome)?$object->cognome:NULL);
+ $this->data->companyName = isset($object->companyName)?$object->companyName:(isset($object->ragione_sociale)?$object->ragione_sociale:NULL);
+ $this->data->dug = isset($object->dug)?$object->dug:NULL;
+ $this->data->address = isset($object->address)?$object->address:(isset($object->indirizzo)?$object->indirizzo:NULL);
+ $this->data->huoseNumber = isset($object->huoseNumber)?$object->huoseNumber:(isset($object->civico)?$object->civico:NULL);
+ $this->data->city = isset($object->city)?$object->city:(isset($object->comune)?$object->comune:NULL);
+ $this->data->zip = isset($object->zip)?$object->zip:(isset($object->cap)?$object->cap:NULL);
+ $this->data->province = isset($object->province)?$object->province:(isset($object->provincia)?$object->provincia:NULL);
+ $this->data->country = isset($object->country)?$object->country:(isset($object->nazione)?$object->nazione:"IT");
+ $this->data->email = isset($object->email)?$object->email:NULL;
+
+ $this->data->id = isset($object->id)?$object->id:NULL;
+ $this->data->state = isset($object->state)?$object->state:NULL;
+ $this->data->IdRicevuta = isset($object->IdRicevuta)?$object->IdRicevuta:NULL;
+ $this->data->tracking_code = isset($object->NumeroRaccomandata)?$object->NumeroRaccomandata:NULL;
+ $this->data->post_office = isset($object->post_office)?$object->post_office:(isset($object->ufficio_postale)?$object->ufficio_postale:NULL);
+ $this->data->post_office_box = isset($object->post_office_box)?$object->post_office_box:(isset($object->casella_postale)?$object->casella_postale:NULL);
+
+
+
+ $this->itData->ufficio_postale = $this->data->post_office;
+ $this->itData->casella_postale = $this->data->post_office_box;
+ $this->itData->co = $this->data->at;
+ $this->itData->titolo = $this->data->title;
+ $this->itData->nome = $this->data->firstName;
+ $this->itData->cognome = $this->data->secondName;
+ $this->itData->ragione_sociale = $this->data->companyName;
+ $this->itData->dug = $this->data->dug;
+ $this->itData->indirizzo = $this->data->address;
+ $this->itData->civico = $this->data->huoseNumber;
+ $this->itData->comune = $this->data->city;
+ $this->itData->cap = $this->data->zip;
+ $this->itData->provincia = $this->data->province;
+ $this->itData->nazione = $this->data->country;
+ $this->itData->email = $this->data->email;
+ $this->itData->id= $this->data->id;
+ $this->itData->state= $this->data->state;
+
+ $this->itData->IdRicevuta = isset($object->IdRicevuta)?$object->IdRicevuta:NULL;
+ $this->itData->tracking_code = isset($object->NumeroRaccomandata)?$object->NumeroRaccomandata:NULL;
+
+ }
+}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/PostaOrdinaria.php b/src/classes/utility/UfficioPostale/PostaOrdinaria.php
new file mode 100644
index 0000000..15f7a67
--- /dev/null
+++ b/src/classes/utility/UfficioPostale/PostaOrdinaria.php
@@ -0,0 +1,92 @@
+getId() == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUPException("Id not present",40011);
+ }
+ if($this->getState() != "NEW"){
+ throw new \OpenApi\classes\exception\OpenApiUPException("State is not NEW",40012);
+ }
+ $param['confirmed'] = TRUE;
+ $ret = call_user_func_array($this->connect,["ordinarie/".$this->getId(),"PATCH",$param]);
+
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+ }
+
+ function send(){
+ try{
+ $object = new \stdClass();;
+ $object->mittente = $this->sender->getObject(TRUE);
+ $object->destinatari = [];
+ foreach($this->getRecpients() as $r){
+ $object->destinatari[] = $r->getObject(TRUE);
+ }
+ $object->documento =$this->documents;
+ $object->opzioni = new \stdClass();
+ $object->opzioni->fronteretro = $this->getFronteRetro();
+ $object->opzioni->colori = $this->getColori();
+ $object->opzioni->autoconfirm = $this->getAutoconfirm();
+ if($this->getCallback() != NULL){
+ $callback = $this->getCallback();
+ foreach($callback as $k => $v){
+ $object->opzioni->$k = $v;
+ }
+ }
+ $ret = call_user_func_array($this->connect,["ordinarie/","POST",$object]);
+ $this->pricing = $ret->data[0]->pricing;
+ $this->id = $ret->data[0]->id;
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->pages = $ret->data[0]->documento_validato->pagine;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+ return true;
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ $response = $e->getServerResponse();
+ //var_dump($response->data->wrong_fields);exit;
+ if(isset($response->data->wrong_fields) && isset($response->error)){
+ $error_message = $this->getError($response->error, $response);
+
+ $e2 = new \OpenApi\classes\exception\OpenApiUPFieldsException("Fields Error",40013);
+ $e2->setServerResponse($e->getServerResponse(), $e->getServerHeaderResponse(), $e->getServerRawResponse(), $e->getHttpCode());
+ $e2->setErrorMessage($error_message);
+ $e2->setFields($response->data->wrong_fields);
+ throw $e2;
+ }
+ throw $e;
+ }
+ }
+
+
+ function creaPostaOrdinariaByData($data){
+ if(isset($data->documento_validato) && is_object($data->documento_validato)){
+ $this->valid_doc_pdf = $data->documento_validato->pdf;
+ $this->valid_doc_jpg = $data->documento_validato->jpg;
+ }
+ $this->pricing = $data->pricing;
+ $this->id = $data->id;
+ $this->confirmed = $data->confirmed;
+ $this->state = $data->state;
+ $this->numero_pagine = $data->documento_validato->pagine;
+ $this->clearRecipients();
+ $this->setRecipients($data->destinatari);
+ $this->setSender($data->mittente);
+ $this->colori = $data->opzioni->colori;
+ $this->fronteretro = $data->opzioni->fronteretro;
+ $this->setCallback($data->opzioni->callback_url, $data->opzioni->custom);
+
+ if(isset($data->IDRichiesta)){
+ $this->request_id = $data->IDRichiesta;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/PostaPrioritaria.php b/src/classes/utility/UfficioPostale/PostaPrioritaria.php
new file mode 100644
index 0000000..061a415
--- /dev/null
+++ b/src/classes/utility/UfficioPostale/PostaPrioritaria.php
@@ -0,0 +1,90 @@
+getId() == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUPException("Id not present",40011);
+ }
+ if($this->getState() != "NEW"){
+ throw new \OpenApi\classes\exception\OpenApiUPException("State is not NEW",40012);
+ }
+ $param['confirmed'] = TRUE;
+ $ret = call_user_func_array($this->connect,["prioritarie/".$this->getId(),"PATCH",$param]);
+
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+ }
+
+ function send(){
+ try{
+ $object = new \stdClass();;
+ $object->mittente = $this->sender->getObject(TRUE);
+ $object->destinatari = [];
+ foreach($this->getRecpients() as $r){
+ $object->destinatari[] = $r->getObject(TRUE);
+ }
+ $object->documento =$this->documents;
+ $object->opzioni = new \stdClass();
+ $object->opzioni->fronteretro = $this->getFronteRetro();
+ $object->opzioni->colori = $this->getColori();
+ $object->opzioni->autoconfirm = $this->getAutoconfirm();
+ if($this->getCallback() != NULL){
+ $callback = $this->getCallback();
+ foreach($callback as $k => $v){
+ $object->opzioni->$k = $v;
+ }
+ }
+ $ret = call_user_func_array($this->connect,["prioritarie/","POST",$object]);
+ $this->pricing = $ret->data[0]->pricing;
+ $this->id = $ret->data[0]->id;
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->pages = $ret->data[0]->documento_validato->pagine;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+ return true;
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ $response = $e->getServerResponse();
+ //var_dump($response->data->wrong_fields);exit;
+ if(isset($response->data->wrong_fields) && isset($response->error)){
+ $error_message = $this->getError($response->error, $response);
+
+ $e2 = new \OpenApi\classes\exception\OpenApiUPFieldsException("Fields Error",40013);
+ $e2->setServerResponse($e->getServerResponse(), $e->getServerHeaderResponse(), $e->getServerRawResponse(), $e->getHttpCode());
+ $e2->setErrorMessage($error_message);
+ $e2->setFields($response->data->wrong_fields);
+ throw $e2;
+ }
+ throw $e;
+ }
+ }
+
+
+ function creaPostaPrioritariaByData($data){
+ if(isset($data->documento_validato) && is_object($data->documento_validato)){
+ $this->valid_doc_pdf = $data->documento_validato->pdf;
+ $this->valid_doc_jpg = $data->documento_validato->jpg;
+ }
+ $this->pricing = $data->pricing;
+ $this->id = $data->id;
+ $this->confirmed = $data->confirmed;
+ $this->state = $data->state;
+ $this->numero_pagine = $data->documento_validato->pagine;
+ $this->clearRecipients();
+ $this->setRecipients($data->destinatari);
+ $this->setSender($data->mittente);
+ $this->colori = $data->opzioni->colori;
+ $this->fronteretro = $data->opzioni->fronteretro;
+ $this->setCallback($data->opzioni->callback_url, $data->opzioni->custom);
+ if(isset($data->IDRichiesta)){
+ $this->request_id = $data->IDRichiesta;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/Raccomandata.php b/src/classes/utility/UfficioPostale/Raccomandata.php
index 44ccc53..18f2ebf 100644
--- a/src/classes/utility/UfficioPostale/Raccomandata.php
+++ b/src/classes/utility/UfficioPostale/Raccomandata.php
@@ -2,10 +2,12 @@
namespace OpenApi\classes\utility\UfficioPostale;
class Raccomandata extends ServiziPostali {
- function __construct($connect){
- parent::__construct($connect);
+ function __construct($connect, $errorClass){
+ parent::__construct($connect, $errorClass);
}
+
+
function confirm(){
if($this->getId() == NULL){
throw new \OpenApi\classes\exception\OpenApiUPException("Id not present",40011);
@@ -22,10 +24,96 @@ function confirm(){
$this->setRecipients($ret->data[0]->destinatari);
}
+
+ /*
+ public function setRecipients($recipients){
+ $this->clearRecipients();
+ $valid = TRUE;
+ foreach($recipients as $key => $recipient){
+ if(!($recipient instanceof \OpenApi\classes\utility\UfficioPostale\Objects\RecipientRaccomandate)){
+
+ $recipient = new \OpenApi\classes\utility\UfficioPostale\Objects\RecipientRaccomandate($recipient);
+ }
+ if(!$recipient->validate()){
+ $valid = FALSE;
+ }
+ $this->recipients[] = $recipient;
+ }
+ $this->validRecipients = $valid;
+ return $valid;
+ }
+
+ protected function getError($code, $serverResponse){
+ return call_user_func_array($this->errorFunc,[$code, $serverResponse]);
+ }
+
+ public function addRecipient($recipient){
+
+ if(!($recipient instanceof \OpenApi\classes\utility\UfficioPostale\Objects\RecipientRaccomandate)){
+ $recipient = new \OpenApi\classes\utility\UfficioPostale\Objects\RecipientRaccomandate($recipient);
+ }
+ $valid = TRUE;
+ if(!$recipient->validate()){
+ $valid = FALSE;
+ }
+ $this->recipients[] = $recipient;
+ $this->validRecipients = $valid;
+ return $valid;
+ }*/
+
+
+ function send(){
+ try{
+ $object = new \stdClass();;
+ $object->mittente = $this->sender->getObject(TRUE);
+ $object->destinatari = [];
+ foreach($this->getRecpients() as $r){
+ $object->destinatari[] = $r->getObject(TRUE);
+ }
+ $object->documento =$this->documents;
+ $object->opzioni = new \stdClass();
+ $object->opzioni->fronteretro = $this->getFronteRetro();
+ $object->opzioni->colori = $this->getColori();
+ $object->opzioni->ar = $this->getAR();
+ $object->opzioni->autoconfirm = $this->getAutoconfirm();
+ if($this->getCallback() != NULL){
+ $callback = $this->getCallback();
+ foreach($callback as $k => $v){
+ $object->opzioni->$k = $v;
+ }
+ }
+ $ret = call_user_func_array($this->connect,["raccomandate/","POST",$object]);
+ $this->pricing = $ret->data[0]->pricing;
+ $this->id = $ret->data[0]->id;
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->pages = $ret->data[0]->documento_validato->pagine;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+ return true;
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ $response = $e->getServerResponse();
+ //var_dump($response->data->wrong_fields);exit;
+ if(isset($response->data->wrong_fields) && isset($response->error)){
+ $error_message = $this->getError($response->error, $response);
+
+ $e2 = new \OpenApi\classes\exception\OpenApiUPFieldsException("Fields Error",40013);
+ $e2->setServerResponse($e->getServerResponse(), $e->getServerHeaderResponse(), $e->getServerRawResponse(), $e->getHttpCode());
+ $e2->setErrorMessage($error_message);
+ $e2->setFields($response->data->wrong_fields);
+ throw $e2;
+ }
+ throw $e;
+ }
+ }
+
+
function creaRaccomandataByData($data){
-
-
+ if(isset($data->documento_validato) && is_object($data->documento_validato)){
+ $this->valid_doc_pdf = $data->documento_validato->pdf;
+ $this->valid_doc_jpg = $data->documento_validato->jpg;
+ }
$this->pricing = $data->pricing;
$this->id = $data->id;
$this->confirmed = $data->confirmed;
@@ -38,46 +126,9 @@ function creaRaccomandataByData($data){
$this->fronteretro = $data->opzioni->fronteretro;
$this->ar = $data->opzioni->ar;
$this->setCallback($data->opzioni->callback_url, $data->opzioni->custom);
- }
-
- function send(){
- $object = new \stdClass();;
- $object->mittente = $this->sender->getObject(TRUE);
- $object->destinatari = [];
- foreach($this->getRecpients() as $r){
- $object->destinatari[] = $r->getObject(TRUE);
+ if(isset($data->IDRichiesta)){
+ $this->request_id = $data->IDRichiesta;
}
- $object->documento =$this->documents;
- $object->opzioni = new \stdClass();
- $object->opzioni->fronteretro = $this->getFronteRetro();
- $object->opzioni->colori = $this->getColori();
- $object->opzioni->ar = $this->getAR();
- $object->opzioni->autoconfirm = $this->getAutoconfirm();
- if($this->getCallback() != NULL){
- $callback = $this->getCallback();
- foreach($callback as $k => $v){
- $object->opzioni->$k = $v;
- }
- }
- // var_dump($object);exit;
- if($this->getId() == NULL){
- $ret = call_user_func_array($this->connect,["raccomandate/","POST",$object]);
- }else{
- $ret = call_user_func_array($this->connect,["raccomandate/".$this->getId(),"PATCH",$object]);
- }
-
- if(!isset($ret->data[0])){
- return false;
- }
- $this->pricing = $ret->data[0]->pricing;
- $this->id = $ret->data[0]->id;
- $this->confirmed = $ret->data[0]->confirmed;
- $this->state = $ret->data[0]->state;
- $this->numero_pagine = $ret->data[0]->documento_validato->pagine;
- $this->clearRecipients();
- $this->setRecipients($ret->data[0]->destinatari);
- return true;
- //$ret= $this->connect->call($this,"raccomandate",$object,"POST");
-
}
+
}
\ No newline at end of file
diff --git a/src/classes/utility/UfficioPostale/ServiziPostali.php b/src/classes/utility/UfficioPostale/ServiziPostali.php
index 3e0c16b..a9b19a7 100644
--- a/src/classes/utility/UfficioPostale/ServiziPostali.php
+++ b/src/classes/utility/UfficioPostale/ServiziPostali.php
@@ -17,12 +17,19 @@ class ServiziPostali {
protected $confirmed;
protected $state;
protected $callback;
+ protected $pages;
+ protected $request_id;
protected $numero_pagine;
+ protected $valid_doc_pdf;
+ protected $valid_doc_jpg;
- function __construct($connect){
+ function __construct($connect, $errorFunc){
$this->connect = $connect;
$this->sender = NULL;
+ $this->errorFunc = $errorFunc;
$this->recipients = [];
+ $this->valid_doc_pdf = NULL;
+ $this->valid_doc_jpg = NULL;
$this->documents = [];
$this->textMessage = NULL;
$this->validRecipients = FALSE;
@@ -37,9 +44,34 @@ function __construct($connect){
$this->callback = NULL;
}
+
+ function setRequestId($request_id){
+ $this->request_id = $request_id;
+ }
+
+ function getRequestId(){
+ return $this->request_id ;
+ }
+
+ function getValidatedDocument($type = "pdf"){
+ if($type == "pdf"){
+ return $this->valid_doc_pdf;
+ }
+ if($type == "jpg"){
+ return $this->valid_doc_jpg;
+ }
+ }
+
+ function getNumeroLettere(){
+ throw new \OpenApi\classes\exception\OpenApiUPException("Letter exist only for telagrammi",40016);
+ }
+
function getNumeroPagine(){
return $this->numero_pagine;
}
+ function getPages(){
+ return $this->pages;
+ }
function getPricing(){
return $this->pricing;
@@ -113,9 +145,9 @@ public function getSenderError(){
}
public function getRecipients(){
- return $this->recipients;
+ return $this->getRecpients();
}
-
+ //MANTENUTO PER RETROCOMPATIBILITA'
public function getRecpients(){
return $this->recipients;
}
@@ -155,6 +187,10 @@ public function setRecipients($recipients){
return $valid;
}
+ protected function getError($code, $serverResponse){
+ return call_user_func_array($this->errorFunc,[$code, $serverResponse]);
+ }
+
public function addRecipient($recipient){
if(!($recipient instanceof \OpenApi\classes\utility\UfficioPostale\Objects\Recipient)){
diff --git a/src/classes/utility/UfficioPostale/Telegramma.php b/src/classes/utility/UfficioPostale/Telegramma.php
new file mode 100644
index 0000000..1a86447
--- /dev/null
+++ b/src/classes/utility/UfficioPostale/Telegramma.php
@@ -0,0 +1,148 @@
+letter = NULL;
+ $this->ar_e = false;
+ $this->ar_c = false;
+ }
+
+ function getNumeroLettere(){
+ return $this->letter;
+ }
+
+ function getNumeroParole(){
+ return $this->parole;
+ }
+ function getNumeroPagine(){
+ throw new \OpenApi\classes\exception\OpenApiUPException("Pages not exist for telagrammi",40015);
+ }
+
+
+ function confirm(){
+ if($this->getId() == NULL){
+ throw new \OpenApi\classes\exception\OpenApiUPException("Id not present",40011);
+ }
+ if($this->getState() != "NEW"){
+ throw new \OpenApi\classes\exception\OpenApiUPException("State is not NEW",40012);
+ }
+ $param['confirmed'] = TRUE;
+ $ret = call_user_func_array($this->connect,["telegrammi/".$this->getId(),"PATCH",$param]);
+
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+ }
+
+
+ function send(){
+ try{
+ $object = new \stdClass();;
+ $object->mittente = $this->sender->getObject(TRUE);
+ $object->destinatari = [];
+ foreach($this->getRecpients() as $r){
+ $object->destinatari[] = $r->getObject(TRUE);
+ }
+ $object->documento =$this->documents;
+ $object->opzioni = new \stdClass();
+
+ $object->opzioni->ar_c = is_bool($this->ar_c)?$this->ar_c:$this->ar_c->getObject(TRUE);
+
+ $object->opzioni->ar_e = $this->ar_e;
+
+ if($this->getCallback() != NULL){
+ $callback = $this->getCallback();
+ foreach($callback as $k => $v){
+ $object->opzioni->$k = $v;
+ }
+ }
+ $ret = call_user_func_array($this->connect,["telegrammi/","POST",$object]);
+ $this->pricing = $ret->data[0]->pricing;
+ $this->id = $ret->data[0]->id;
+ $this->confirmed = $ret->data[0]->confirmed;
+ $this->state = $ret->data[0]->state;
+ $this->letter = $ret->data[0]->documento_validato->size;
+ $this->parole = $ret->data[0]->documento_validato->parole;
+ $this->clearRecipients();
+ $this->setRecipients($ret->data[0]->destinatari);
+ return true;
+ }catch(\OpenApi\classes\exception\OpenApiConnectionsException $e){
+ $response = $e->getServerResponse();
+ if(isset($response->data->wrong_fields) && isset($response->error)){
+ $error_message = $this->getError($response->error, $response);
+
+ $e2 = new \OpenApi\classes\exception\OpenApiUPFieldsException("Fields Error",40013);
+ $e2->setServerResponse($e->getServerResponse(), $e->getServerHeaderResponse(), $e->getServerRawResponse(), $e->getHttpCode());
+ $e2->setErrorMessage($error_message);
+ $e2->setFields($response->data->wrong_fields);
+ throw $e2;
+ }
+ throw $e;
+ }
+ }
+
+ function creaTelegrammaByData($data){
+ if(isset($data->documento_validato) && is_object($data->documento_validato)){
+ $this->valid_doc_pdf = $data->documento_validato->pdf;
+ $this->valid_doc_jpg = $data->documento_validato->jpg;
+ }
+ $this->pricing = $data->pricing;
+ $this->id = $data->id;
+ $this->confirmed = $data->confirmed;
+ $this->state = $data->state;
+ $this->letter = $data->documento_validato->size;
+ $this->parole = $data->documento_validato->parole;
+ $this->clearRecipients();
+ $this->setRecipients($data->destinatari);
+ $this->setSender($data->mittente);
+ $this->ar_e = isset($data->opzioni->ar_e)?$data->opzioni->ar_e:FALSE;
+ $this->ar_c = isset($data->opzioni->ar_c)?$data->opzioni->ar_c:FALSE;
+ /* $this->colori = $data->opzioni->colori;
+ $this->fronteretro = $data->opzioni->fronteretro;
+ $this->ar = $data->opzioni->ar;*/
+ $this->setCallback($data->opzioni->callback_url, $data->opzioni->custom);
+ if(isset($data->IDRichiesta)){
+ $this->request_id = $data->IDRichiesta;
+ }
+
+ }
+
+
+ function setRicevutaElettronica($ar_e){
+ $this->ar_e = $ar_e;
+ }
+
+ function getRicevutaElettronica(){
+ return $this->ar_e;
+ }
+
+ function setRicevutaCartacea($ar_c){
+ if(is_bool(($ar_c))){
+ $this->ar_c = $ar_c;
+ return TRUE;
+ }else{
+ if($ar_c instanceof \OpenApi\classes\utility\UfficioPostale\Objects\Sender){
+ $this->ar_c = $ar_c;
+ }else{
+ $this->ar_c = new \OpenApi\classes\utility\UfficioPostale\Objects\Sender($ar_c);
+ }
+ if(!$this->ar_c->validate()){
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ }
+
+ function getRicevutaCartacea(){
+ return $this->ar_c;
+ }
+
+}
\ No newline at end of file
diff --git a/src/classes/utility/VisRequest.php b/src/classes/utility/VisRequest.php
new file mode 100644
index 0000000..447219b
--- /dev/null
+++ b/src/classes/utility/VisRequest.php
@@ -0,0 +1,434 @@
+ visengin",40008);
+ }
+ $this->visura = $visura;
+ $this->variables = [];
+ $this->new = TRUE;
+ $this->json = NULL;
+ $this->jsonValido = FALSE;
+ $this->state = 0;
+ $this->test = false;
+ $this->callback = NULL;
+ $this->email_target = NULL;
+ $this->id = NULL;
+ $this->statoRichiesta = NULL;
+ $this->ricerche = [];
+ $this->document = NULL;
+ $this->format_errror = [];
+ $this->opzioni = null;
+ foreach($visura->data->json_struttura->campi as $k => $v){
+ $this->variables[$k] = FALSE;
+ }
+ }
+
+ function setOpzioni($opzioni){
+ $this->opzioni = $opzioni;
+ }
+
+ function getOpzioni(){
+ return $this->opzioni;
+ }
+
+ function setNew(bool $new){
+ return $this->new = $new;
+ }
+
+ function getNew(){
+ return $this->new;
+ }
+ /**
+ *
+ * Imposta il JSON per inviare una nuova visura
+ *
+ * @param array $data IL JSON della visura da inviare
+ *
+ * @return boolean Ritorna TRUE nel caso in cui tutti i campi richiesti per la visura sono stati compilati (attenzione, viene effettuata la sola validazione sui required, per la validazione del formato occcorre inviare la visura)
+ */
+ function setJson(object $data){
+ foreach($data as $k => $v){
+ if(!isset($this->variables[$k])){
+ throw new \OpenApi\classes\exception\OpenApiVisEngineException("Visengine you are setting $k json key, but $k key is not presente for {$this->visura->data->nome_visura}",40006);
+ }
+ $this->variables[$k] = $v!=NULL;
+ }
+ $this->json = $data;
+
+ $this->validaJSON();
+ return $this->jsonValido;
+ }
+
+
+
+
+
+ /**
+ *
+ * Restituisce il JSON della visura
+ *
+ * @return object
+ */
+ function getJson(){
+ return $this->json;
+ }
+
+ /**
+ * Ritorna TRUE nel caso in cui tutti i campi richiesti per la visura sono presenti all'interno del JSON
+ * @return boolean
+ */
+ function isValidJson(){
+ return $this->jsonValido;
+ }
+
+ /**
+ *
+ * Imposta i dati della callback
+ *
+ * @param string $url La url da richiamare per la callback
+ * @param object $data Oggetto data che verrà ripassato
+ * @param string $method='JSON' Metodo da usare JSON/POST
+ * @param string $field="visengineData" Nome del campo dove verranno passati i dati della visura
+ *
+ * @return void
+ */
+ function setCallbackData(string $url, object $data, $method = "JSON", $field="visengineData"){
+ $this->callback = (object)[
+ "url" => $url,
+ "data" => $data,
+ "method" => $method,
+ "field" => $field
+ ];
+ }
+
+
+ /**
+ * Restituisce i dati della callback
+ *
+ * @return object
+ */
+ function getCallbackData(){
+ return $this->callback;
+ }
+
+ /**
+ * Impowsta il parametro state della visura
+ * @param int $stato
+ *
+ * @return void
+ */
+ function setState($stato = 0){
+ if($stato != 0 && !$this->jsonValido ){
+ throw new \OpenApi\classes\exception\OpenApiVisEngineException("JSON is not valid, so is not possible set state = 1",40007);
+ }
+ $this->state = $stato == 0 ? $stato : 1;
+ }
+
+ /**
+ * Ritorna il parametro state
+ * @return int
+ */
+ function getState(){
+ return $this->state;
+ }
+
+ /**
+ * Imposta il parametro email_target
+ *
+ * @param string $email_target
+ *
+ * @return void
+ */
+ function setTargetEmail(string $email_target){
+ $this->email_target = $email_target;
+ }
+
+ /**
+ * Ritorna il parametro email_target
+ * @return string
+ */
+ function getTargetEmail(){
+ return $this->email_target;
+ }
+
+ function hasSearchResult(){
+ return $this->visura->data->ricerca == 1 && $this->getStatoRichiesta() == "In ricerca" && $this->getStatoRicerca() == "Ricerca evasa";
+ }
+
+ function getSearchResult(){
+ if(count($this->ricerche) == NULL){
+ return FALSE;
+ }
+ return json_decode($this->ricerche[count($this->ricerche) - 1]->json_risultato);
+ }
+ function getSearchId(){
+ if(count($this->ricerche) == NULL){
+ return FALSE;
+ }
+ return $this->ricerche[count($this->ricerche) - 1]->id_ricerca;
+ }
+ function getSearch(){
+ if(count($this->ricerche) == NULL){
+ return FALSE;
+ }
+ return $this->ricerche[count($this->ricerche) - 1];
+ }
+
+ function getSearchCount(){
+ return count($this->ricerche);
+ }
+
+ function setDocument($document){
+ $this->document = $document;
+ }
+
+ function getDocument(){
+ return $this->document;
+ }
+
+ function getHash(){
+ return $this->visura->data->hash_visura;
+ }
+
+
+ /**
+ *
+ * Imposta il parametro test
+ *
+ * @param bool $test
+ *
+ * @return void
+ */
+ function setTest(bool $test){
+ $this->test = $test;
+ }
+
+
+ /**
+ * Restituisce il parametro test
+ * @return bool
+ */
+ function getTest(){
+ return $this->test;
+ }
+
+
+ /**
+ * Controlla il JSON e ritorna TRUE nel caso in cui tutti i campi richiesti per la visura sono presenti all'interno del JSON
+ * @return boolean
+ */
+ private function validaJSON(){
+ if(!$this->validaPresenzaCampi()){
+ $this->format_errror = [];
+ $this->jsonValido = FALSE;
+ return;
+ }
+ $this->format_errror = [];
+ if(!$this->validaFormatoCampi()){
+ $this->jsonValido = FALSE;
+ return;
+ }
+ $this->jsonValido = TRUE;
+
+ }
+
+ private function validaFormatoCampi(){
+ $error = FALSE;
+// var_dump($this->visura->data->json_struttura->campi);exit;
+
+ //cod_comune
+ //cod_provincia
+ //codice_fiscale_persona_fisica
+ foreach($this->visura->data->json_struttura->campi as $key => $campo){
+ if(!isset($this->json->$key) || $this->json->$key == ""){
+ continue;
+ }
+ if(isset($campo->tipo) && $campo->tipo == 'codice_fiscale_persona_fisica'){
+ $val = new \OpenApi\classes\utility\Plugins\Validations();
+ if(!$val->italianFiscalCode($this->json->$key)){
+ $this->format_errror[$key] = 'codice_fiscale_persona_fisica';
+ $error = TRUE;
+ }
+ }
+
+ if(isset($campo->tipo) && $campo->tipo == 'partita_iva'){
+ $val = new \OpenApi\classes\utility\Plugins\Validations();
+ if(!$val->italianFiscalCode($this->json->$key) && !$val->italianVat($this->json->$key)){
+ $this->format_errror[$key] = 'partita_iva';
+ $error = TRUE;
+ }
+ }
+
+ if(isset($campo->tipo) && $campo->tipo == 'codice_fiscale'){
+ $val = new \OpenApi\classes\utility\Plugins\Validations();
+ if(!$val->italianFiscalCode($this->json->$key) && !$val->italianVat($this->json->$key)){
+ $this->format_errror[$key] = 'codice_fiscale';
+ $error = TRUE;
+ }
+ }
+ if(isset($campo->tipo) && $campo->tipo == 'cod_comune'){
+ $re = '/^[a-zA-Z]{1}[0-9]{3}$/m';
+
+ preg_match_all($re, $this->json->$key, $matches, PREG_SET_ORDER, 0);
+ if(count($matches) == 0){
+ $this->format_errror[$key] = 'cod_comune';
+ $error = TRUE;
+ }
+ }
+
+ if(isset($campo->tipo) && $campo->tipo == 'cod_provincia'){
+ $re = '/^[a-zA-Z]{2}$/m';
+
+ preg_match_all($re, $this->json->$key, $matches, PREG_SET_ORDER, 0);
+ if(count($matches) == 0){
+ $this->format_errror[$key] = 'cod_provincia';
+ $error = TRUE;
+ }
+ }
+ if(isset($campo->tipo) && $campo->tipo == 'data_iso8601'){
+ $d = \DateTime::createFromFormat("d-m-Y", $this->json->$key);
+
+ if(!($d && $d->format('d-m-Y') === $this->json->$key)){
+ $this->format_errror[$key] = 'data_iso8601';
+ $error = TRUE;
+ }
+ }
+ }
+ return !$error;
+ }
+
+ private function validaPresenzaCampi(){
+ $re = '/\$(\d)+/m';
+ $validazione = $this->visura->data->json_struttura->validazione;
+ $subst = '$this->variables[\'$0\']';
+ $valida = TRUE;
+ $validazione = '$valida = ' .preg_replace($re, $subst, $validazione).";";
+ eval($validazione);
+ return $valida;
+ }
+
+ public function getErrors(){
+ if(count($this->format_errror) != 0){
+ $ret['error_type'] = "format";
+ $ret['error'] = $this->format_errror;
+ return $ret;
+ }
+ $this->expr = [];
+ $validazione = $this->visura->data->json_struttura->validazione;
+
+ list($validazione, $expr) =$this->createExpression($validazione);
+
+ //var_dump($validazione);exit;
+ $errori = $this->valida($validazione, $expr);
+
+ $ret['error_type'] = "empty_fields";
+ $ret['error'] = $errori;
+ return $ret;
+
+ }
+
+ private function valida($validazione,$expr, $errori = []){
+ //var_dump($this->variables);
+ $errori = ["type"=>"and","list"=>[]];
+ $and = explode('&&',$validazione);
+ foreach($and as $andItem){
+ $andItem = trim($andItem);
+ $or = explode('||',$andItem);
+ if(count($or) == 1){
+ $orItem = $or[0];
+ if(substr($orItem,0,1)=='$'){
+ if(!$this->variables[$orItem]){
+ $errori['list'][] = $orItem;
+ }
+ }else{
+ $errors = $this->valida($expr[str_replace("e","",$orItem)], $expr);
+ if(count($errors)){
+
+ $errori['list'] = array_merge($errori['list'], $errors['list']);
+
+ }
+ }
+ }else{
+ $errore = false;
+ $item = array();
+ $hasError = true;
+ foreach($or as $orItem){
+ $orItem = trim($orItem);
+ if(substr($orItem,0,1)=='$'){
+ $item[] = $orItem;
+ if($this->variables[$orItem]){
+
+ $hasError = FALSE;
+ }
+ }else{
+ $errors = $this->valida($expr[str_replace("e","",$orItem)], $expr);
+ if(count($errors['list'])){
+ $item[] = $errors;
+ }else{
+ $hasError = FALSE;
+ }
+ }
+ }
+
+ if($hasError){
+ $errori['list'][] = ["type"=>"or","list"=>$item];
+ }
+ }
+ }
+
+ return $errori;
+ }
+
+ private function createExpression($validazione, $expr = []){
+ $preg = "/\(([$\d&| e]*?)\)/";
+ preg_match($preg, $validazione, $matches, PREG_OFFSET_CAPTURE, 0);
+ if(isset($matches[0]) && isset($matches[1])){
+ $expr[] = $matches[1][0];
+ $expn = count($expr)-1;
+ $validazione = str_replace($matches[0],"e{$expn}",$validazione);
+ return $this->createExpression($validazione, $expr);
+ }
+ return array($validazione, $expr);
+
+ }
+
+ function getId() {
+ return $this->id;
+ }
+
+ function setId($id) {
+ $this->id = $id;
+ }
+
+ function getStatoRichiesta() {
+ return $this->statoRichiesta;
+ }
+
+ function setStatoRichiesta($statoRichiesta) {
+ $this->statoRichiesta = $statoRichiesta;
+ }
+
+ function getRicerche() {
+ return $this->ricerche;
+ }
+
+ function setRicerche($ricerche) {
+ $this->ricerche = $ricerche;
+ }
+
+ function getStatoRicerca(){
+ if(count($this->ricerche) == NULL){
+ return FALSE;
+ }
+ return $this->ricerche[count($this->ricerche) - 1]->stato_ricerca;
+ }
+
+ function getValidation(){
+ return $validazione = $this->visura->data->json_struttura->validazione;;
+ }
+}
\ No newline at end of file
From 2e80b3efb00e73078c222d063f53d193acd88bab Mon Sep 17 00:00:00 2001
From: Lorenzo Paderi
Date: Thu, 24 Feb 2022 13:03:20 +0100
Subject: [PATCH 53/85] Merge 'readme.md' from 'fix-linting' into 'master'
---
readme.md | 239 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 218 insertions(+), 21 deletions(-)
diff --git a/readme.md b/readme.md
index 4911d52..139e3c8 100644
--- a/readme.md
+++ b/readme.md
@@ -1,61 +1,258 @@
# OpenAPI Library
-## Installation
+
+* 1. [Installation](#Installation)
+* 2. [Usage](#Usage)
+ * 2.1. [Instanza della classe](#Instanzadellaclasse)
+ * 2.2. [Esempi](#Esempi)
+* 3. [Modulo comuni](#Modulocomuni)
+ * 3.1. [Esempi](#Esempi-1)
+* 4. [Modulo imprese](#Moduloimprese)
+ * 4.1. [Utilizzo](#Utilizzo)
+ * 4.2. [Esempi](#Esempi-1)
+* 5. [Modulo Marche Temporali](#ModuloMarcheTemporali)
+ * 5.1. [Esempi](#Esempi-1)
+* 6. [Modulo SMS](#ModuloSMS)
+ * 6.1. [Inviare un SMS](#InviareunSMS)
+* 7. [Modulo Visengine](#ModuloVisengine)
+
+
+
+
+
+## 1. Installation
```sh
composer require altravia/openapi
```
-## Usage
+## 2. Usage
-### Instanza della classe
+### 2.1. Instanza della classe
```php
- $this->openapi = new \OpenApi\OpenApi($scopes,$user,$apikey,"test");
+require_once 'vendor/autoload.php';
+
+$openapi = new \OpenApi\OpenApi($scopes, $user, $apikey, $environment);
```
Dove `$scopes` è un array di stringhe o di oggetti in uno dei seguenti formati:
```php
-$scopes=[
+$scopes = [
"GET:ws.ufficiopostale.com/comuni",
- ["domain"=>"ws.ufficiopostale.com", "method"=>"comuni","mode"=>"GET"]
+ [
+ "domain"=>"ws.ufficiopostale.com",
+ "method"=>"comuni",
+ "mode" =>"GET"
+ ]
];
```
...e `$environment` è l'ambiente sceltro tra `'test'` (default) e `'production'`
+OpenApi si occuperá di reperire automaticamente, o generare, un nuovo token quando necessario.
+
+A questo punto, in base agli scopes indicati vengono creati i seguenti oggetti:
-A questo punto, in base agli scopes indicati vengono creati i seguenti oggetto:
```php
-$this->openapi->ufficiopostale
-$this->openapi->imprese
-...
+// Ogni oggetto verrá creato solo se disponibile nello scope.
+$openapi->ufficiopostale;
+$openapi->comuni;
+$openapi->imprese;
+$openapi->visengine;
+$openapi->marcheTemporali;
+$openapi->geocoding;
+$openapi->SMS;
+$openapi->firmaDigitale;
+$openapi->pecMassiva;
```
-
che possono essere usati al seguente modo:
```php
$this->openapi->ufficioposale->getCitiesByCap('00132');
```
+### 2.2. Esempi
+
+```php
+require_once 'vendor/autoload.php';
+
+// Dichiaro gli scopes necessari
+$scopes = [
+ 'GET:comuni.openapi.it/cap',
+ 'GET:imprese.altravia.com/advance',
+];
+
+$openapi = new OpenApi\OpenApi($scopes, 'my_username','my_api_key', 'test');
+
+// Comuni: prendi informazioni sul cap 00132
+$cap = $openapi->comuni->getCitiesByCap('00132');
+
+// Imprese: prendi informazioni su una specifica impresa
+$impresa = $openapi->imprese->getByPartitaIva('12485671007');
+
+// Ufficio Postale: ottieni informaizoni sul tracking
+$track = $this->openapi->ufficiopostale->track('123456789');
+```
+
+
+## 3. Modulo comuni
+Consente di prendere informazioni su comuni e provincie.
+
+* `getCitiesByCap`
+* `getComuneByCatasto`
+* `getRegioni`
+* `getProvince`
+* `getComuni`
+
+### 3.1. Esempi
+
+```php
+$provincia = 'RM';
+$comuni = $this->openapi->comuni->getComuni($provincia);
+
+var_dump($comuni['comuni']);
+/*
+
+["nome_provincia"]=>
+ string(4) "Roma"
+ ["sigla_provincia"]=>
+ string(2) "RM"
+ ["regione"]=>
+ string(5) "Lazio"
+ ["comuni"]=>
+ array(121) {
+ [0]=>
+ string(6) "Affile"
+ ...
+*/
+
+
+```
+
+## 4. Modulo imprese
+### 4.1. Utilizzo
+Il modulo imprese espone i seguenti metodi:
+* `getByPartitaIva`
+* `getClosed`
+* `getVatGroup`
+* `getPec`
+* `getBySearch`
+
+Per `getBySearch` e `getByPartitaIva` è richiesto accesso allo scope `/advance`
+
+### 4.2. Esempi
+Utilizziamo `getBySearch` per cercare un'azienda il cui nome inizia con `Altrav` a Roma
+
+```php
+$autocomplete = $this->openapi->imprese->getBySearch('Altrav*', 'RM');
+
+/*
+ [0]=>
+ object(stdClass)#41 (10) {
+ ["piva"]=>
+ string(11) "12485671007"
+ ["cf"]=>
+ string(11) "12485671007"
+ ["denominazione"]=>
+ string(20) "ALTRAVIA SERVIZI SRL"
+ [1]=>
+ object(stdClass)#42 (10) {
+ ["id"]=>
+ string(24) "4242424242"
+ ["denominazione"]=>
+ string(18) "xxx Altravia Esempio 2"
+ ...
+ */
+```
+
+## 5. Modulo Marche Temporali
+* `availability`
+* `checkLotto`
+* `purcahse`
+
+### 5.1. Esempi
+
+```php
+// Controlliamo la disponibilitá di una marca di inforcert o aruba
+$disponibilita = $this->openapi->marcheTemporali->availability('infocert', 1);
+
+// Se le marche sono disponibili, acquistiamone una
+if ($disponibilita->availability > 0) {
+ try {
+ $marca = $this->openapi->marcheTemporali->purcahse('infocert', 1);
+ } catch (\OpenApi\classes\exception\OpenApiMarcheTemporaliException $e) {
+ error_log(var_dump($e));
+ }
+}
+```
+
+## 6. Modulo SMS
+* `getRecipients`
+* `getMessage`
+* `sendMore`
+* `sendOne`
+
+### 6.1. Inviare un SMS
+Per inviare un SMS, per prima cosa definiamo i destinatari:
+
+```php
+$recipient = '+39-3939989741';
+// OR
+$recipients = [
+ [
+ 'number' => '+39-3939989741',
+ 'fields' => ['nome' => 'NomeDestinatario']
+ ]
+];
+```
-# Modulo ufficio postale
+Possiamo ora procedere ad inviare un SMS:
+```php
-# Modulo visure
+try {
+ $priority = 1;
+ $options = null;
+ $singleSms = $this->openapi->SMS->sendOne('Nome del mittente', $recipient, 'lorem ipsum', null, $priority, $options);
+} catch (\OpenApi\classes\exception\OpenApiConnectionsException $e) {
+ throw 'Non è stato possibile recapitare il messaggio';
+}
+```
-# Modulo imprese
+Possiamo anche speficiare i prefissi in modo indipendente:
+```php
+$this->openapi->SMS->sendOne('Nome del mittente', '3939989741', 'lorem ipsum', '+42', 1, null);
+```
-## `getByPartitaIva`
+O passare delle opzioni
+```php
+$options = ['timestamp_send' => '2021-04-20']
+$this->openapi->SMS->sendOne('Nome del mittente', '3939989741', 'lorem ipsum', '+42', 1, $options);
+```
-### Introduction
+## 7. Modulo Visengine
+Come prima cosa, settiamo l'hash della visura che vogliamo richiedere
-La funzione consente di recuperare i dati aziendali a partire dalla partita IVA
+```php
+// https://developers.openapi.it/services/visengine
+$this->openapi->visengine->setHash($visura->hash);
+```
-### Description
+A questo punto, possiamo lanciare `createRequest`, che ritornerà una istanza vuota della visura che andremo a creare della struttura richiesta
-`function getByPartitaIva(string $partitaIva, $ttl = 86400):object`
+```php
+$request = $this->openapi->visengine->createRequest();
+```
-* $partitaIva: La partita IVA da cercare
-* $ttl: Time To Release, per quanti secondi la chiamata resta in cache prima di essere effettuata una seconda volta
+Prodediamo a completare l'oggetto, che potremmo passare a sendRequest quando pronto
+```php
+$request->setJson(['$0' => 'abcd', '$1' => '12485671007']);
+ // url di callback, oggetto con dati aggiuntivi, metodo
+$request->setCallbackData('https://example.com', new stdClass(), 'POST');
+$visura = $this->openapi->visengine->sendRequest($request);
+```
\ No newline at end of file
From 28def3741e6c5fe1577b9154d4fb387da207f999 Mon Sep 17 00:00:00 2001
From: francesco
Date: Mon, 13 Oct 2025 20:21:09 +0200
Subject: [PATCH 54/85] chore: init quality maintenance
---
.github/REPOINFO.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .github/REPOINFO.txt
diff --git a/.github/REPOINFO.txt b/.github/REPOINFO.txt
new file mode 100644
index 0000000..e69de29
From d198c335e76718b42fad61e028a9805a78df2786 Mon Sep 17 00:00:00 2001
From: francesco
Date: Mon, 13 Oct 2025 20:30:29 +0200
Subject: [PATCH 55/85] chore: upkeep
---
.github/assets/repo-header-a3.png | Bin 0 -> 72023 bytes
.github/assets/repo-header-a3.txt | 15 +
readme.md => README.md | 529 +++++++++++++++---------------
3 files changed, 287 insertions(+), 257 deletions(-)
create mode 100644 .github/assets/repo-header-a3.png
create mode 100644 .github/assets/repo-header-a3.txt
rename readme.md => README.md (88%)
diff --git a/.github/assets/repo-header-a3.png b/.github/assets/repo-header-a3.png
new file mode 100644
index 0000000000000000000000000000000000000000..3db54204d56f3a78206b802f343cd5df829a19e0
GIT binary patch
literal 72023
zcmbrlbyQnV*C-5yVx<&oaS8>B2ZsO&6n7|AiWLnWf(4frC{_q=MT-}0ai@53cL`2$
zcf0BDdA{d;-@EP~-@12Yog{N+&z{-7&z?D`jf-m55!n8Ba`6LXj;1mF&JKtZFS
zfyCV%Ow4Q{E_9|4OKW>D^Fc!kGo7_Lm{~_agf5L0Q;AU2TNfG1y
z57>X*`v(@p^_RPL*8gJ4KaGELHhT
zQ5`4>`Tk8IswE-;cd>#wiK(Cz76PM_wx*M_HbFtcK!0KXzh0Cb{3DJ3D~_WK^*=2C
zAB%A}arkdGfdUixN0(tvS}>TMn3RdVs|g*82E^VR;skMGr89?_fu$wnxOF7-R0X*u
z=-|!}C$P4JjH;%ko-6E~3Z1EwiM=^k3t|GLQ!#NuxfB%BQTGO@5WgVDJ_pbmB@
zQvrjx{`a~5kM#YEWR(9vc@nPw_#0H?KOPIUG%&Lh${#f^7Wkr}lfF`rme6uf-EH!i
zcahUxdMGJuI6byIh!Miwena;;K3%4_zjk>3z|APqr?ghW_gnba?_`Jzgd6cR=uX-pvh-y-*>U&>Q41oY{92!
zd;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