<?php
namespace API\InfoLegale\Traits;

trait Compagny
{
    
    
    public function compagny(string $siren, string $country)
    {
        try {
            $response = $this->client->get($this->urlApi.'companies/'.$country.'/'.$siren, [
            
                    'headers' => [
                        'Authorization' => 'Bearer '. $this->token
                    ],

                ]);

            $this->code = $response->getStatusCode();
            $this->header = $response->getHeaderLine('content-type');
            
            return json_decode($response->getBody()->getContents(), true);
        } catch (\Exception $e) {
            return [];
        }
    }

    public function sites(string $siren, string $country)
    {
        try {
            $response = $this->client->get($this->urlApi.'companies/'.$country.'/'.$siren.'/sites', [
            
                    'headers' => [
                        'Authorization' => 'Bearer '. $this->token
                    ],

                ]);

            $this->code = $response->getStatusCode();
            $this->header = $response->getHeaderLine('content-type');
            
            return json_decode($response->getBody()->getContents(), true);
        } catch (\Exception $e) {
            return [];
        }
    }
}
