mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-09 00:24:37 -04:00
Add legal entity
This commit is contained in:
parent
5f43c5e2a2
commit
bc1510582e
83
app/DataMapper/Analytics/LegalEntityCreated.php
Normal file
83
app/DataMapper/Analytics/LegalEntityCreated.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataMapper\Analytics;
|
||||||
|
|
||||||
|
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
|
||||||
|
|
||||||
|
class LegalEntityCreated extends GenericMixedMetric
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The type of Sample.
|
||||||
|
*
|
||||||
|
* Monotonically incrementing counter
|
||||||
|
*
|
||||||
|
* - counter
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $type = 'mixed_metric';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the counter.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name = 'einvoice.legal_entity.created';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The datetime of the counter measurement.
|
||||||
|
*
|
||||||
|
* date("Y-m-d H:i:s")
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public $datetime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class failure name
|
||||||
|
* set to 0.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $string_metric5 = 'stub';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exception string
|
||||||
|
* set to 0.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $string_metric6 = 'stub';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The counter
|
||||||
|
* set to 1.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public $int_metric1 = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Company Key
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $string_metric7 = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subject
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $string_metric8 = '';
|
||||||
|
|
||||||
|
public function __construct($string_metric7 = '', $string_metric8 = '')
|
||||||
|
{
|
||||||
|
$this->string_metric7 = $string_metric7;
|
||||||
|
$this->string_metric8 = $string_metric8;
|
||||||
|
}
|
||||||
|
}
|
@ -11,11 +11,13 @@
|
|||||||
|
|
||||||
namespace App\Services\EDocument\Gateway\Storecove;
|
namespace App\Services\EDocument\Gateway\Storecove;
|
||||||
|
|
||||||
|
use App\DataMapper\Analytics\LegalEntityCreated;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use GuzzleHttp\Exception\ServerException;
|
use GuzzleHttp\Exception\ServerException;
|
||||||
use Illuminate\Http\Client\RequestException;
|
use Illuminate\Http\Client\RequestException;
|
||||||
|
use Turbo124\Beacon\Facades\LightLogs;
|
||||||
|
|
||||||
enum HttpVerb: string
|
enum HttpVerb: string
|
||||||
{
|
{
|
||||||
@ -240,6 +242,8 @@ class Storecove
|
|||||||
public function getLegalEntity($id)
|
public function getLegalEntity($id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// $uri = "legal_entities";
|
||||||
|
|
||||||
$uri = "legal_entities/{$id}";
|
$uri = "legal_entities/{$id}";
|
||||||
|
|
||||||
$r = $this->httpClient($uri, (HttpVerb::GET)->value, []);
|
$r = $this->httpClient($uri, (HttpVerb::GET)->value, []);
|
||||||
@ -297,7 +301,11 @@ class Storecove
|
|||||||
$r = $this->httpClient($uri, (HttpVerb::POST)->value, $data);
|
$r = $this->httpClient($uri, (HttpVerb::POST)->value, $data);
|
||||||
|
|
||||||
if($r->successful()) {
|
if($r->successful()) {
|
||||||
return $r->json();
|
$data = $r->json();
|
||||||
|
|
||||||
|
LightLogs::create(new LegalEntityCreated($data['id'], $legal_entity_id))->batch();
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
@ -347,10 +355,7 @@ class Storecove
|
|||||||
nlog("Server error: " . $e->getMessage());
|
nlog("Server error: " . $e->getMessage());
|
||||||
nlog("Response body: " . $e->getResponse()->getBody()->getContents());
|
nlog("Response body: " . $e->getResponse()->getBody()->getContents());
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
nlog("Request error: " . $e->getMessage());
|
nlog("Request error: {$e->getCode()}: " . $e->getMessage());
|
||||||
if ($e->hasResponse()) {
|
|
||||||
nlog("Response body: " . $e->getResponse()->getBody()->getContents());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user