openstamanager/plugins/exportFE/src/Interaction.php

37 lines
932 B
PHP
Raw Normal View History

2018-12-07 18:16:46 +01:00
<?php
namespace Plugins\ExportFE;
/**
* Classe per l'interazione con API esterne.
*
* @since 2.4.3
*/
2018-12-14 12:50:44 +01:00
class Interaction extends Connection
2018-12-07 18:16:46 +01:00
{
public static function sendXML($id_record)
{
try {
$fattura = new FatturaElettronica($id_record);
$file = DOCROOT.'/'.FatturaElettronica::getDirectory().'/'.$fattura->getFilename();
2019-02-19 15:59:27 +01:00
$response = static::request('POST', 'invio_fattura_xml', [
'xml' => file_get_contents($file),
'filename' => $fattura->getFilename(),
2018-12-07 18:16:46 +01:00
]);
2018-12-14 12:50:44 +01:00
$body = static::responseBody($response);
2018-12-07 18:16:46 +01:00
2019-02-19 15:59:27 +01:00
return [
'code' => $body['status'],
'message' => $body['message'],
];
2018-12-07 18:16:46 +01:00
} catch (UnexpectedValueException $e) {
}
2019-02-19 15:59:27 +01:00
return [
'code' => 400,
'message' => tr('Fattura non generata correttamente'),
];
2018-12-07 18:16:46 +01:00
}
}