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 type
      • id: Content identifier
      • label: 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

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)
  • 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 content
  • DISLIKE: User disliked content
  • PAGE_VIEW: User viewed a page
  • CONTENT_CONSUMED: User consumed content
  • SHARE: User shared content
  • COMMENT: User commented
  • CLICK_AD: User clicked advertisement
  • CONVERSION: User completed conversion
  • PREDICTION_MADE: User made prediction
  • CONVERT: User converted
  • MANAGE_INTERESTS: User managed interests
  • GAME_PARTICIPATION: User participated in game
  • ARTICLE_CONSUMED: User consumed article
  • VIDEO_CONSUMED: User consumed video
  • SHORT_VIDEO_CONSUMED: User consumed short video
  • LONG_VIDEO_CONSUMED: User consumed long video
  • AUDIO_CONSUMED: User consumed audio
  • GALLERY_CONSUMED: User consumed gallery
  • IMAGE_CONSUMED: User consumed image
  • POLL_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.