Proyectos de Subversion Moodle

Rev

| 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
/**
18
 * Google Drive Rest API.
19
 *
20
 * @package    fileconverter_googledrive
21
 * @copyright  2017 Damyon Wiese
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
namespace fileconverter_googledrive;
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
/**
29
 * Google Drive Rest API.
30
 *
31
 * @copyright  2017 Damyon Wiese
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
34
class rest extends \core\oauth2\rest {
35
 
36
    /**
37
     * Define the functions of the rest API.
38
     *
39
     * @return array Example:
40
     *  [ 'listFiles' => [ 'method' => 'get', 'endpoint' => 'http://...', 'args' => [ 'folder' => PARAM_STRING ] ] ]
41
     */
42
    public function get_api_functions() {
43
        return [
44
            'upload' => [
45
                'endpoint' => 'https://www.googleapis.com/upload/drive/v3/files',
46
                'method' => 'post',
47
                'args' => [
48
                    'uploadType' => PARAM_RAW,
49
                    'fields' => PARAM_RAW
50
                ],
51
                'response' => 'headers'
52
            ],
53
            'upload_content' => [
54
                'endpoint' => '{uploadurl}',
55
                'method' => 'put',
56
                'args' => [
57
                    'uploadurl' => PARAM_URL
58
                ],
59
                'response' => 'json'
60
            ],
61
            'create' => [
62
                'endpoint' => 'https://www.googleapis.com/drive/v3/files',
63
                'method' => 'post',
64
                'args' => [
65
                    'fields' => PARAM_RAW
66
                ],
67
                'response' => 'json'
68
            ],
69
            'delete' => [
70
                'endpoint' => 'https://www.googleapis.com/drive/v3/files/{fileid}',
71
                'method' => 'delete',
72
                'args' => [
73
                    'fileid' => PARAM_RAW
74
                ],
75
                'response' => 'json'
76
            ],
77
        ];
78
    }
79
}