Just getting started with Services so this is probably an easy question.
I'm attempting to allow users to access their private messages from a web app using this sandbox module. At this point, after referring to the documentation on testing resources, I can get a JSON collection of the messages when I visit http://example.com/drupalgap/privatemsg, and I can get a specific thread if I visit http://example.com/drupalgap/privatemsg/threadID.
I understand the basic syntax is example.com + endpoint (drupalgap) + resource (privatemsg) + query.
However, the sandbox module includes a function for getting the number of unread messages, which I would like to do. Here's the code:
/**
* Get the number of unread private messages of the logged-in user.
*
* @param int $uid
* User ID.
*
* @return int
* The unread count.
*/
function _privatemsg_services_unread_count($uid = '') {
global $user;
if (!user_is_logged_in()) {
return services_error(t('This user is not logged in.'), 403);
}
/*
* If a user id other than the current user's ID is passed, validate that the
* authenticated user has the correct permissions to read another user's
* messages.
*/
if (is_numeric($uid) && ($uid != $user->uid)) {
if (user_access("read all private messages")) {
$account = user_load($uid);
}
else {
return services_error(
t('This user does not have permissions to use this service.'),
403
);
}
}
else {
$account = $user;
}
// Return unread count.
return privatemsg_unread_count($account);
}
My question is, how do I call this with services? I've tried things like http://example.com/drupalgap/privatemsg/unread_count/ and http://example.com/drupalgap/privatemsg_unread_count but I get no results.