Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit 6301ee9

Browse files
committed
Merge pull request #4421 from weerd/kudos-endpoint
Adding new targeted action endpoint for Kudos.
2 parents 3135e61 + ee3a3ef commit 6301ee9

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

lib/modules/dosomething/dosomething_api/resources/reportback_item_resource.inc

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function _reportback_item_resource_definition() {
1010
'file' => array(
1111
'type' => 'inc',
1212
'module' => 'dosomething_api',
13-
'name' => 'resources/reportback_item_resource'
13+
'name' => 'resources/reportback_item_resource',
1414
),
1515
'callback' => '_reportback_item_resource_retrieve',
1616
'args' => array(
@@ -80,6 +80,50 @@ function _reportback_item_resource_definition() {
8080

8181
),
8282

83+
'targeted_actions' => array(
84+
85+
'kudos' => array(
86+
'help' => 'Register a kudos action being applied to a reportback item.',
87+
'file' => array(
88+
'type' => 'inc',
89+
'module' => 'dosomething_api',
90+
'name' => 'resources/reportback_item_resource',
91+
),
92+
'callback' => '_reportback_item_resource_kudos',
93+
'args' => array(
94+
array(
95+
'name' => 'fid',
96+
'description' => 'The reportback item file ID.',
97+
'optional' => FALSE,
98+
'type' => 'int',
99+
'source' => array(
100+
'path' => 0
101+
),
102+
),
103+
array(
104+
'name' => 'user_id',
105+
'description' => 'The ID of the user executing a kudos.',
106+
'optional' => FALSE,
107+
'type' => 'int',
108+
'source' => array(
109+
'data' => 'user_id',
110+
),
111+
),
112+
array(
113+
'name' => 'term_ids',
114+
'description' => 'An array of kudos term IDs.',
115+
'optional' => FALSE,
116+
'type' => 'array',
117+
'source' => array(
118+
'data' => 'term_ids',
119+
),
120+
),
121+
),
122+
'access callback' => '_reportback_item_resource_access',
123+
),
124+
125+
),
126+
83127
);
84128

85129
return $reportback_item_resource;
@@ -110,4 +154,16 @@ function _reportback_item_resource_index($campaigns, $status, $count, $random, $
110154
function _reportback_item_resource_retrieve($fid) {
111155
$reportbackItems = new ReportbackItem;
112156
return $reportbackItems->show($fid);
157+
}
158+
159+
160+
function _reportback_item_resource_kudos($fid, $user_id, $term_ids) {
161+
$parameters = array(
162+
'fid' => $fid,
163+
'uid' => $user_id,
164+
'tids' => $term_ids,
165+
);
166+
167+
// @TODO: temporarily returning back the header body data for testing.
168+
return $parameters;
113169
}

0 commit comments

Comments
 (0)