1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-01-14 08:26:43 +01:00
openstamanager/plugins/receiptFE/src/Interaction.php
2019-02-20 16:07:42 +01:00

54 lines
1.2 KiB
PHP

<?php
namespace Plugins\ReceiptFE;
use Plugins\ExportFE\Connection;
/**
* Classe per l'interazione con API esterne.
*
* @since 2.4.3
*/
class Interaction extends Connection
{
public static function getReceiptList()
{
$response = static::request('POST', 'notifiche_da_importare');
$body = static::responseBody($response);
return $body['results'];
}
public static function getReceipt($name)
{
$directory = Ricevuta::getImportDirectory();
$file = $directory.'/'.$name;
if (!file_exists($file)) {
$response = static::request('POST', 'notifica_da_importare', [
'name' => $name,
]);
$body = static::responseBody($response);
Ricevuta::store($name, $body['content']);
}
return $name;
}
public static function processReceipt($filename)
{
$response = static::request('POST', 'notifica_xml_salvata', [
'filename' => $filename,
]);
$body = static::responseBody($response);
$result = true;
if ($body['status'] != '200') {
$result = $body['status'].' - '.$body['message'];
}
return $result;
}
}