Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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_badges\external;
18
 
19
defined('MOODLE_INTERNAL') || die();
20
 
21
use core\external\exporter;
22
 
23
/**
24
 * Class for displaying a badge competency.
25
 *
26
 * @package   core_badges
27
 * @copyright 2019 Damyon Wiese
28
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 */
30
class issuer_exporter extends exporter {
31
 
32
    /**
1441 ariadna 33
     * Map data depending on the version.
1 efrain 34
     *
1441 ariadna 35
     * @param \stdClass $data The remote data.
1 efrain 36
     * @param string $apiversion The backpack version used to communicate remotely.
1441 ariadna 37
     * @return \stdClass
1 efrain 38
     */
39
    public static function map_external_data($data, $apiversion) {
40
        $mapped = new \stdClass();
41
        if (isset($data->entityType)) {
42
            $mapped->type = $data->entityType;
43
        } else {
44
            $mapped->type = $data->type;
45
        }
46
        if (isset($data->entityId)) {
47
            $mapped->id = $data->entityId;
48
        } else {
49
            $mapped->id = $data->id;
50
        }
51
        $mapped->name = $data->name;
52
        $mapped->email = $data->email;
53
        $mapped->url = $data->url;
54
        return $mapped;
55
    }
56
 
57
    /**
58
     * Return the list of properties.
59
     *
60
     * @return array
61
     */
62
    protected static function define_properties() {
63
        return [
64
            'type' => [
65
                'type' => PARAM_ALPHA,
66
                'description' => 'Issuer',
67
            ],
68
            'id' => [
69
                'type' => PARAM_RAW,
70
                'description' => 'Unique identifier for this issuer',
71
            ],
72
            'name' => [
73
                'type' => PARAM_TEXT,
74
                'description' => 'Name of the issuer',
75
            ],
76
            'email' => [
77
                'type' => PARAM_EMAIL,
78
                'description' => 'Email of the issuer',
79
            ],
80
            'url' => [
81
                'type' => PARAM_URL,
82
                'description' => 'URL for this issuer',
83
            ],
84
        ];
85
    }
86
 
87
    /**
88
     * Returns a list of objects that are related.
89
     *
90
     * @return array
91
     */
92
    protected static function define_related() {
93
        return array(
94
            'context' => 'context',
95
        );
96
    }
97
}