-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssociation.php
More file actions
101 lines (89 loc) · 3.35 KB
/
Association.php
File metadata and controls
101 lines (89 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
namespace Qdequippe\Pappers\Api\Endpoint;
use Psr\Http\Message\ResponseInterface;
use Qdequippe\Pappers\Api\Exception\AssociationBadRequestException;
use Qdequippe\Pappers\Api\Exception\AssociationNotFoundException;
use Qdequippe\Pappers\Api\Exception\AssociationServiceUnavailableException;
use Qdequippe\Pappers\Api\Exception\AssociationUnauthorizedException;
use Qdequippe\Pappers\Api\Runtime\Client\BaseEndpoint;
use Qdequippe\Pappers\Api\Runtime\Client\Endpoint;
use Qdequippe\Pappers\Api\Runtime\Client\EndpointTrait;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Serializer\SerializerInterface;
class Association extends BaseEndpoint implements Endpoint
{
use EndpointTrait;
/**
* Vous devez fournir soit l'identifiant de l'association, soit le SIREN, soit le SIRET.
*
* @param array $queryParameters {
*
* @var string $id_association Identifiant de l'association
* @var string $siret SIRET de l'association
* @var string $siren SIREN de l'association
* }
*/
public function __construct(array $queryParameters = [])
{
$this->queryParameters = $queryParameters;
}
public function getMethod(): string
{
return 'GET';
}
public function getUri(): string
{
return '/association';
}
public function getBody(SerializerInterface $serializer, $streamFactory = null): array
{
return [[], null];
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
protected function getQueryOptionsResolver(): OptionsResolver
{
$optionsResolver = parent::getQueryOptionsResolver();
$optionsResolver->setDefined(['id_association', 'siret', 'siren']);
$optionsResolver->setRequired([]);
$optionsResolver->setDefaults([]);
$optionsResolver->addAllowedTypes('id_association', ['string']);
$optionsResolver->addAllowedTypes('siret', ['string']);
$optionsResolver->addAllowedTypes('siren', ['string']);
return $optionsResolver;
}
/**
* @return \Qdequippe\Pappers\Api\Model\Association|null
*
* @throws AssociationBadRequestException
* @throws AssociationUnauthorizedException
* @throws AssociationNotFoundException
* @throws AssociationServiceUnavailableException
*/
protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if ((null === $contentType) === false && (200 === $status && false !== mb_strpos(strtolower($contentType), 'application/json'))) {
return $serializer->deserialize($body, 'Qdequippe\Pappers\Api\Model\Association', 'json');
}
if (400 === $status) {
throw new AssociationBadRequestException($response);
}
if (401 === $status) {
throw new AssociationUnauthorizedException($response);
}
if (404 === $status) {
throw new AssociationNotFoundException($response);
}
if (503 === $status) {
throw new AssociationServiceUnavailableException($response);
}
}
public function getAuthenticationScopes(): array
{
return ['apiKey'];
}
}