Activity Operations
The Activity API provides functionality to manage user activities in the Fans United platform. It supports creating, retrieving, and deleting various types of user activities.
Core Methods
Create Activity
suspend fun add(
action: ActionsEnum,
tags: List<Tag>,
content: Content? = null,
campaign: Campaign? = null
): ActivityResponseBody?
Creates a new activity for the authenticated user with:
-
action:
ActionsEnum
- Required parameter defining the type of user activity
- Possible values:
LIKE
,DISLIKE
,PAGE_VIEW
,CONTENT_CONSUMED
,SHARE
,COMMENT
,CLICK_AD
,CONVERSION
,CONVERT
, etc.
-
tags:
List<Tag>
- Required list of tags associated with the activity
- Used for categorization and tracking
- Each
Tag
contains metadata about the activity
-
content:
Content?
(optional)- Contains details about the content being interacted with
- Properties:
type
: Content typeid
: Content identifierlabel
: Content description
-
campaign:
Campaign?
(optional)- Campaign information used for tracking marketing activities
- id:
String?
- unique identifier for the campaign - label:
String?
- descriptive label for the campaign
- id:
- Campaign information used for tracking marketing activities
Return Type ActivityResponseBody
A response data model containing activity tracking results and user interaction details.
Properties
-
id:
String?
- Activity's unique identifier
-
profileId:
String?
- Associated user profile identifier
-
property:
String?
- Activity property name
-
value:
String?
- Activity property value
-
action:
ActionsEnum?
- Type of activity performed (e.g.,
LIKE
,SHARE
)
- Type of activity performed (e.g.,
-
context:
ActivityContext?
- Additional activity metadata
-
points:
Int
- Points awarded for activity
val response = ActivityResponseBody(
id = "act_123",
profileId = "user_456",
action = ActionsEnum.LIKE,
points = 5
)
Usage Example
val response = activity.add(
action = ActionsEnum.PAGE_VIEW,
tags = listOf(Tag("sports"), Tag("article")),
content = Content(
type = "article",
id = "123",
label = "match-report"
),
campaign = Campaign(
id = "camp_123",
label = "summer_promo_2024"
)
)
Delete Activity
suspend fun delete(activityId: String): Boolean?
Deletes an activity by its ID.
Get Activities
Get Own Activities
suspend fun getOwn(
filters: OwnActivityFilters? = null,
disableCache: Boolean = false
): PagedResponse<List<ActivityResponseBody>>?
Get User Activities
suspend fun getForUser(
userId: String,
filters: UserActivityFilters? = null,
disableCache: Boolean = false
): PagedResponse<List<ActivityResponseBody>>?
Supported Activity Types
Content Interaction
// Like content
suspend fun like(tags: List<Tag>, content: Content? = null, campaign: Campaign? = null)
// Dislike content
suspend fun dislike(tags: List<Tag>, content: Content? = null, campaign: Campaign? = null)
// Comment on content
suspend fun addComment(tags: List<Tag>, content: Content? = null, campaign: Campaign? = null)
// Share content
suspend fun addShare(tags: List<Tag>, content: Content? = null, campaign: Campaign? = null)
Content Consumption
// Page view
suspend fun addPageView(tags: List<Tag>, content: Content? = null, campaign: Campaign? = null)
// Content consumed
suspend fun addContentConsumed(tags: List<Tag>, content: Content? = null, campaign: Campaign? = null)
Advertising
// Ad click
suspend fun addClickAd(tags: List<Tag>, content: Content? = null, campaign: Campaign? = null)
// Conversion
suspend fun addConvert(tags: List<Tag>, content: Content? = null, campaign: Campaign? = null)
Available Activity Actions
LIKE
: User liked contentDISLIKE
: User disliked contentPAGE_VIEW
: User viewed a pageCONTENT_CONSUMED
: User consumed contentSHARE
: User shared contentCOMMENT
: User commentedCLICK_AD
: User clicked advertisementCONVERSION
: User completed conversionPREDICTION_MADE
: User made predictionCONVERT
: User convertedMANAGE_INTERESTS
: User managed interestsGAME_PARTICIPATION
: User participated in gameARTICLE_CONSUMED
: User consumed articleVIDEO_CONSUMED
: User consumed videoSHORT_VIDEO_CONSUMED
: User consumed short videoLONG_VIDEO_CONSUMED
: User consumed long videoAUDIO_CONSUMED
: User consumed audioGALLERY_CONSUMED
: User consumed galleryIMAGE_CONSUMED
: User consumed imagePOLL_PARTICIPATION
: User participated in poll
Example Usage
// Create activity
val activity = sdk.activity().add(
action = ActionsEnum.LIKE,
tags = listOf(Tag(id = "fb:t:8633", source = "FOOTBALL", type = ResourceType.TEAM))),
content = Content(
type = "article",
id = "article123",
label = "Sports News"
)
)
// Get user activities
val activities = sdk.activity().getForUser(
userId = "user123",
filters = UserActivityFilters(
action = ActionsEnum.LIKE,
limit = 10
)
)
Note: All activity operations are suspending functions and should be called from a coroutine scope.
Updated 3 days ago