|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the xAPI package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Client\Api; |
|
13
|
|
|
|
|
14
|
|
|
use Xabbuh\XApi\Model\ActivityProfile; |
|
15
|
|
|
use Xabbuh\XApi\Model\ActivityProfileDocument; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Client to access the activity profile API of an xAPI based learning record |
|
19
|
|
|
* store. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Christian Flothmann <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
final class ActivityProfileApiClient extends DocumentApiClient implements ActivityProfileApiClientInterface |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritDoc} |
|
27
|
|
|
*/ |
|
28
|
1 |
|
public function createOrUpdateDocument(ActivityProfileDocument $document) |
|
29
|
|
|
{ |
|
30
|
1 |
|
$this->doStoreActivityProfileDocument('post', $document); |
|
31
|
1 |
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritDoc} |
|
35
|
|
|
*/ |
|
36
|
1 |
|
public function createOrReplaceDocument(ActivityProfileDocument $document) |
|
37
|
|
|
{ |
|
38
|
1 |
|
$this->doStoreActivityProfileDocument('put', $document); |
|
39
|
1 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritDoc} |
|
43
|
|
|
*/ |
|
44
|
1 |
|
public function deleteDocument(ActivityProfile $profile) |
|
45
|
|
|
{ |
|
46
|
1 |
|
$this->doDeleteDocument('activities/profile', array( |
|
47
|
1 |
|
'activityId' => $profile->getActivity()->getId()->getValue(), |
|
48
|
1 |
|
'profileId' => $profile->getProfileId(), |
|
49
|
|
|
)); |
|
50
|
1 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* {@inheritDoc} |
|
54
|
|
|
*/ |
|
55
|
1 |
|
public function getDocument(ActivityProfile $profile) |
|
56
|
|
|
{ |
|
57
|
|
|
/** @var \Xabbuh\XApi\Model\DocumentData $documentData */ |
|
58
|
1 |
|
$documentData = $this->doGetDocument('activities/profile', array( |
|
59
|
1 |
|
'activityId' => $profile->getActivity()->getId()->getValue(), |
|
60
|
1 |
|
'profileId' => $profile->getProfileId(), |
|
61
|
|
|
)); |
|
62
|
|
|
|
|
63
|
1 |
|
return new ActivityProfileDocument($profile, $documentData); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Stores a state document. |
|
68
|
|
|
* |
|
69
|
|
|
* @param string $method HTTP method to use |
|
70
|
|
|
* @param ActivityProfileDocument $document The document to store |
|
71
|
|
|
*/ |
|
72
|
2 |
|
private function doStoreActivityProfileDocument($method, ActivityProfileDocument $document) |
|
73
|
|
|
{ |
|
74
|
2 |
|
$profile = $document->getActivityProfile(); |
|
75
|
2 |
|
$this->doStoreDocument( |
|
76
|
2 |
|
$method, |
|
77
|
2 |
|
'activities/profile', |
|
78
|
|
|
array( |
|
79
|
2 |
|
'activityId' => $profile->getActivity()->getId()->getValue(), |
|
80
|
2 |
|
'profileId' => $profile->getProfileId(), |
|
81
|
|
|
), |
|
82
|
2 |
|
$document |
|
83
|
|
|
); |
|
84
|
2 |
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|