h3. activity {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity}

h4. POST activity.*format*{anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.Post}

*Description*: Creates an activity to an identity's activity stream. If no _{noformat}identity_id{noformat}_ is specified, the activity will be created to the authenticated identity's activity stream.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity.json]

*Body Data*: The data for an activity

For example:
{code}
{
"title": "Hello World", //required
"type": "exosocial:core", //optional
"priority": 0.5, //optional
"titleId": "", //optional
"templateParams": {} //optional
}
{code}

*Supported Format*: json

*Requires Authentication*: true

*Parameters*:
* *Optional*
** *{noformat}identity_id{noformat}*: The identity who posts activities to his stream, to the stream of his connection or the space stream where he is a manager or a member.
*Examples*
* *JSON*

*Request*:

{code}
POST: http://localhost:8080/rest/private/api/social/v1-alpha3/socialdemo/activity.json
HEADER: Content-Type: application/json
BODY: {"title": "Hello World!!!"}
{code}

*Response*: A list of activity objects in the JSON format.

{code:json}
{
  "appId":"",
  "identityId":"423c28dac0a80137186cb6150f481c8c",
  "totalNumberOfComments":0,
  "liked":false,
  "templateParams":{},
  "postedTime":1315383441216,
  "type":"",
  "posterIdentity":{},
  "activityStream":"",
  "id":"42f6786cc0a80137337a0b28ebe6af73",
  "title":"Hello World!!!",
  "priority":0,
  "createdAt":"Wed Sep 7 15:17:21 +0700 2011",
  "likedByIdentities":[],
  "titleId":"",
  "body": "",
  "comments":[]
}
{code}

h4. GET activity/:activityId.format {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.Get}

*Description*: Gets an activity object from a specified activity Id.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e6f7g8h9i.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e6f7g8h9i.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*:
* *Required*
** *id*: the Id of the existing activity.
* *Optional*
** *{noformat}poster_identity{noformat}*: When this parameter is set to *true*, *t* or *1*, the returned activity will provide more information for the user who posted this activity.
** *{noformat}number_of_comments{noformat}*: Specifies the number of the latest comments to be displayed along with this activity. By default, _{noformat}number_of_comments=0{noformat}_. If _{noformat}number_of_comments{noformat}_ is a positive number, this number is considered as a limit number that must be equal or less than 100. If the total number of comments is less than the provided positive number, the total number of comments must be returned. If the total number of comments is more than 100, it is recommended to use _activity/:id/comments.format_ instead.
** *{noformat}number_of_likes{noformat}*: Specifies the number of the latest detailed likes to be returned along with this activity. By default, _{noformat}number_of_likes=0{noformat}_. If _{noformat}number_of_likes{noformat}_ is a positive number, this number is considered as a limit number that must be equal or less than 100. If the total number of likes is less than the provided positive number, the  total number of likes must be returned. If the total number of likes is more than 100, it is recommended to use _activity/:activityId/likes.format_ instead.
** *{noformat}activity_stream{noformat}*: When this parameter is set to *true*, *t* or *1*, the returned activity will provide more information for the activity stream that this activity belongs to.

*Examples*:
* *JSON*

*Request*:

{code:}
GET: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e6f7g8h9i.json?poster_identity=t&number_of_comments=10&number_of_likes=5&activity_stream=t
{code}

*Response*:
{code:json}
{
"id": "1a2b3c4d5e6f7g8h9j",
"title": "Hello World!!!",
"appId": "",
"type": "DEFAULT_ACTIVITY",
"postedTime": 123456789, //timestamp
"createdAt": "Fri Jun 17 06:42:26 +0000 2011", //The Date follows ISO 8601
"priority": 0.5, //between 0.0 and 1.0, higher value => higher priority.
"templateParams": {},
"titleId": "",
"identityId": "123456789abcdefghi", //the identity id of the user who created this activity
"liked": true, //is liked (favorites) by this authenticated identity
"likedByIdentities": [{"id":1234567, "providerId":"organization", "remoteId":"demo", "profile":{"fullName":"Demo GTN", "avatarUrl":"http://localhost:8080/profile/u/demo/avatar.jpg?u=12345"}}],
"totalNumberOfLikes": 20
"posterIdentity": {"id":1234567, "providerId":"organization", "remoteId":"demo", "profile":{"fullName":"Demo GTN", "avatarUrl":"http://localhost:8080/profile/u/demo/avatar.jpg?u=12345"}}, //optional
"comments": [{}], //optional
"totalNumberOfComments": 1234,
"activityStream": {
"type": "user", // or "space"
"prettyId": "root", // or space_abcde
"fullName": "Root Root",
"faviconUrl": "http://demo3.exoplatform.org/favicons/exo-default.jpg",
"title": "Activity Stream of Root Root",
"body": "",
"permaLink": "http://localhost:8080/profile/root"
} //optional
}
{code}


h4. DELETE activity/:activityId.format {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.Delete}

*Description*: Deletes an existing activity by its Id using the DELETE method. The deleted activity information will be returned in the specified format.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId.format{code}

For example:
* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e6f7g8h9i.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e6f7g8h9i.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*:
* *Required*
** *id*: The Id of the existing activity.

*Examples*
* *JSON*
*Request*:

{code:}
DELETE: http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e6f7g8h9i.json
{code}

*Response*:

{code:json}
{
"id": "1a2b3c4d5e6f7g8h9i"
}
{code}

h4. POST activity/destroy/:activityId.format  {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.PostDelete.}

*Description*: Deletes an existing activity by its Id using the POST method. The deleted activity information will be returned in the specified format. It is recommended to use the DELETE method, except the case that clients cannot make request via this method.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/destroy/:activityId.format{code}

For example:

[http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/destroy/1a2b3c4d5e6f7g8h9i.json]

[http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/destroy/1a2b3c4d5e6f7g8h9i.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:

{code}
POST: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/destroy/1a2b3c4d5e6f7g8h9i.json
{code}

*Response*:

{code:json}
{
"id": "1a2b3c4d5e6f7g8h9i"
}
{code}


h3. activity/:activityId/comments {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activitycomments}

h4. GET activity/:activityId/comments.format {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activitycomments.Get}

*Description*: Gets all comments on an activity.

*URL*:
{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId/comments.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/comments.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/comments.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:

{code}
GET: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e/comments.json
{code}

*Response*: A list of comment objects in the JSON format.

{code}
{
  totalNumberOfComments: 2,
  comments: [
  {
    "id": "123456"
    "posterIdentity": {"id":123456, "providerId":"organization", "remoteId":"demo", "profile":{"fullName":"Demo GTN", "avatarUrl":"http://localhost:8080/profile/u/demo/avatar.jpg?u=12345"}},
    "text": "Comment there!",
    "postedTime": 123456789,
    "createdAt": "Fri Jun 17 06:42:26 +0000 2011"
  },
  {
    "id" : "234567"
    "posterIdentity": {"id":123456, "providerId":"organization", "remoteId":"demo", "profile":{"fullName":"Demo GTN", "avatarUrl":"http://localhost:8080/profile/u/demo/avatar.jpg?u=12345"}},
    "text": "Comment there 2!",
    "postedTime": 123456789,
    "createdAt": "Fri Jun 17 06:42:26 +0000 2011"
  }
  ]
}
{code}

h3. activity/:activityId/comment {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activitycomment}

h4. POST activity/:activityId/comment.format   {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activitycomments.Post}

*Description*: Posts a new comment on an existing activity. The poster of this comment is an authenticated identity.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId/comment{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/comment.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/comment.json]

*Body data*:
{code}
{
  "text": "My comment here!!!"
}
{code}

*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:
{code}
POST: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e/comment.json
HEADER: Content-Type: application/json
BODY: {"text": "My comment here!!!"}
{code}

*Response*: The created comment.
{code}
{
"id": "123456"
"posterIdentity": {"id":123456, "providerId":"organization", "remoteId":"demo", "profile":{"fullName":"Demo GTN", "avatarUrl":"http://localhost:8080/profile/u/demo/avatar.jpg?u=12345"}},
"text": "My comment here!!!",
"postedTime": 123456789,
"createdAt": "Fri Jun 17 06:42:26 +0000 2011"
}
{code}

h4. DELETE activity/:activityId/comment/:commentId.format {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activitycomments.Delete}

*Description*: Deletes an existing comment by its Id.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId/comment/:commentId.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/comment/123456.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/comment/123456.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:

{code}
DELETE: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e/comment/123456.json
{code}

*Response*: The deleted comment.

{code:json}
{
"id": "123456"
}
{code}

h4. POST activity/:activityId/comment/destroy/:commentId.format {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activitycomments.PostDelete}

*Description*: Deletes an existing comment by its Id using the POST method. The deleted activity information will be returned in a specified format. It is recommended to use the DELETE method, except the case that clients cannot make request via this method.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId/comment/destroy/:commentId.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/comment/destroy/123456.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/comment/destroy/123456.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:

{code}
POST: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/comment/destroy/123456.json
{code}

*Response*: The deleted comment

{code}
{
"id": "123456"
}
{code}

h3. activity/:activityId/likes {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.ActivityLikes}

h4. GET activity/:activityId/likes.format {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.ActivityLikes.GET}
*Description*: Gets all the identities who like an existing activity.

*URL*:
{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId/likes.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/likes.json]

* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/likes.json]


*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:
{code}
GET: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e/likes.json
{code}

*Response*:
{code}
{
  totalNumberOfLikes: 2,
  likesByIdentities: [
    {"id":1234567,
     "providerId":"organization",
     "remoteId":"demo",
     "profile":{"fullName":"Demo GTN", "avatarUrl":"http://localhost:8080/profile/u/demo/avatar.jpg?u=12345"}
    },
    {"id":23456,
     "providerId":"organization",
     "remoteId":"root",
     "profile":{"fullName":"Root GTN", "avatarUrl":"http://localhost:8080/profile/u/root/avatar.jpg?u=12345"}
    },
  ]
}
{code}

h3. activity/:activityId/like    {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.ActivityLike}

h4. POST activity/:activityId/like.format  {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.ActivityLike.Post}

*Description*: Allows an authenticated identity to do the "like" action on an existing activity.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId/like.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/like.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/like.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:

{code}
http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/like.json
{code}

*Response*:

{code}
{
  "liked": true
}
{code}

h4. DELETE activity/:activityId/like.format {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.ActivityLike.Delete}

*Description*: Allows an identity to remove his "like" action on an activity.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId/like.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/like.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/like.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:

{code}
DELETE: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/like.json
{code}

*Response*:

{code}
{
  "liked": false
}
{code}

h4. POST activity/:activityId/like/destroy.format  {anchor:id=SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.ActivityLike.Postdestroy}

*Description*: Allows an identity to remove his "like" action on an activity. It is recommended to use the DELETE method, except the case that clients cannot make request via this method.

*URL*:

{code}http://{domain_name}/{rest_context_name}/private/api/social/{version}/{portal_container_name}/activity/:activityId/like/destroy.format{code}

For example:

* [http://platform35.demo.exoplatform.org/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/like/destroy.json]
* [http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/like/destroy.json]

*Supported Format*: json

*Requires Authentication*: true

*Parameters*: No

*Examples*:
* *JSON*

*Request*:

{code}
POST: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4e5e/like/destroy.json
{code}

*Response*:

{code}
{
  "liked": false
}
{code}
