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