| 1441 |
ariadna |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace core_user\route\responses;
|
|
|
18 |
|
|
|
19 |
use core\param;
|
|
|
20 |
use core\router\schema\response\content\payload_response_type;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* A standard response for user preferences.
|
|
|
24 |
*
|
|
|
25 |
* @package core_user
|
|
|
26 |
* @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>
|
|
|
27 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
28 |
*/
|
|
|
29 |
class user_preferences_response extends \core\router\schema\response\response {
|
|
|
30 |
/**
|
|
|
31 |
* Constructor for a standard user preference response.
|
|
|
32 |
*/
|
|
|
33 |
public function __construct() {
|
|
|
34 |
parent::__construct(
|
|
|
35 |
content: new payload_response_type(
|
|
|
36 |
schema: new \core\router\schema\objects\array_of_strings(
|
|
|
37 |
keyparamtype: param::TEXT,
|
|
|
38 |
valueparamtype: param::RAW,
|
|
|
39 |
),
|
|
|
40 |
examples: [
|
|
|
41 |
new \core\router\schema\example(
|
|
|
42 |
name: 'A single preference value',
|
|
|
43 |
summary: 'A json response containing a single preference',
|
|
|
44 |
value: [
|
|
|
45 |
"drawers-open-index" => "1",
|
|
|
46 |
],
|
|
|
47 |
),
|
|
|
48 |
new \core\router\schema\example(
|
|
|
49 |
name: 'A set of preference values',
|
|
|
50 |
summary: 'A json response containing a set of preferences',
|
|
|
51 |
value: [
|
|
|
52 |
"drawers-open-index" => "1",
|
|
|
53 |
"login_failed_count_since_success" => "1",
|
|
|
54 |
"coursesectionspreferences_2" => "{\"contentcollapsed\":[]}",
|
|
|
55 |
],
|
|
|
56 |
),
|
|
|
57 |
]
|
|
|
58 |
),
|
|
|
59 |
);
|
|
|
60 |
}
|
|
|
61 |
}
|