Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace Packback\Lti1p3;
4
 
5
use Packback\Lti1p3\Helpers\Helpers;
6
 
7
class LtiNamesRolesProvisioningService extends LtiAbstractService
8
{
9
    public const CONTENTTYPE_MEMBERSHIPCONTAINER = 'application/vnd.ims.lti-nrps.v2.membershipcontainer+json';
10
 
11
    public function getScope(): array
12
    {
13
        return [LtiConstants::NRPS_SCOPE_MEMBERSHIP_READONLY];
14
    }
15
 
16
    /**
17
     * @param  array  $options  An array of options that can be passed with the context_membership_url such as rlid, since, etc.
18
     */
19
    public function getMembers(array $options = []): array
20
    {
21
        $url = Helpers::buildUrlWithQueryParams($this->getServiceData()['context_memberships_url'], $options);
22
 
23
        $request = new ServiceRequest(
24
            ServiceRequest::METHOD_GET,
25
            $url,
26
            ServiceRequest::TYPE_GET_MEMBERSHIPS
27
        );
28
        $request->setAccept(static::CONTENTTYPE_MEMBERSHIPCONTAINER);
29
 
30
        return $this->getAll($request, 'members');
31
    }
32
}