|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Mediapart LaPresseLibre Library. |
|
5
|
|
|
* |
|
6
|
|
|
* CC BY-NC-SA <https://github.com/mediapart/lapresselibre> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Mediapart\LaPresseLibre\Operation; |
|
13
|
|
|
|
|
14
|
|
|
use Mediapart\LaPresseLibre\Endpoint; |
|
15
|
|
|
use Mediapart\LaPresseLibre\Subscription\Type as SubscriptionType; |
|
16
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @see https://github.com/NextINpact/LaPresseLibreSDK/wiki/Fonctionnement-des-web-services#web-service-de-v%C3%A9rification-de-comptes-existants |
|
20
|
|
|
*/ |
|
21
|
|
|
class Verification extends Endpoint |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* {@inheritdoc} |
|
25
|
|
|
*/ |
|
26
|
|
|
protected function resolveInput(array $arguments) |
|
27
|
|
|
{ |
|
28
|
|
|
$resolver = new OptionsResolver(); |
|
29
|
|
|
$resolver->setDefaults([ |
|
30
|
|
|
'Mail' => null, |
|
31
|
|
|
'Password' => null, |
|
32
|
|
|
]); |
|
33
|
|
|
|
|
34
|
|
|
$resolver->setRequired('CodeUtilisateur'); |
|
35
|
|
|
$resolver->setAllowedTypes('Mail', ['string', 'null']); |
|
36
|
|
|
$resolver->setAllowedTypes('Password', ['string', 'null']); |
|
37
|
|
|
$resolver->setAllowedTypes('CodeUtilisateur', 'string'); |
|
38
|
|
|
|
|
39
|
|
|
return $resolver->resolve($arguments); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritdoc} |
|
44
|
|
|
*/ |
|
45
|
|
|
protected function resolveOutput(array $data) |
|
46
|
|
|
{ |
|
47
|
|
|
$resolver = new OptionsResolver(); |
|
48
|
|
|
$resolver->setDefaults([ |
|
49
|
|
|
'TypeAbonnement' => null, |
|
50
|
|
|
'DateExpiration' => null, |
|
51
|
|
|
'DateSouscription' => null, |
|
52
|
|
|
]); |
|
53
|
|
|
|
|
54
|
|
|
$resolver->setRequired(['Mail', 'CodeUtilisateur', 'AccountExist', 'PartenaireID']); |
|
55
|
|
|
$resolver->setAllowedTypes('Mail', 'string'); |
|
56
|
|
|
$resolver->setAllowedTypes('CodeUtilisateur', 'string'); |
|
57
|
|
|
$resolver->setAllowedValues('TypeAbonnement', array_merge(SubscriptionType::all(), [null])); |
|
58
|
|
|
$resolver->setAllowedTypes('DateExpiration', ['string', 'null']); |
|
59
|
|
|
$resolver->setAllowedTypes('DateSouscription', ['string', 'null']); |
|
60
|
|
|
$resolver->setAllowedTypes('AccountExist', ['boolean']); |
|
61
|
|
|
$resolver->setAllowedTypes('PartenaireID', 'int'); |
|
62
|
|
|
|
|
63
|
|
|
return $resolver->resolve($data); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|