1 | <?php |
2 | |
3 | require_once __DIR__ . "/../lib/php/BAD_REQUEST.php"; |
4 | require_once __DIR__ . "/../lib/php/validaJson.php"; |
5 | require_once __DIR__ . "/../lib/php/ProblemDetails.php"; |
6 | require_once __DIR__ . "/Suscripcion.php"; |
7 | |
8 | function suscripcionRecupera($objeto) |
9 | { |
10 | |
11 | $objeto = validaJson($objeto); |
12 | |
13 | if (!isset($objeto->publicKey) || !is_string($objeto->publicKey)) |
14 | throw new ProblemDetails( |
15 | type: "/error/publickeyincorrecta.html", |
16 | status: BAD_REQUEST, |
17 | title: "La publicKey debe ser texto.", |
18 | ); |
19 | |
20 | if (!isset($objeto->authToken) || !is_string($objeto->authToken)) |
21 | throw new ProblemDetails( |
22 | type: "/error/authtokenincorrecto.html", |
23 | status: BAD_REQUEST, |
24 | title: "El authToken debe ser texto.", |
25 | ); |
26 | |
27 | if (!isset($objeto->contentEncoding) || !is_string($objeto->contentEncoding)) |
28 | throw new ProblemDetails( |
29 | type: "/error/contentencodingincorrecta.html", |
30 | status: BAD_REQUEST, |
31 | title: "La contentEncoding debe ser texto.", |
32 | ); |
33 | |
34 | return new Suscripcion( |
35 | endpoint: $objeto->endpoint, |
36 | publicKey: $objeto->publicKey, |
37 | authToken: $objeto->authToken, |
38 | contentEncoding: $objeto->contentEncoding |
39 | ); |
40 | } |
41 | |