Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
prytoegrian committed Nov 5, 2017
2 parents 4f6c333 + 2146fe6 commit 3f012b0
Show file tree
Hide file tree
Showing 1,912 changed files with 257,109 additions and 5,252 deletions.
6 changes: 6 additions & 0 deletions .bettercodehub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
exclude:
- /vendor/.*
- /Public/Assets/.*
component_depth: 1
languages:
- php
6 changes: 5 additions & 1 deletion .bootstrap.atoum.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php
/* Autoload */
define('ROOT_PATH', '');
define('NIL_INT', -1);
define('NIL_INT', -1);
define('DS', DIRECTORY_SEPARATOR);
define('_PHP_CONGES', 1);
define('API_SYSPATH', DS . 'tmp' . DS);
define('API_PATH', '');
require_once ROOT_PATH . 'vendor/autoload.php';
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[Bug] Pour nous aider à corriger le bug dans les meilleures conditions, merci de prendre le temps de détailler ces quelques points
[Uniquement pour les bugs]

### Système et application

* Système d'exploitation :
* Système d'exploitation du serveur :
* Serveur HTTP et version :
* Version MySQL et PHP :
* Version MySQL et PHP :
* Navigateur et version :
* Version de l'application :
* Avez-vous des notifications dans la console du navigateur :
* Avez-vous des notifications dans la console du navigateur :
* Avez-vous des erreurs dans le log du serveur http (ex : /var/log/apache2) :

* Méthodes de connexion [interne / ldap / sso] :

### Reproduction du bug

* Prérequis :
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
api/.htaccess
tags
debug/
cfg/env.php
Expand All @@ -7,3 +8,4 @@ cfg/config_SMTP.php
.idea/
/nbproject/
/dump/*.dump
/backup/libertempo*
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
language: php
php:
- '5.5'
- '5.6'
- '7.0'
notifications:
irc: "irc.tuxfamily.org#Libertempo"
before_script: composer require atoum/atoum
script: vendor/bin/atoum
6 changes: 6 additions & 0 deletions App/Exceptions/NotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
namespace App\Exceptions;

class NotFoundException extends \Exception
{
}
147 changes: 147 additions & 0 deletions App/Libraries/ApiClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?php
namespace App\Libraries;

use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7;
use GuzzleHttp\Exception;

/**
* Classe de consommation de l'API ; is immutable
*
* @author Prytoegrian <[email protected]>
* @author Wouldsmina
* @since 1.9
*/
final class ApiClient
{
/**
* @var ClientInterface Client de la requête
*/
private $client;

/**
* @param ClientInterface $client Client de la requête
*
* @throws \RuntimeException if infrastructure pre-conditions aren't fulfilled
*/
public function __construct(ClientInterface $client)
{
if (!extension_loaded('curl')) {
if (false === ini_set('allow_url_fopen', true)) {
throw new \RuntimeException('cURL or allow_url_fopen are required');
}
}
$this->client = $client;
}

/**
* Effectue l'ordre Http GET
*
* @param string $uri URI relative de la ressource
*
* @return \stdClass Au format Jsend
*/
public function get($uri)
{
return $this->request('GET', $uri, []);
}

/**
* Récupère un token de l'API avec le connecteur DBConges
*
* @param string $login Login de l'utilisateur LT
* @param string $password MDP de l'utilisateur LT
*
* @return \stdClass Au format Jsend
*/
public function authentifyDbConges($login, $password)
{
return $this->authentifyCommon($login, $password);
}

/**
* Récupère un token de l'API avec le connecteur tierce
*
* @param string $login Login de l'utilisateur LT
*
* @return \stdClass Au format Jsend
*/
public function authentifyThirdParty($login)
{
return $this->authentifyCommon($login, 'none');
}

/**
* Récupère un token de l'API pour les futurs échanges
*
* @param string $login Login de l'utilisateur LT
* @param string $password MDP de l'utilisateur LT
*
* @return \stdClass Au format Jsend
*/
private function authentifyCommon($login, $password)
{
$options = [
'headers' => [
'Authorization' => 'Basic ' . base64_encode($login . ':' . $password),
],
];
return $this->request('GET', 'authentification', $options);
}

/**
* Effectue une requête HTTP
*
* @param string $method Ordre HTTP
* @param string $uri URI relative de la ressource
* @param array $options Options de requête
* @example ['headers' => [], 'body' => []]
*
* @return \stdClass Au format Jsend
* @throws \LogicException Si la requête est mal formée (Http4XX)
*/
private function request($method, $uri, array $options)
{
$json = 'application/json';
$options = array_merge_recursive($options, [
'headers' => [
'Content-Type' => $json,
'Accept' => $json,
],
]);
try {
$response = $this->client->request($method, $uri, $options);
} catch (Exception\ServerException $e) {
throw new \RuntimeException('Erreur serveur : '. $this->formatError($e));
} catch (Exception\ClientException $e) {
throw new \LogicException('Erreur client : '. $this->formatError($e));
}

$body = json_decode($response->getBody(), false);
if (null === $body) {
throw new \RuntimeException('La réponse n\'est pas du JSON');
}

return $body;
}

/**
* Formate les erreurs pour afficher les informations nécessaires à la correction
*
* @param \Exception $exception
*
* @return string
*/
private function formatError(\Exception $exception)
{
return 'Request -> ' . Psr7\str($exception->getRequest()) . ' | Response <- ' . Psr7\str($exception->getResponse());
}

/**
* Clonage interdit
*/
public function __clone()
{
throw new \LogicException('Clonage interdit');
}
}
42 changes: 0 additions & 42 deletions App/Libraries/Calendrier/ACollection.php

This file was deleted.

125 changes: 0 additions & 125 deletions App/Libraries/Calendrier/BusinessCollection.php

This file was deleted.

Loading

0 comments on commit 3f012b0

Please sign in to comment.