-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from studoo-app/develop
v0.1.3
- Loading branch information
Showing
13 changed files
with
116 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: "3.8" | ||
services: | ||
mock-ecole-directe-api: | ||
container_name: mock-ecole-directe-api | ||
image: bfoujols/mock-api-ecole-directe | ||
ports: | ||
- "9042:80" | ||
restart: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Studoo\Api\EcoleDirecte\Client; | ||
use Symfony\Component\Dotenv\Dotenv; | ||
|
||
/** | ||
* Mise en place de l'environnement de développement via DotEnv | ||
* via le fichier .env à la racine du projet | ||
* Renseigner les variables ENV | ||
* Pour faire fonctionner le Docker, il faut renseigner ENV=test | ||
* Dans la classe Client, il faut renseigner le base_path "http://localhost:9042" (adresse du serveur Docker) | ||
* Voir https://github.com/studoo-app/mock-ecole-directe-api | ||
*/ | ||
|
||
$dotenv = new Dotenv(); | ||
$dotenv->loadEnv(__DIR__ . '/../.env'); | ||
|
||
if (isset($_POST['username']) && isset($_POST['password'])) { | ||
$client = new Client([ | ||
"base_path" => "http://localhost:9042", | ||
"client_id" => $_POST['username'], | ||
"client_secret" => $_POST['password'], | ||
]); | ||
// Recupération du token et profile | ||
$etudiant = $client->fetchAccessToken(); | ||
echo "Token: {$etudiant->getToken()} <br>"; | ||
echo "Email: {$etudiant->getEmail()} <br>"; | ||
echo "Nom: {$etudiant->getNom()} <br>"; | ||
echo "Prenom: {$etudiant->getPrenom()} <br>"; | ||
echo "Identifiant: {$etudiant->getIdentifiant()} <br>"; | ||
} else { | ||
echo "<h1>API ECOLE DIRECTE via Form</h1>"; | ||
echo "<form method='post'>"; | ||
echo "<label for='username'> Username </label>"; | ||
echo "<input type='text' name='username' id='username' required>"; | ||
echo "<label for='password'> Password </label>"; | ||
echo "<input type='password' name='password' id='password' required>"; | ||
echo "<input type='submit' value='Envoyer'>"; | ||
echo "</form>"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use Studoo\Api\EcoleDirecte\Client; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ClientTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @throws \Studoo\Api\EcoleDirecte\Exception\InvalidModelException | ||
*/ | ||
public function testFetchAccessToken() | ||
{ | ||
$_ENV["ENV"] = "test"; | ||
|
||
$client = new Client([ | ||
"base_path" => "http://localhost:9042", | ||
"client_id" => "jeremy", | ||
"client_secret" => "test", | ||
]); | ||
$this->assertEquals('7654-5678-43345-80R8-54324', $client->fetchAccessToken()->getToken()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters