Skip to content

Commit

Permalink
Merge pull request #29 from apidae-tourisme/dev
Browse files Browse the repository at this point in the history
Ajout API Collaborateurs
  • Loading branch information
PierreGranger authored Feb 17, 2023
2 parents 86803a3 + 0719219 commit 68dc03d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 7 deletions.
25 changes: 25 additions & 0 deletions examples/collaborateurs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use ApidaePHP\Exception\ApidaeException;

$config = [];
require __DIR__ . "/requires.inc.php";

$client = new \ApidaePHP\Client($config);

$referenceId = 4640947;

try {
$collaborateurs = $client->getCollaborateurs([
'query' => ['referenceIds' => [$referenceId]]
]);
var_dump($collaborateurs) ;
} catch (ApidaeException $e) {
echo $e->getcode() ;
echo $e->getMessage() ;
die() ;
} catch (Exception $e) {
echo $e->getcode() ;
echo $e->getMessage() ;
die() ;
}
16 changes: 9 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use ApidaePHP\Exception\ApidaeException;
use GuzzleHttp\Command\CommandInterface;
use GuzzleHttp\Command\Guzzle\Operation;
use ApidaePHP\Description\Collaborateurs;
use GuzzleHttp\Client as GuzzleHttpClient;
use GuzzleHttp\Command\Guzzle\Description;
use ApidaePHP\Description\TouristicObjects;
Expand Down Expand Up @@ -1410,14 +1411,14 @@ class Client extends GuzzleClient
use Export;
use ApidaeSso;

const NAME = 'apidae-php';
const VERSION = '2.0.0';
public const NAME = 'apidae-php';
public const VERSION = '2.0.0';

const META_SCOPE = 'api_metadonnees';
const SSO_SCOPE = 'sso';
const EDIT_SCOPE = 'api_ecriture';
public const META_SCOPE = 'api_metadonnees';
public const SSO_SCOPE = 'sso';
public const EDIT_SCOPE = 'api_ecriture';

const ENVIRONMENTS = [
public const ENVIRONMENTS = [
'prod' => [
'baseUri' => 'https://api.apidae-tourisme.com/',
'ssoBaseUrl' => 'https://base.apidae-tourisme.com'
Expand Down Expand Up @@ -1502,6 +1503,7 @@ public function __construct(array $config = [])

$this->operations = array_merge(
Agenda::$operations,
Collaborateurs::$operations,
Edit::$operations,
Exports::$operations,
Member::$operations,
Expand Down Expand Up @@ -1616,7 +1618,7 @@ public function __call($method, array $args): array|string
return $match[1];
}
}

if (! is_array($result) && preg_match('#^Guzzle.*Result$#', get_class($result))) {
return $result->toArray() ;
}
Expand Down
36 changes: 36 additions & 0 deletions src/Description/Collaborateurs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace ApidaePHP\Description;

class Collaborateurs extends AbstractDescriptions
{
/** @var array<mixed> $operations */
public static array $operations = array(
'postCollaborateurs' => [
'httpMethod' => 'POST',
'uri' => '/api/v002/collaborateurs/',
'documentationUrl' => 'https://dev.apidae-tourisme.com/documentation-technique/v2/api-decriture/v002-collaborateurs/',
'responseModel' => 'getResponse',
'parameters' => [
'query' => [
'type' => 'string',
'location' => 'formParam',
'required' => true
],
],
],
'getCollaborateurs' => [
'httpMethod' => 'GET',
'uri' => '/api/v002/collaborateurs/',
'documentationUrl' => 'https://dev.apidae-tourisme.com/documentation-technique/v2/api-de-diffusion/liste-des-services/v002-collaborateurs/',
'responseModel' => 'getResponse',
'parameters' => [
'query' => [
'type' => 'string',
'location' => 'formParam',
'required' => true
],
],
]
);
}

0 comments on commit 68dc03d

Please sign in to comment.