openstamanager/plugins/exportFE/src/Interaction.php

37 lines
887 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();
2018-12-14 12:50:44 +01:00
$response = static::request('POST', 'send_xml', [], [
2018-12-07 18:16:46 +01:00
'multipart' => [
[
2018-12-23 14:01:59 +01:00
'name' => 'xml',
2018-12-14 12:50:44 +01:00
'filename' => $fattura->getFilename(),
2018-12-23 14:01:59 +01:00
'contents' => file_get_contents($file),
2018-12-07 18:16:46 +01:00
],
2018-12-23 14:01:59 +01:00
],
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-01-22 08:59:11 +01:00
return $body;
2018-12-07 18:16:46 +01:00
} catch (UnexpectedValueException $e) {
}
2018-12-14 12:50:44 +01:00
return false;
2018-12-07 18:16:46 +01:00
}
}