server/src/app/Services/TranscriptManager.php
changeset 396 c8f651e7e4ff
parent 163 59c68fc4848e
equal deleted inserted replaced
395:b7d79db348e7 396:c8f651e7e4ff
    10     public function __construct(Client $client) {
    10     public function __construct(Client $client) {
    11         $this->client = $client;
    11         $this->client = $client;
    12     }
    12     }
    13 
    13 
    14 
    14 
    15     public function getConverterUrl(string $converterKey, Document $document, string $url) {
    15     public function getConverterUrl($converterKey, Document $document, $url) {
    16 
    16 
    17         $response = $this->client->get($url);
    17         $response = $this->client->get($url);
    18         $statusCode = $response->getStatusCode();
    18         $statusCode = $response->getStatusCode();
    19         if($statusCode < 200 || $statusCode > 299 ) {
    19         if($statusCode < 200 || $statusCode > 299 ) {
    20             throw new TranscriptManagerException("Can not get transcript content : $statusCode -> ".$response->getReasonPhrase());
    20             throw new TranscriptManagerException("Can not get transcript content : $statusCode -> ".$response->getReasonPhrase());
    22 
    22 
    23         return $this->getConverter($converterKey, $document, $response->getBody());
    23         return $this->getConverter($converterKey, $document, $response->getBody());
    24 
    24 
    25     }
    25     }
    26 
    26 
    27     public function getConverter(string $converterKey, Document $document, string $source) {
    27     public function getConverter($converterKey, Document $document, $source) {
    28 
    28 
    29         $converterClassMapping = config('corpusparole.transcrit_decoder_mapping');
    29         $converterClassMapping = config('corpusparole.transcrit_decoder_mapping');
    30         if(!array_key_exists($converterKey, $converterClassMapping)) {
    30         if(!array_key_exists($converterKey, $converterClassMapping)) {
    31             throw new TranscriptManagerException("Transcript type $converterKey doe not exists");
    31             throw new TranscriptManagerException("Transcript type $converterKey doe not exists");
    32         }
    32         }