Documentation ¶
Index ¶
- Constants
- Variables
- type APIError
- type Activity
- type ActivityGroup
- type AddActivitiesResponse
- type AddActivityResponse
- type AddObjectOption
- type AddReactionRequestObject
- type AddToManyRequest
- type AggregatedFeed
- func (f *AggregatedFeed) AddActivities(activities ...Activity) (*AddActivitiesResponse, error)
- func (f *AggregatedFeed) AddActivity(activity Activity) (*AddActivityResponse, error)
- func (f *AggregatedFeed) Follow(feed *FlatFeed, opts ...FollowFeedOption) error
- func (f *AggregatedFeed) GetActivities(opts ...GetActivitiesOption) (*AggregatedFeedResponse, error)
- func (f *AggregatedFeed) GetEnrichedActivities(opts ...GetActivitiesOption) (*EnrichedAggregatedFeedResponse, error)
- func (f *AggregatedFeed) GetFollowing(opts ...FollowingOption) (*FollowingResponse, error)
- func (f *AggregatedFeed) GetNextPageActivities(resp *AggregatedFeedResponse) (*AggregatedFeedResponse, error)
- func (f *AggregatedFeed) GetNextPageEnrichedActivities(resp *EnrichedAggregatedFeedResponse) (*EnrichedAggregatedFeedResponse, error)
- func (f *AggregatedFeed) ID() string
- func (f *AggregatedFeed) RealtimeToken(readonly bool) string
- func (f *AggregatedFeed) RemoveActivityByForeignID(foreignID string) error
- func (f *AggregatedFeed) RemoveActivityByID(id string) error
- func (f *AggregatedFeed) Slug() string
- func (f *AggregatedFeed) Unfollow(target Feed, opts ...UnfollowOption) error
- func (f *AggregatedFeed) UpdateToTargets(activity Activity, opts ...UpdateToTargetsOption) error
- func (f *AggregatedFeed) UserID() string
- type AggregatedFeedResponse
- type AnalyticsClient
- type Client
- func (c *Client) AddToMany(activity Activity, feeds ...Feed) error
- func (c *Client) AggregatedFeed(slug, userID string) (*AggregatedFeed, error)
- func (c *Client) Analytics() *AnalyticsClient
- func (c *Client) Collections() *CollectionsClient
- func (c *Client) FlatFeed(slug, userID string) (*FlatFeed, error)
- func (c *Client) FollowMany(relationships []FollowRelationship, opts ...FollowManyOption) error
- func (c *Client) GetActivitiesByForeignID(values ...ForeignIDTimePair) (*GetActivitiesResponse, error)
- func (c *Client) GetActivitiesByID(ids ...string) (*GetActivitiesResponse, error)
- func (c *Client) GetUserSessionToken(userID string) (string, error)
- func (c *Client) GetUserSessionTokenWithClaims(userID string, claims map[string]interface{}) (string, error)
- func (c *Client) NotificationFeed(slug, userID string) (*NotificationFeed, error)
- func (c *Client) PartialUpdateActivities(changesets ...UpdateActivityRequest) (*UpdateActivitiesResponse, error)
- func (c *Client) Personalization() *PersonalizationClient
- func (c *Client) Reactions() *ReactionsClient
- func (c *Client) UnfollowMany(relationships []UnfollowRelationship) error
- func (c *Client) UpdateActivities(activities ...Activity) error
- func (c *Client) UpdateActivityByForeignID(foreignID string, timestamp Time, set map[string]interface{}, unset []string) (*UpdateActivityResponse, error)
- func (c *Client) UpdateActivityByID(id string, set map[string]interface{}, unset []string) (*UpdateActivityResponse, error)
- func (c *Client) Users() *UsersClient
- type ClientInterface
- type ClientOption
- type CollectionObject
- type CollectionsClient
- func (c *CollectionsClient) Add(collection string, object CollectionObject, opts ...AddObjectOption) (*CollectionObject, error)
- func (c *CollectionsClient) CreateReference(collection, id string) string
- func (c *CollectionsClient) Delete(collection string, id string) error
- func (c *CollectionsClient) DeleteMany(collection string, ids ...string) error
- func (c *CollectionsClient) Get(collection string, id string) (*CollectionObject, error)
- func (c *CollectionsClient) Select(collection string, ids ...string) ([]GetCollectionResponseObject, error)
- func (c *CollectionsClient) Update(collection string, id string, data map[string]interface{}) (*CollectionObject, error)
- func (c *CollectionsClient) Upsert(collection string, objects ...CollectionObject) error
- type Data
- type Duration
- type EngagementEvent
- func (e EngagementEvent) WithBoost(boost int) EngagementEvent
- func (e EngagementEvent) WithContent(foreignID string, content map[string]interface{}) EngagementEvent
- func (e EngagementEvent) WithFeatures(features ...EventFeature) EngagementEvent
- func (e EngagementEvent) WithFeedID(feedID string) EngagementEvent
- func (e EngagementEvent) WithForeignID(foreignID string) EngagementEvent
- func (e EngagementEvent) WithLabel(label string) EngagementEvent
- func (e EngagementEvent) WithLocation(location string) EngagementEvent
- func (e EngagementEvent) WithPosition(position int) EngagementEvent
- func (e EngagementEvent) WithTrackedAt(trackedAt time.Time) EngagementEvent
- func (e EngagementEvent) WithUserData(userData *UserData) EngagementEvent
- type EnrichedActivity
- type EnrichedActivityGroup
- type EnrichedAggregatedFeedResponse
- type EnrichedFlatFeedResponse
- type EnrichedNotificationFeedResponse
- type EnrichedNotificationFeedResult
- type EnrichedReaction
- type EventFeature
- type Feed
- type FilterReactionResponse
- type FilterReactionsAttribute
- type FilterReactionsOption
- func WithActivityData() FilterReactionsOption
- func WithIDGT(id string) FilterReactionsOption
- func WithIDGTE(id string) FilterReactionsOption
- func WithIDLT(id string) FilterReactionsOption
- func WithIDLTE(id string) FilterReactionsOption
- func WithLimit(limit int) FilterReactionsOption
- func WithOwnChildren() FilterReactionsOption
- type FlatFeed
- func (f *FlatFeed) AddActivities(activities ...Activity) (*AddActivitiesResponse, error)
- func (f *FlatFeed) AddActivity(activity Activity) (*AddActivityResponse, error)
- func (f *FlatFeed) Follow(feed *FlatFeed, opts ...FollowFeedOption) error
- func (f *FlatFeed) GetActivities(opts ...GetActivitiesOption) (*FlatFeedResponse, error)
- func (f *FlatFeed) GetActivitiesWithRanking(ranking string, opts ...GetActivitiesOption) (*FlatFeedResponse, error)
- func (f *FlatFeed) GetEnrichedActivities(opts ...GetActivitiesOption) (*EnrichedFlatFeedResponse, error)
- func (f *FlatFeed) GetEnrichedActivitiesWithRanking(ranking string, opts ...GetActivitiesOption) (*EnrichedFlatFeedResponse, error)
- func (f *FlatFeed) GetFollowers(opts ...FollowersOption) (*FollowersResponse, error)
- func (f *FlatFeed) GetFollowing(opts ...FollowingOption) (*FollowingResponse, error)
- func (f *FlatFeed) GetNextPageActivities(resp *FlatFeedResponse) (*FlatFeedResponse, error)
- func (f *FlatFeed) GetNextPageEnrichedActivities(resp *EnrichedFlatFeedResponse) (*EnrichedFlatFeedResponse, error)
- func (f *FlatFeed) ID() string
- func (f *FlatFeed) RealtimeToken(readonly bool) string
- func (f *FlatFeed) RemoveActivityByForeignID(foreignID string) error
- func (f *FlatFeed) RemoveActivityByID(id string) error
- func (f *FlatFeed) Slug() string
- func (f *FlatFeed) Unfollow(target Feed, opts ...UnfollowOption) error
- func (f *FlatFeed) UpdateToTargets(activity Activity, opts ...UpdateToTargetsOption) error
- func (f *FlatFeed) UserID() string
- type FlatFeedResponse
- type FollowFeedOption
- type FollowManyOption
- type FollowRelationship
- type FollowRelationshipOption
- type Follower
- type FollowersOption
- type FollowersResponse
- type FollowingOption
- type FollowingResponse
- type ForeignIDTimePair
- type GetActivitiesOption
- func WithActivitiesIDGT(id string) GetActivitiesOption
- func WithActivitiesIDGTE(id string) GetActivitiesOption
- func WithActivitiesIDLT(id string) GetActivitiesOption
- func WithActivitiesIDLTE(id string) GetActivitiesOption
- func WithActivitiesLimit(limit int) GetActivitiesOption
- func WithActivitiesOffset(offset int) GetActivitiesOption
- func WithCustomParam(name, value string) GetActivitiesOption
- func WithEnrichOwnChildren() GetActivitiesOption
- func WithEnrichOwnReactions() GetActivitiesOption
- func WithEnrichReactionCounts() GetActivitiesOption
- func WithEnrichReactionKindsFilter(kinds ...string) GetActivitiesOption
- func WithEnrichRecentReactions() GetActivitiesOption
- func WithEnrichRecentReactionsLimit(limit int) GetActivitiesOption
- func WithNotificationsMarkRead(all bool, activityIDs ...string) GetActivitiesOption
- func WithNotificationsMarkSeen(all bool, activityIDs ...string) GetActivitiesOption
- type GetActivitiesResponse
- type GetCollectionResponseObject
- type ImpressionEventsData
- func (d ImpressionEventsData) AddForeignIDs(foreignIDs ...string) ImpressionEventsData
- func (d ImpressionEventsData) WithFeatures(features ...EventFeature) ImpressionEventsData
- func (d ImpressionEventsData) WithFeedID(feedID string) ImpressionEventsData
- func (d ImpressionEventsData) WithForeignIDs(foreignIDs ...string) ImpressionEventsData
- func (d ImpressionEventsData) WithLocation(location string) ImpressionEventsData
- func (d ImpressionEventsData) WithPosition(position int) ImpressionEventsData
- func (d ImpressionEventsData) WithTrackedAt(trackedAt time.Time) ImpressionEventsData
- func (d ImpressionEventsData) WithUserData(userData *UserData) ImpressionEventsData
- type NotificationFeed
- func (f *NotificationFeed) AddActivities(activities ...Activity) (*AddActivitiesResponse, error)
- func (f *NotificationFeed) AddActivity(activity Activity) (*AddActivityResponse, error)
- func (f *NotificationFeed) Follow(feed *FlatFeed, opts ...FollowFeedOption) error
- func (f *NotificationFeed) GetActivities(opts ...GetActivitiesOption) (*NotificationFeedResponse, error)
- func (f *NotificationFeed) GetEnrichedActivities(opts ...GetActivitiesOption) (*EnrichedNotificationFeedResponse, error)
- func (f *NotificationFeed) GetFollowing(opts ...FollowingOption) (*FollowingResponse, error)
- func (f *NotificationFeed) GetNextPageActivities(resp *NotificationFeedResponse) (*NotificationFeedResponse, error)
- func (f *NotificationFeed) GetNextPageEnrichedActivities(resp *EnrichedNotificationFeedResponse) (*EnrichedNotificationFeedResponse, error)
- func (f *NotificationFeed) ID() string
- func (f *NotificationFeed) RealtimeToken(readonly bool) string
- func (f *NotificationFeed) RemoveActivityByForeignID(foreignID string) error
- func (f *NotificationFeed) RemoveActivityByID(id string) error
- func (f *NotificationFeed) Slug() string
- func (f *NotificationFeed) Unfollow(target Feed, opts ...UnfollowOption) error
- func (f *NotificationFeed) UpdateToTargets(activity Activity, opts ...UpdateToTargetsOption) error
- func (f *NotificationFeed) UserID() string
- type NotificationFeedResponse
- type NotificationFeedResult
- type PersonalizationClient
- func (c *PersonalizationClient) Delete(resource string, params map[string]interface{}) error
- func (c *PersonalizationClient) Get(resource string, params map[string]interface{}) (*PersonalizationResponse, error)
- func (c *PersonalizationClient) Post(resource string, params map[string]interface{}, data map[string]interface{}) error
- type PersonalizationResponse
- type Reaction
- type ReactionsClient
- func (c *ReactionsClient) Add(r AddReactionRequestObject) (*Reaction, error)
- func (c *ReactionsClient) AddChild(parentID string, r AddReactionRequestObject) (*Reaction, error)
- func (c *ReactionsClient) Delete(id string) error
- func (c *ReactionsClient) Filter(attr FilterReactionsAttribute, opts ...FilterReactionsOption) (*FilterReactionResponse, error)
- func (c *ReactionsClient) Get(id string) (*Reaction, error)
- func (c *ReactionsClient) GetNextPageFilteredReactions(resp *FilterReactionResponse) (*FilterReactionResponse, error)
- func (c *ReactionsClient) Update(id string, data map[string]interface{}, targetFeeds []string) (*Reaction, error)
- type Requester
- type Time
- type UnfollowOption
- type UnfollowRelationship
- type UpdateActivitiesResponse
- type UpdateActivityRequest
- type UpdateActivityResponse
- type UpdateToTargetsOption
- type User
- type UserData
- type UsersClient
- func (c *UsersClient) Add(user User, getOrCreate bool) (*User, error)
- func (c *UsersClient) CreateReference(id string) string
- func (c *UsersClient) Delete(id string) error
- func (c *UsersClient) Get(id string) (*User, error)
- func (c *UsersClient) Update(id string, data map[string]interface{}) (*User, error)
Constants ¶
const ( // TimeLayout is the default time parse layout for Stream API JSON time fields TimeLayout = "2006-01-02T15:04:05.999999" // ReactionTimeLayout is the time parse layout for Stream Reaction API JSON time fields ReactionTimeLayout = "2006-01-02T15:04:05.999999Z07:00" )
Variables ¶
var ( // ErrMissingNextPage is returned when trying to read the next page of a response // which has an empty "next" field. ErrMissingNextPage = fmt.Errorf("request missing next page") // ErrInvalidNextPage is returned when trying to read the next page of a response // which has an invalid "next" field. ErrInvalidNextPage = fmt.Errorf("invalid format for Next field") )
var Version = "v3.1.1"
Version is the current release version for this client
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { Code int `json:"code,omitempty"` Detail string `json:"detail,omitempty"` Duration Duration `json:"duration,omitempty"` Exception string `json:"exception,omitempty"` ExceptionFields map[string][]interface{} `json:"exception_fields,omitempty"` StatusCode int `json:"status_code,omitempty"` }
APIError is an error returned by Stream API when the request cannot be performed or errored server side.
func ToAPIError ¶
ToAPIError tries to cast the provided error to APIError type, returning the obtained APIError and whether the operation was successful.
type Activity ¶
type Activity struct { ID string `json:"id,omitempty"` Actor string `json:"actor,omitempty"` Verb string `json:"verb,omitempty"` Object string `json:"object,omitempty"` ForeignID string `json:"foreign_id,omitempty"` Target string `json:"target,omitempty"` Time Time `json:"time,omitempty"` Origin string `json:"origin,omitempty"` To []string `json:"to,omitempty"` Score float64 `json:"score,omitempty"` Extra map[string]interface{} `json:"-"` }
Activity is a Stream activity entity.
func (Activity) MarshalJSON ¶
MarshalJSON encodes the Activity to a valid JSON bytes slice. It's required because of the custom JSON fields and time formats.
func (*Activity) UnmarshalJSON ¶
UnmarshalJSON decodes the provided JSON payload into the Activity. It's required because of the custom JSON fields and time formats.
type ActivityGroup ¶
type ActivityGroup struct { Activities []Activity `json:"activities,omitempty"` // contains filtered or unexported fields }
ActivityGroup is a group of Activity obtained from aggregated feeds.
type AddActivitiesResponse ¶
type AddActivitiesResponse struct { Activities []Activity `json:"activities,omitempty"` // contains filtered or unexported fields }
AddActivitiesResponse is the API response obtained when adding activities to a feed.
type AddActivityResponse ¶
type AddActivityResponse struct {
Activity
}
AddActivityResponse is the API response obtained when adding a single activity to a feed.
type AddObjectOption ¶
type AddObjectOption func(*addCollectionRequest)
AddObjectOption is an option usable by the Collections.Add method.
func WithUserID ¶
func WithUserID(userID string) AddObjectOption
WithUserID adds the user id to the Collections.Add request object.
type AddReactionRequestObject ¶
type AddReactionRequestObject struct { ID string `json:"id,omitempty"` Kind string `json:"kind"` ActivityID string `json:"activity_id"` UserID string `json:"user_id"` Data map[string]interface{} `json:"data,omitempty"` TargetFeeds []string `json:"target_feeds,omitempty"` ParentID string `json:"parent,omitempty"` }
AddReactionRequestObject is an object used only when calling the Add* reaction endpoints
type AddToManyRequest ¶
type AddToManyRequest struct { Activity Activity `json:"activity,omitempty"` FeedIDs []string `json:"feeds,omitempty"` }
AddToManyRequest is the API request body for adding an activity to multiple feeds at once.
type AggregatedFeed ¶
type AggregatedFeed struct {
// contains filtered or unexported fields
}
AggregatedFeed is a Stream aggregated feed, which contains activities grouped based on the grouping function defined on the dashboard.
func (*AggregatedFeed) AddActivities ¶
func (f *AggregatedFeed) AddActivities(activities ...Activity) (*AddActivitiesResponse, error)
AddActivities adds multiple activities to the feed.
func (*AggregatedFeed) AddActivity ¶
func (f *AggregatedFeed) AddActivity(activity Activity) (*AddActivityResponse, error)
AddActivity adds a new Activity to the feed.
func (*AggregatedFeed) Follow ¶
func (f *AggregatedFeed) Follow(feed *FlatFeed, opts ...FollowFeedOption) error
Follow follows the provided feed (which must be a FlatFeed), applying the provided FollowFeedOptions, if any.
func (*AggregatedFeed) GetActivities ¶
func (f *AggregatedFeed) GetActivities(opts ...GetActivitiesOption) (*AggregatedFeedResponse, error)
GetActivities requests and retrieves the activities and groups for the aggregated feed.
func (*AggregatedFeed) GetEnrichedActivities ¶
func (f *AggregatedFeed) GetEnrichedActivities(opts ...GetActivitiesOption) (*EnrichedAggregatedFeedResponse, error)
GetEnrichedActivities requests and retrieves the enriched activities and groups for the aggregated feed.
func (*AggregatedFeed) GetFollowing ¶
func (f *AggregatedFeed) GetFollowing(opts ...FollowingOption) (*FollowingResponse, error)
GetFollowing returns the list of the feeds following the feed, applying the provided FollowingOptions, if any.
func (*AggregatedFeed) GetNextPageActivities ¶
func (f *AggregatedFeed) GetNextPageActivities(resp *AggregatedFeedResponse) (*AggregatedFeedResponse, error)
GetNextPageActivities returns the activities for the given AggregatedFeed at the "next" page of a previous *AggregatedFeedResponse response, if any.
func (*AggregatedFeed) GetNextPageEnrichedActivities ¶
func (f *AggregatedFeed) GetNextPageEnrichedActivities(resp *EnrichedAggregatedFeedResponse) (*EnrichedAggregatedFeedResponse, error)
GetNextPageEnrichedActivities returns the enriched activities for the given AggregatedFeed at the "next" page of a previous *EnrichedAggregatedFeedResponse response, if any.
func (*AggregatedFeed) ID ¶
func (f *AggregatedFeed) ID() string
ID returns the feed ID, as slug:user_id.
func (*AggregatedFeed) RealtimeToken ¶
RealtimeToken returns a token that can be used client-side to listen in real-time to feed changes.
func (*AggregatedFeed) RemoveActivityByForeignID ¶
RemoveActivityByID removes an activity from the feed (if present), using the provided foreignID string argument as the foreign_id field of the activity.
func (*AggregatedFeed) RemoveActivityByID ¶
RemoveActivityByID removes an activity from the feed (if present), using the provided id string argument as the ID field of the activity.
func (*AggregatedFeed) Unfollow ¶
func (f *AggregatedFeed) Unfollow(target Feed, opts ...UnfollowOption) error
Unfollow unfollows the provided feed, applying the provided UnfollowOptions, if any.
func (*AggregatedFeed) UpdateToTargets ¶
func (f *AggregatedFeed) UpdateToTargets(activity Activity, opts ...UpdateToTargetsOption) error
UpdateToTargets updates the "to" targets for the provided activity, with the options passed as argument for replacing, adding, or removing to targets.
type AggregatedFeedResponse ¶
type AggregatedFeedResponse struct { Results []ActivityGroup `json:"results,omitempty"` // contains filtered or unexported fields }
AggregatedFeedResponse is the API response obtained when retrieving activities from an aggregated feed.
type AnalyticsClient ¶ added in v1.6.0
type AnalyticsClient struct {
// contains filtered or unexported fields
}
AnalyticsClient is a specialized client used to send and track analytics events for enabled apps.
func (*AnalyticsClient) RedirectAndTrack ¶ added in v1.6.0
func (c *AnalyticsClient) RedirectAndTrack(url string, events ...map[string]interface{}) (string, error)
RedirectAndTrack is used to send and track analytics ImpressionEvents. It tracks the events data (either EngagementEvents or ImpressionEvents) and redirects to the provided URL string.
func (*AnalyticsClient) TrackEngagement ¶ added in v1.6.0
func (c *AnalyticsClient) TrackEngagement(events ...EngagementEvent) error
TrackEngagement is used to send and track analytics EngagementEvents.
func (*AnalyticsClient) TrackImpression ¶ added in v1.6.0
func (c *AnalyticsClient) TrackImpression(eventsData ImpressionEventsData) error
TrackImpression is used to send and track analytics ImpressionEvents.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Stream API client used for retrieving feeds and performing API calls.
func NewClient ¶
func NewClient(key, secret string, opts ...ClientOption) (*Client, error)
NewClient builds a new Client with the provided API key and secret. It can be configured further by passing any number of ClientOption parameters.
func NewClientFromEnv ¶
NewClientFromEnv build a new Client using environment variables values, with possible values being STREAM_API_KEY, STREAM_API_SECRET, STREAM_API_REGION, and STREAM_API_VERSION.
func (*Client) AggregatedFeed ¶
func (c *Client) AggregatedFeed(slug, userID string) (*AggregatedFeed, error)
AggregatedFeed returns a new Aggregated Feed with the provided slug and userID.
func (*Client) Analytics ¶ added in v1.6.0
func (c *Client) Analytics() *AnalyticsClient
Analytics returns a new AnalyticsClient sharing the base configuration of the original Client.
func (*Client) Collections ¶ added in v1.7.0
func (c *Client) Collections() *CollectionsClient
Collections returns a new CollectionsClient.
func (*Client) FollowMany ¶
func (c *Client) FollowMany(relationships []FollowRelationship, opts ...FollowManyOption) error
FollowMany creates multiple follows at once.
func (*Client) GetActivitiesByForeignID ¶ added in v1.9.0
func (c *Client) GetActivitiesByForeignID(values ...ForeignIDTimePair) (*GetActivitiesResponse, error)
GetActivitiesByForeignID returns activities for the current app having the given foreign IDs and timestamps.
func (*Client) GetActivitiesByID ¶ added in v1.9.0
func (c *Client) GetActivitiesByID(ids ...string) (*GetActivitiesResponse, error)
GetActivitiesByID returns activities for the current app having the given IDs.
func (*Client) GetUserSessionToken ¶ added in v1.13.0
func (*Client) GetUserSessionTokenWithClaims ¶ added in v1.13.0
func (*Client) NotificationFeed ¶
func (c *Client) NotificationFeed(slug, userID string) (*NotificationFeed, error)
NotificationFeed returns a new Notification Feed with the provided slug and userID.
func (*Client) PartialUpdateActivities ¶
func (c *Client) PartialUpdateActivities(changesets ...UpdateActivityRequest) (*UpdateActivitiesResponse, error)
PartialUpdateActivities performs a partial update on multiple activities with the given set and unset operations specified by each changeset. This returns the affected activities.
func (*Client) Personalization ¶ added in v1.7.0
func (c *Client) Personalization() *PersonalizationClient
Personalization returns a new PersonalizationClient.
func (*Client) Reactions ¶
func (c *Client) Reactions() *ReactionsClient
Reactions returns a new ReactionsClient.
func (*Client) UnfollowMany ¶ added in v1.8.0
func (c *Client) UnfollowMany(relationships []UnfollowRelationship) error
UnfollowMany removes multiple follow relationships at once.
func (*Client) UpdateActivities ¶ added in v1.11.0
UpdateActivities updates existing activities.
func (*Client) UpdateActivityByForeignID ¶ added in v1.9.1
func (c *Client) UpdateActivityByForeignID(foreignID string, timestamp Time, set map[string]interface{}, unset []string) (*UpdateActivityResponse, error)
UpdateActivityByForeignID performs a partial activity update with the given set and unset operations, returning the affected activity, on the activity with the given foreign ID and timestamp.
func (*Client) UpdateActivityByID ¶ added in v1.9.1
func (c *Client) UpdateActivityByID(id string, set map[string]interface{}, unset []string) (*UpdateActivityResponse, error)
UpdateActivityByID performs a partial activity update with the given set and unset operations, returning the affected activity, on the activity with the given ID.
type ClientInterface ¶
type ClientInterface interface { // FlatFeed returns a new Flat Feed with the provided slug and userID. FlatFeed(slug, userID string) (*FlatFeed, error) // AggregatedFeed returns a new Aggregated Feed with the provided slug and // userID. AggregatedFeed(slug, userID string) (*AggregatedFeed, error) // NotificationFeed returns a new Notification Feed with the provided slug and // userID. NotificationFeed(slug, userID string) (*NotificationFeed, error) // AddToMany adds an activity to multiple feeds at once. AddToMany(activity Activity, feeds ...Feed) error // FollowMany creates multiple follows at once. FollowMany(relationships []FollowRelationship, opts ...FollowManyOption) error // UnfollowMany removes multiple follow relationships at once. UnfollowMany(relationships []UnfollowRelationship) error // Analytics returns a new AnalyticsClient sharing the base configuration of the original Client. Analytics() *AnalyticsClient // Collections returns a new CollectionsClient. Collections() *CollectionsClient // Users returns a new UsersClient. Users() *UsersClient // Reactions returns a new ReactionsClient. Reactions() *ReactionsClient // Personalization returns a new PersonalizationClient. Personalization() *PersonalizationClient // GetActivitiesByID returns activities for the current app having the given IDs. GetActivitiesByID(ids ...string) (*GetActivitiesResponse, error) // GetActivitiesByForeignID returns activities for the current app having the given foreign IDs and timestamps. GetActivitiesByForeignID(values ...ForeignIDTimePair) (*GetActivitiesResponse, error) // UpdateActivities updates existing activities. UpdateActivities(activities ...Activity) error // PartialUpdateActivities performs a partial update on multiple activities with the given set and unset operations // specified by each changeset. This returns the affected activities. PartialUpdateActivities(changesets ...UpdateActivityRequest) (*UpdateActivitiesResponse, error) // UpdateActivityByID performs a partial activity update with the given set and unset operations, returning the // affected activity, on the activity with the given ID. UpdateActivityByID(id string, set map[string]interface{}, unset []string) (*UpdateActivityResponse, error) // UpdateActivityByForeignID performs a partial activity update with the given set and unset operations, returning the // affected activity, on the activity with the given foreign ID and timestamp. UpdateActivityByForeignID(foreignID string, timestamp Time, set map[string]interface{}, unset []string) (*UpdateActivityResponse, error) GetUserSessionToken(userID string) (string, error) GetUserSessionTokenWithClaims(userID string, claims map[string]interface{}) (string, error) }
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function used for adding specific configuration options to a Stream client.
func WithAPIRegion ¶
func WithAPIRegion(region string) ClientOption
WithAPIRegion sets the region for a given Client.
func WithAPIVersion ¶
func WithAPIVersion(version string) ClientOption
WithAPIVersion sets the version for a given Client.
func WithHTTPRequester ¶
func WithHTTPRequester(requester Requester) ClientOption
WithHTTPRequester sets the HTTP requester for a given client, used mostly for testing.
type CollectionObject ¶ added in v1.7.0
type CollectionObject struct { ID string `json:"id,omitempty"` Data map[string]interface{} `json:"data"` }
CollectionObject is a collection's object.
func (CollectionObject) MarshalJSON ¶ added in v1.7.0
func (o CollectionObject) MarshalJSON() ([]byte, error)
MarshalJSON marshals the CollectionObject to a flat JSON object.
type CollectionsClient ¶ added in v1.7.0
type CollectionsClient struct {
// contains filtered or unexported fields
}
CollectionsClient is a specialized client used to interact with the Collection endpoints.
func (*CollectionsClient) Add ¶
func (c *CollectionsClient) Add(collection string, object CollectionObject, opts ...AddObjectOption) (*CollectionObject, error)
Add adds a single object to a collection.
func (*CollectionsClient) CreateReference ¶ added in v1.12.0
func (c *CollectionsClient) CreateReference(collection, id string) string
CreateReference returns a new reference string in the form SO:<collection>:<id>.
func (*CollectionsClient) Delete ¶ added in v1.7.0
func (c *CollectionsClient) Delete(collection string, id string) error
Delete removes from a collection the object having the given ID.
func (*CollectionsClient) DeleteMany ¶
func (c *CollectionsClient) DeleteMany(collection string, ids ...string) error
DeleteMany removes from a collection the objects having the given IDs.
func (*CollectionsClient) Get ¶ added in v1.7.0
func (c *CollectionsClient) Get(collection string, id string) (*CollectionObject, error)
Get retrives a collection object having the given ID.
func (*CollectionsClient) Select ¶
func (c *CollectionsClient) Select(collection string, ids ...string) ([]GetCollectionResponseObject, error)
Select returns a list of CollectionObjects for the given collection name having the given IDs.
func (*CollectionsClient) Update ¶
func (c *CollectionsClient) Update(collection string, id string, data map[string]interface{}) (*CollectionObject, error)
Update updates the given collection object's data.
func (*CollectionsClient) Upsert ¶ added in v1.7.0
func (c *CollectionsClient) Upsert(collection string, objects ...CollectionObject) error
Upsert creates new or updates existing objects for the given collection's name.
type Data ¶
Data is a representation of an enriched activities enriched object, such as the the user or the object
type Duration ¶
Duration wraps time.Duration, used because of JSON marshaling and unmarshaling.
func (Duration) MarshalJSON ¶
MarshalJSON marshals the Duration to a string like "30s".
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON for Duration is required because of the incoming duration string.
type EngagementEvent ¶ added in v1.6.0
type EngagementEvent map[string]interface{}
EngagementEvent represent an analytics engagement event. It must be populated with the available methods, or custom data can be arbitrarily added to it manually as key(string),value(interface{}) pairs.
func (EngagementEvent) WithBoost ¶ added in v1.6.0
func (e EngagementEvent) WithBoost(boost int) EngagementEvent
WithBoost sets the event's boost field to the given int.
func (EngagementEvent) WithContent ¶ added in v1.6.0
func (e EngagementEvent) WithContent(foreignID string, content map[string]interface{}) EngagementEvent
WithContent sets the event's content field to the given content map, and also sets the foreign_id field of such object to the given foreign ID string. If just the foreign ID is required to be sent, use the WithForeignID method.
func (EngagementEvent) WithFeatures ¶ added in v1.6.0
func (e EngagementEvent) WithFeatures(features ...EventFeature) EngagementEvent
WithFeatures sets the event's features field to the given list of EventFeatures.
func (EngagementEvent) WithFeedID ¶ added in v1.6.0
func (e EngagementEvent) WithFeedID(feedID string) EngagementEvent
WithFeedID sets the event's feed_id field to the given string.
func (EngagementEvent) WithForeignID ¶ added in v1.6.0
func (e EngagementEvent) WithForeignID(foreignID string) EngagementEvent
WithForeignID sets the event's content field to the given foreign ID. If the content payload must be an object, use the WithContent method.
func (EngagementEvent) WithLabel ¶ added in v1.6.0
func (e EngagementEvent) WithLabel(label string) EngagementEvent
WithLabel sets the event's label field to the given string.
func (EngagementEvent) WithLocation ¶ added in v1.6.0
func (e EngagementEvent) WithLocation(location string) EngagementEvent
WithLocation sets the event's location field to the given string.
func (EngagementEvent) WithPosition ¶ added in v1.6.0
func (e EngagementEvent) WithPosition(position int) EngagementEvent
WithPosition sets the event's position field to the given int.
func (EngagementEvent) WithTrackedAt ¶ added in v1.6.0
func (e EngagementEvent) WithTrackedAt(trackedAt time.Time) EngagementEvent
WithTrackedAt sets the event's tracked_at field to the given time.Time.
func (EngagementEvent) WithUserData ¶ added in v1.6.0
func (e EngagementEvent) WithUserData(userData *UserData) EngagementEvent
WithUserData sets the event's user_data field to the given UserData's value.
type EnrichedActivity ¶
type EnrichedActivity struct { ID string `json:"id,omitempty"` Actor Data `json:"actor,omitempty"` Verb string `json:"verb,omitempty"` Object Data `json:"object,omitempty"` ForeignID string `json:"foreign_id,omitempty"` Target Data `json:"target,omitempty"` Time Time `json:"time,omitempty"` Origin Data `json:"origin,omitempty"` To []string `json:"to,omitempty"` Score float64 `json:"score,omitempty"` ReactionCounts map[string]int `json:"reaction_counts,omitempty"` OwnReactions map[string][]*EnrichedReaction `json:"own_reactions,omitempty"` LatestReactions map[string][]*EnrichedReaction `json:"latest_reactions,omitempty"` Extra map[string]interface{} `json:"-"` }
EnrichedActivity is an enriched Stream activity entity.
func (EnrichedActivity) MarshalJSON ¶
func (a EnrichedActivity) MarshalJSON() ([]byte, error)
MarshalJSON encodes the EnrichedActivity to a valid JSON bytes slice. It's required because of the custom JSON fields and time formats.
func (*EnrichedActivity) UnmarshalJSON ¶
func (a *EnrichedActivity) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes the provided JSON payload into the EnrichedActivity. It's required because of the custom JSON fields and time formats.
type EnrichedActivityGroup ¶
type EnrichedActivityGroup struct { Activities []EnrichedActivity `json:"activities,omitempty"` // contains filtered or unexported fields }
EnrichedActivityGroup is a group of enriched Activities obtained from aggregated feeds.
type EnrichedAggregatedFeedResponse ¶
type EnrichedAggregatedFeedResponse struct { Results []EnrichedActivityGroup `json:"results,omitempty"` // contains filtered or unexported fields }
EnrichedAggregatedFeedResponse is the API response obtained when retrieving enriched activities from an aggregated feed.
type EnrichedFlatFeedResponse ¶
type EnrichedFlatFeedResponse struct { Results []EnrichedActivity `json:"results,omitempty"` // contains filtered or unexported fields }
EnrichedFlatFeedResponse is the API response obtained when retrieving enriched activities from a flat feed.
type EnrichedNotificationFeedResponse ¶
type EnrichedNotificationFeedResponse struct { Results []EnrichedNotificationFeedResult `json:"results"` // contains filtered or unexported fields }
EnrichedNotificationFeedResponse is the API response obtained when retrieving enriched activities from a notification feed.
type EnrichedNotificationFeedResult ¶
type EnrichedNotificationFeedResult struct { Activities []EnrichedActivity `json:"activities"` // contains filtered or unexported fields }
EnrichedNotificationFeedResult is a notification-feed specific response, containing the list of enriched activities in the group, plus the extra fields about the group read+seen status.
type EnrichedReaction ¶
type EnrichedReaction struct { ID string `json:"id,omitempty"` Kind string `json:"kind"` ActivityID string `json:"activity_id"` UserID string `json:"user_id"` Data map[string]interface{} `json:"data,omitempty"` TargetFeeds []string `json:"target_feeds,omitempty"` ParentID string `json:"parent,omitempty"` ChildrenReactions map[string][]*EnrichedReaction `json:"latest_children,omitempty"` OwnChildren map[string][]*EnrichedReaction `json:"own_children,omitempty"` ChildrenCounters map[string]int `json:"children_counts,omitempty"` User Data `json:"user,omitempty"` CreatedAt Time `json:"created_at,omitempty"` UpdatedAt Time `json:"updated_at,omitempty"` }
EnrichedReaction is an enriched Stream reaction entity.
type EventFeature ¶ added in v1.6.0
EventFeature is a single analytics event feature, a pair of group and value strings.
func NewEventFeature ¶ added in v1.6.0
func NewEventFeature(group, value string) EventFeature
NewEventFeature returns a new EventFeature from the given group and value params.
type Feed ¶
type Feed interface { ID() string Slug() string UserID() string AddActivity(Activity) (*AddActivityResponse, error) AddActivities(...Activity) (*AddActivitiesResponse, error) RemoveActivityByID(string) error RemoveActivityByForeignID(string) error Follow(*FlatFeed, ...FollowFeedOption) error GetFollowing(...FollowingOption) (*FollowingResponse, error) Unfollow(Feed, ...UnfollowOption) error UpdateToTargets(Activity, ...UpdateToTargetsOption) error RealtimeToken(bool) string }
Feed is a generic Stream feed, exporting the generic functions common to any Stream feed.
type FilterReactionResponse ¶
type FilterReactionResponse struct { Results []Reaction `json:"results"` Activity map[string]interface{} `json:"activity"` // contains filtered or unexported fields }
FilterReactionResponse is the response received from the ReactionsClient.Filter call.
type FilterReactionsAttribute ¶
type FilterReactionsAttribute func() string
FilterReactionsAttribute specifies the filtering method of Reactions.Filter()
func ByActivityID ¶
func ByActivityID(activityID string) FilterReactionsAttribute
ByActivityID will filter reactions based on the specified activity id.
func ByReactionID ¶
func ByReactionID(reactionID string) FilterReactionsAttribute
ByReactionID will filter reactions based on the specified parent reaction id.
func ByUserID ¶
func ByUserID(userID string) FilterReactionsAttribute
ByUserID will filter reactions based on the specified user id.
func (FilterReactionsAttribute) ByKind ¶
func (a FilterReactionsAttribute) ByKind(kind string) FilterReactionsAttribute
ByKind filters reactions by kind, after the initial desired filtering method was applied.
type FilterReactionsOption ¶
type FilterReactionsOption struct {
// contains filtered or unexported fields
}
FilterReactionsOption is an option used by Reactions.Filter() to support pagination.
func WithActivityData ¶
func WithActivityData() FilterReactionsOption
WithActivityData will enable returning the activity data when filtering reactions by activity_id.
func WithIDGT ¶
func WithIDGT(id string) FilterReactionsOption
WithIDGT adds the id_gt parameter to API calls, used when retrieving paginated reactions.
func WithIDGTE ¶
func WithIDGTE(id string) FilterReactionsOption
WithIDGTE adds the id_gte parameter to API calls, used when retrieving paginated reactions, returning activities with ID greater or equal than the provided id.
func WithIDLT ¶
func WithIDLT(id string) FilterReactionsOption
WithIDLT adds the id_lt parameter to API calls, used when retrieving paginated reactions.
func WithIDLTE ¶
func WithIDLTE(id string) FilterReactionsOption
WithIDLTE adds the id_lte parameter to API calls, used when retrieving paginated reactions.
func WithLimit ¶
func WithLimit(limit int) FilterReactionsOption
WithLimit adds the limit parameter to the Reactions.Filter() call.
func WithOwnChildren ¶
func WithOwnChildren() FilterReactionsOption
WithOwnChildren will enable returning the children reactions when filtering reactions by parent ID.
type FlatFeed ¶
type FlatFeed struct {
// contains filtered or unexported fields
}
FlatFeed is a Stream flat feed.
func (*FlatFeed) AddActivities ¶
func (f *FlatFeed) AddActivities(activities ...Activity) (*AddActivitiesResponse, error)
AddActivities adds multiple activities to the feed.
func (*FlatFeed) AddActivity ¶
func (f *FlatFeed) AddActivity(activity Activity) (*AddActivityResponse, error)
AddActivity adds a new Activity to the feed.
func (*FlatFeed) Follow ¶
func (f *FlatFeed) Follow(feed *FlatFeed, opts ...FollowFeedOption) error
Follow follows the provided feed (which must be a FlatFeed), applying the provided FollowFeedOptions, if any.
func (*FlatFeed) GetActivities ¶
func (f *FlatFeed) GetActivities(opts ...GetActivitiesOption) (*FlatFeedResponse, error)
GetActivities returns the activities for the given FlatFeed, filtering results with the provided GetActivitiesOption parameters.
func (*FlatFeed) GetActivitiesWithRanking ¶
func (f *FlatFeed) GetActivitiesWithRanking(ranking string, opts ...GetActivitiesOption) (*FlatFeedResponse, error)
GetActivitiesWithRanking returns the activities (filtered) for the given FlatFeed, using the provided ranking method.
func (*FlatFeed) GetEnrichedActivities ¶
func (f *FlatFeed) GetEnrichedActivities(opts ...GetActivitiesOption) (*EnrichedFlatFeedResponse, error)
GetEnrichedActivities returns the enriched activities for the given FlatFeed, filtering results with the provided GetActivitiesOption parameters.
func (*FlatFeed) GetEnrichedActivitiesWithRanking ¶
func (f *FlatFeed) GetEnrichedActivitiesWithRanking(ranking string, opts ...GetActivitiesOption) (*EnrichedFlatFeedResponse, error)
GetEnrichedActivitiesWithRanking returns the enriched activities (filtered) for the given FlatFeed, using the provided ranking method.
func (*FlatFeed) GetFollowers ¶
func (f *FlatFeed) GetFollowers(opts ...FollowersOption) (*FollowersResponse, error)
GetFollowers returns the feeds following the given FlatFeed.
func (*FlatFeed) GetFollowing ¶
func (f *FlatFeed) GetFollowing(opts ...FollowingOption) (*FollowingResponse, error)
GetFollowing returns the list of the feeds following the feed, applying the provided FollowingOptions, if any.
func (*FlatFeed) GetNextPageActivities ¶
func (f *FlatFeed) GetNextPageActivities(resp *FlatFeedResponse) (*FlatFeedResponse, error)
GetNextPageActivities returns the activities for the given FlatFeed at the "next" page of a previous *FlatFeedResponse response, if any.
func (*FlatFeed) GetNextPageEnrichedActivities ¶
func (f *FlatFeed) GetNextPageEnrichedActivities(resp *EnrichedFlatFeedResponse) (*EnrichedFlatFeedResponse, error)
GetNextPageEnrichedActivities returns the enriched activities for the given FlatFeed at the "next" page of a previous *EnrichedFlatFeedResponse response, if any.
func (*FlatFeed) RealtimeToken ¶
RealtimeToken returns a token that can be used client-side to listen in real-time to feed changes.
func (*FlatFeed) RemoveActivityByForeignID ¶
RemoveActivityByID removes an activity from the feed (if present), using the provided foreignID string argument as the foreign_id field of the activity.
func (*FlatFeed) RemoveActivityByID ¶
RemoveActivityByID removes an activity from the feed (if present), using the provided id string argument as the ID field of the activity.
func (*FlatFeed) Unfollow ¶
func (f *FlatFeed) Unfollow(target Feed, opts ...UnfollowOption) error
Unfollow unfollows the provided feed, applying the provided UnfollowOptions, if any.
func (*FlatFeed) UpdateToTargets ¶
func (f *FlatFeed) UpdateToTargets(activity Activity, opts ...UpdateToTargetsOption) error
UpdateToTargets updates the "to" targets for the provided activity, with the options passed as argument for replacing, adding, or removing to targets.
type FlatFeedResponse ¶
type FlatFeedResponse struct { Results []Activity `json:"results,omitempty"` // contains filtered or unexported fields }
FlatFeedResponse is the API response obtained when retrieving activities from a flat feed.
type FollowFeedOption ¶
type FollowFeedOption func(*followFeedOptions)
FollowFeedOption is a function used to customize FollowFeed API calls.
func WithFollowFeedActivityCopyLimit ¶
func WithFollowFeedActivityCopyLimit(activityCopyLimit int) FollowFeedOption
WithFollowFeedActivityCopyLimit sets the activity copy threshold for Follow Feed API calls.
type FollowManyOption ¶
type FollowManyOption struct {
// contains filtered or unexported fields
}
FollowManyOption is an option to customize behavior of Follow Many calls.
func WithFollowManyActivityCopyLimit ¶
func WithFollowManyActivityCopyLimit(activityCopyLimit int) FollowManyOption
WithFollowManyActivityCopyLimit sets how many activities should be copied from the target feed.
type FollowRelationship ¶
type FollowRelationship struct { Source string `json:"source,omitempty"` Target string `json:"target,omitempty"` ActivityCopyLimit *int `json:"activity_copy_limit,omitempty"` }
FollowRelationship represents a follow relationship between a source ("follower") and a target ("following"), used for FollowMany requests.
func NewFollowRelationship ¶
func NewFollowRelationship(source, target Feed, opts ...FollowRelationshipOption) FollowRelationship
NewFollowRelationship is a helper for creating a FollowRelationship from the source ("follower") and target ("following") feeds.
type FollowRelationshipOption ¶
type FollowRelationshipOption func(r *FollowRelationship)
FollowRelationshipOption customizes a FollowRelationship.
func WithFollowRelationshipActivityCopyLimit ¶
func WithFollowRelationshipActivityCopyLimit(activityCopyLimit int) FollowRelationshipOption
WithFollowRelationshipActivityCopyLimit sets the ActivityCopyLimit field for a given FollowRelationship.
type Follower ¶
type Follower struct { FeedID string `json:"feed_id,omitempty"` TargetID string `json:"target_id,omitempty"` }
Follower is the representation of a feed following another feed.
type FollowersOption ¶
type FollowersOption struct {
// contains filtered or unexported fields
}
FollowersOption is an option usable by followers feed methods.
func WithFollowersLimit ¶
func WithFollowersLimit(limit int) FollowersOption
WithFollowersLimit limits the number of followers in the response to the provided limit.
func WithFollowersOffset ¶
func WithFollowersOffset(offset int) FollowersOption
WithFollowersOffset returns followers starting from the given offset.
type FollowersResponse ¶
type FollowersResponse struct {
// contains filtered or unexported fields
}
FollowersResponse is the API response obtained when retrieving followers from a feed.
type FollowingOption ¶
type FollowingOption struct {
// contains filtered or unexported fields
}
FollowingOption is an option usable by following feed methods.
func WithFollowingFilter ¶
func WithFollowingFilter(ids ...string) FollowingOption
WithFollowingFilter adds the filter parameter to API calls, used when retrieving following feeds, allowing the check whether certain feeds are being followed.
func WithFollowingLimit ¶
func WithFollowingLimit(limit int) FollowingOption
WithFollowingLimit limits the number of followings in the response to the provided limit.
func WithFollowingOffset ¶
func WithFollowingOffset(offset int) FollowingOption
WithFollowingOffset returns followings starting from the given offset.
type FollowingResponse ¶
type FollowingResponse struct {
// contains filtered or unexported fields
}
FollowingResponse is the API response obtained when retrieving following feeds from a feed.
type ForeignIDTimePair ¶ added in v1.9.0
ForeignIDTimePair couples an activity's foreignID and timestamp.
func NewForeignIDTimePair ¶ added in v1.9.0
func NewForeignIDTimePair(foreignID string, timestamp Time) ForeignIDTimePair
NewForeignIDTimePair creates a new ForeignIDTimePair with the given foreign ID and timestamp.
type GetActivitiesOption ¶
type GetActivitiesOption struct {
// contains filtered or unexported fields
}
GetActivitiesOption is an option usable by GetActivities methods for flat and aggregated feeds.
func WithActivitiesIDGT ¶
func WithActivitiesIDGT(id string) GetActivitiesOption
WithActivitiesIDGT adds the id_gt parameter to API calls, used when retrieving paginated activities from feeds, returning activities with ID greater than the provided id.
func WithActivitiesIDGTE ¶
func WithActivitiesIDGTE(id string) GetActivitiesOption
WithActivitiesIDGTE adds the id_gte parameter to API calls, used when retrieving paginated activities from feeds, returning activities with ID greater or equal than the provided id.
func WithActivitiesIDLT ¶
func WithActivitiesIDLT(id string) GetActivitiesOption
WithActivitiesIDLT adds the id_lt parameter to API calls, used when retrieving paginated activities from feeds, returning activities with ID lesser than the provided id.
func WithActivitiesIDLTE ¶
func WithActivitiesIDLTE(id string) GetActivitiesOption
WithActivitiesIDLTE adds the id_lte parameter to API calls, used when retrieving paginated activities from feeds, returning activities with ID lesser or equal than the provided id.
func WithActivitiesLimit ¶
func WithActivitiesLimit(limit int) GetActivitiesOption
WithActivitiesLimit adds the limit parameter to API calls which support it, limiting the number of results in the response to the provided limit threshold. Supported operations: retrieve activities, retrieve followers, retrieve following.
func WithActivitiesOffset ¶
func WithActivitiesOffset(offset int) GetActivitiesOption
WithActivitiesOffset adds the offset parameter to API calls which support it, getting results starting from the provided offset index. Supported operations: retrieve activities, retrieve followers, retrieve following.
func WithCustomParam ¶
func WithCustomParam(name, value string) GetActivitiesOption
WithCustomParam adds a custom parameter to the read request.
func WithEnrichOwnChildren ¶
func WithEnrichOwnChildren() GetActivitiesOption
WithEnrichOwnChildren enriches the activities with the children reactions.
func WithEnrichOwnReactions ¶
func WithEnrichOwnReactions() GetActivitiesOption
WithEnrichOwnReactions enriches the activities with the reactions to them.
func WithEnrichReactionCounts ¶
func WithEnrichReactionCounts() GetActivitiesOption
WithEnrichReactionCounts enriches the activities with the reaction counts.
func WithEnrichReactionKindsFilter ¶
func WithEnrichReactionKindsFilter(kinds ...string) GetActivitiesOption
WithEnrichmReactionKindsFilter filters the reactions by the specified kinds
func WithEnrichRecentReactions ¶
func WithEnrichRecentReactions() GetActivitiesOption
WithEnrichRecentReactions enriches the activities with the recent reactions to them.
func WithEnrichRecentReactionsLimit ¶
func WithEnrichRecentReactionsLimit(limit int) GetActivitiesOption
WithEnrichRecentReactionsLimit specifies how many recent reactions to include in the enrichment.
func WithNotificationsMarkRead ¶
func WithNotificationsMarkRead(all bool, activityIDs ...string) GetActivitiesOption
WithNotificationsMarkRead marks as read the given activity ids in a notification feed. If the all parameter is true, every activity in the feed is marked as read.
func WithNotificationsMarkSeen ¶
func WithNotificationsMarkSeen(all bool, activityIDs ...string) GetActivitiesOption
WithNotificationsMarkSeen marks as seen the given activity ids in a notification feed. If the all parameter is true, every activity in the feed is marked as seen.
type GetActivitiesResponse ¶ added in v1.9.0
type GetActivitiesResponse struct { Results []Activity `json:"results"` // contains filtered or unexported fields }
GetActivitiesResponse contains a slice of Activity returned by GetActivitiesByID and GetActivitiesByForeignID requests.
type GetCollectionResponseObject ¶ added in v1.10.0
type GetCollectionResponseObject struct { ForeignID string `json:"foreign_id"` Data map[string]interface{} `json:"data"` }
GetCollectionResponseObject represent a single response coming from a Collection Get request after a CollectionsClient.Get call.
type ImpressionEventsData ¶ added in v1.6.0
type ImpressionEventsData map[string]interface{}
ImpressionEventsData represents the payload of an arbitrary number of impression events. It must be populated with the available methods, or custom data can be arbitrarily added to it manually as key(string),value(interface{}) pairs.
func (ImpressionEventsData) AddForeignIDs ¶ added in v1.6.0
func (d ImpressionEventsData) AddForeignIDs(foreignIDs ...string) ImpressionEventsData
AddForeignIDs adds the given foreign ID strings to the content_list field, creating it if it doesn't exist.
func (ImpressionEventsData) WithFeatures ¶ added in v1.6.0
func (d ImpressionEventsData) WithFeatures(features ...EventFeature) ImpressionEventsData
WithFeatures sets the features field to the given list of EventFeatures.
func (ImpressionEventsData) WithFeedID ¶ added in v1.6.0
func (d ImpressionEventsData) WithFeedID(feedID string) ImpressionEventsData
WithFeedID sets the feed_id field to the given string.
func (ImpressionEventsData) WithForeignIDs ¶ added in v1.6.0
func (d ImpressionEventsData) WithForeignIDs(foreignIDs ...string) ImpressionEventsData
WithForeignIDs sets the content_list field to the given list of strings.
func (ImpressionEventsData) WithLocation ¶ added in v1.6.0
func (d ImpressionEventsData) WithLocation(location string) ImpressionEventsData
WithLocation sets the location field to the given string.
func (ImpressionEventsData) WithPosition ¶ added in v1.6.0
func (d ImpressionEventsData) WithPosition(position int) ImpressionEventsData
WithPosition sets the position field to the given int.
func (ImpressionEventsData) WithTrackedAt ¶ added in v1.6.0
func (d ImpressionEventsData) WithTrackedAt(trackedAt time.Time) ImpressionEventsData
WithTrackedAt sets the tracked_at field to the given time.Time.
func (ImpressionEventsData) WithUserData ¶ added in v1.6.0
func (d ImpressionEventsData) WithUserData(userData *UserData) ImpressionEventsData
WithUserData sets the user_data field to the given UserData value.
type NotificationFeed ¶
type NotificationFeed struct {
// contains filtered or unexported fields
}
NotificationFeed is a Stream notification feed.
func (*NotificationFeed) AddActivities ¶
func (f *NotificationFeed) AddActivities(activities ...Activity) (*AddActivitiesResponse, error)
AddActivities adds multiple activities to the feed.
func (*NotificationFeed) AddActivity ¶
func (f *NotificationFeed) AddActivity(activity Activity) (*AddActivityResponse, error)
AddActivity adds a new Activity to the feed.
func (*NotificationFeed) Follow ¶
func (f *NotificationFeed) Follow(feed *FlatFeed, opts ...FollowFeedOption) error
Follow follows the provided feed (which must be a FlatFeed), applying the provided FollowFeedOptions, if any.
func (*NotificationFeed) GetActivities ¶
func (f *NotificationFeed) GetActivities(opts ...GetActivitiesOption) (*NotificationFeedResponse, error)
GetActivities returns the activities for the given NotificationFeed, filtering results with the provided GetActivitiesOption parameters.
func (*NotificationFeed) GetEnrichedActivities ¶
func (f *NotificationFeed) GetEnrichedActivities(opts ...GetActivitiesOption) (*EnrichedNotificationFeedResponse, error)
GetEnrichedActivities returns the enriched activities for the given NotificationFeed, filtering results with the provided GetActivitiesOption parameters.
func (*NotificationFeed) GetFollowing ¶
func (f *NotificationFeed) GetFollowing(opts ...FollowingOption) (*FollowingResponse, error)
GetFollowing returns the list of the feeds following the feed, applying the provided FollowingOptions, if any.
func (*NotificationFeed) GetNextPageActivities ¶
func (f *NotificationFeed) GetNextPageActivities(resp *NotificationFeedResponse) (*NotificationFeedResponse, error)
GetNextPageActivities returns the activities for the given NotificationFeed at the "next" page of a previous *NotificationFeedResponse response, if any.
func (*NotificationFeed) GetNextPageEnrichedActivities ¶
func (f *NotificationFeed) GetNextPageEnrichedActivities(resp *EnrichedNotificationFeedResponse) (*EnrichedNotificationFeedResponse, error)
GetNextPageEnrichedActivities returns the enriched activities for the given NotificationFeed at the "next" page of a previous *EnrichedNotificationFeedResponse response, if any.
func (*NotificationFeed) ID ¶
func (f *NotificationFeed) ID() string
ID returns the feed ID, as slug:user_id.
func (*NotificationFeed) RealtimeToken ¶
RealtimeToken returns a token that can be used client-side to listen in real-time to feed changes.
func (*NotificationFeed) RemoveActivityByForeignID ¶
RemoveActivityByID removes an activity from the feed (if present), using the provided foreignID string argument as the foreign_id field of the activity.
func (*NotificationFeed) RemoveActivityByID ¶
RemoveActivityByID removes an activity from the feed (if present), using the provided id string argument as the ID field of the activity.
func (*NotificationFeed) Slug ¶
func (f *NotificationFeed) Slug() string
Slug returns the feed's slug.
func (*NotificationFeed) Unfollow ¶
func (f *NotificationFeed) Unfollow(target Feed, opts ...UnfollowOption) error
Unfollow unfollows the provided feed, applying the provided UnfollowOptions, if any.
func (*NotificationFeed) UpdateToTargets ¶
func (f *NotificationFeed) UpdateToTargets(activity Activity, opts ...UpdateToTargetsOption) error
UpdateToTargets updates the "to" targets for the provided activity, with the options passed as argument for replacing, adding, or removing to targets.
type NotificationFeedResponse ¶
type NotificationFeedResponse struct { Results []NotificationFeedResult `json:"results"` // contains filtered or unexported fields }
NotificationFeedResponse is the API response obtained when retrieving activities from a notification feed.
type NotificationFeedResult ¶
type NotificationFeedResult struct { Activities []Activity `json:"activities"` // contains filtered or unexported fields }
NotificationFeedResult is a notification-feed specific response, containing the list of activities in the group, plus the extra fields about the group read+seen status.
type PersonalizationClient ¶ added in v1.7.0
type PersonalizationClient struct {
// contains filtered or unexported fields
}
PersonalizationClient is a specialized client for personalization features.
func (*PersonalizationClient) Delete ¶ added in v1.7.0
func (c *PersonalizationClient) Delete(resource string, params map[string]interface{}) error
Delete removes data from the given resource, adding the given params to the request.
func (*PersonalizationClient) Get ¶ added in v1.7.0
func (c *PersonalizationClient) Get(resource string, params map[string]interface{}) (*PersonalizationResponse, error)
Get obtains a PersonalizationResponse for the given resource and params.
type PersonalizationResponse ¶ added in v1.7.0
type PersonalizationResponse struct { AppID int `json:"app_id"` Duration Duration `json:"duration"` Limit int `json:"limit"` Offset int `json:"offset"` Version string `json:"version"` Next string `json:"next"` Results []map[string]interface{} `json:"results"` // contains filtered or unexported fields }
PersonalizationResponse is a generic response from the personalization endpoints obtained after a PersonalizationClient.Get call. Common JSON fields are directly available as struct fields, while non-standard JSON fields can be retrieved using the Extra() method.
func (*PersonalizationResponse) Extra ¶ added in v1.7.0
func (r *PersonalizationResponse) Extra() map[string]interface{}
Extra returns the non-common response fields as a map[string]interface{}.
func (*PersonalizationResponse) UnmarshalJSON ¶ added in v1.7.0
func (r *PersonalizationResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON for PersonalizationResponse is required because of the incoming duration string, and for storing non-standard fields without losing their values, so they can be retrieved later on with the Extra() function.
type Reaction ¶
type Reaction struct { AddReactionRequestObject ChildrenReactions map[string][]*Reaction `json:"latest_children,omitempty"` OwnChildren map[string][]*Reaction `json:"own_children,omitempty"` ChildrenCounters map[string]interface{} `json:"children_counts,omitempty"` }
Reaction is a reaction retrieved from the API.
type ReactionsClient ¶
type ReactionsClient struct {
// contains filtered or unexported fields
}
ReactionsClient is a specialized client used to interact with the Reactions endpoints.
func (*ReactionsClient) Add ¶
func (c *ReactionsClient) Add(r AddReactionRequestObject) (*Reaction, error)
Add adds a reaction.
func (*ReactionsClient) AddChild ¶
func (c *ReactionsClient) AddChild(parentID string, r AddReactionRequestObject) (*Reaction, error)
AddChild adds a child reaction to the provided parent.
func (*ReactionsClient) Delete ¶
func (c *ReactionsClient) Delete(id string) error
Delete deletes a reaction having the given id.
func (*ReactionsClient) Filter ¶
func (c *ReactionsClient) Filter(attr FilterReactionsAttribute, opts ...FilterReactionsOption) (*FilterReactionResponse, error)
Filter lists reactions based on the provided criteria and with the specified pagination.
func (*ReactionsClient) Get ¶
func (c *ReactionsClient) Get(id string) (*Reaction, error)
Get retrieves a reaction having the given id.
func (*ReactionsClient) GetNextPageFilteredReactions ¶
func (c *ReactionsClient) GetNextPageFilteredReactions(resp *FilterReactionResponse) (*FilterReactionResponse, error)
GetNextPageFilteredReactions returns the reactions at the "next" page of a previous *FilterReactionResponse response, if any.
type Time ¶
Time wraps time.Time, used because of custom API time format in JSON marshaling and unmarshaling.
func (Time) MarshalJSON ¶
MarshalJSON marshals Time into a string formatted with the TimeLayout format.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON for Time is required because of the incoming time string format.
type UnfollowOption ¶
type UnfollowOption struct {
// contains filtered or unexported fields
}
UnfollowOption is an option usable with the Unfollow feed method.
func WithUnfollowKeepHistory ¶
func WithUnfollowKeepHistory(keepHistory bool) UnfollowOption
WithUnfollowKeepHistory adds the keep_history parameter to API calls, used to keep history when unfollowing feeds, rather than purging it (default behavior). If the keepHistory parameter is false, nothing happens.
type UnfollowRelationship ¶ added in v1.8.0
type UnfollowRelationship struct { Source string `json:"source"` Target string `json:"target"` KeepHistory bool `json:"keep_history"` }
UnfollowRelationship represents a single follow relationship to remove, used for UnfollowMany requests.
type UpdateActivitiesResponse ¶
type UpdateActivitiesResponse struct {
Activities []*Activity `json:"activities"`
}
type UpdateActivityRequest ¶
type UpdateActivityRequest struct { ID *string `json:"id,omitempty"` ForeignID *string `json:"foreign_id,omitempty"` Time *Time `json:"time,omitempty"` Set map[string]interface{} `json:"set,omitempty"` Unset []string `json:"unset,omitempty"` }
UpdateActivityRequest is the API request body for partially updating an activity.
func NewUpdateActivityRequestByForeignID ¶
func NewUpdateActivityRequestByForeignID(foreignID string, timestamp Time, set map[string]interface{}, unset []string) UpdateActivityRequest
NewUpdateActivityRequestByForeignID creates a new UpdateActivityRequest to be used by PartialUpdateActivities
func NewUpdateActivityRequestByID ¶
func NewUpdateActivityRequestByID(id string, set map[string]interface{}, unset []string) UpdateActivityRequest
NewUpdateActivityRequestByID creates a new UpdateActivityRequest to be used by PartialUpdateActivities
type UpdateActivityResponse ¶ added in v1.9.1
type UpdateActivityResponse struct {
Activity
}
UpdateActivityResponse is the response returned by the UpdateActivityByID and UpdateActivityByForeignID methods.
type UpdateToTargetsOption ¶
type UpdateToTargetsOption func(*updateToTargetsRequest)
UpdateToTargetsOption determines what operations perform during an UpdateToTargets API call.
func WithToTargetsAdd ¶
func WithToTargetsAdd(targets ...string) UpdateToTargetsOption
WithToTargetsAdd sets the add to targets, adding them to the activity's existing ones.
func WithToTargetsNew ¶
func WithToTargetsNew(targets ...string) UpdateToTargetsOption
WithToTargetsNew sets the new to targets, replacing all the existing ones. It cannot be used in combination with any other UpdateToTargetsOption.
func WithToTargetsRemove ¶
func WithToTargetsRemove(targets ...string) UpdateToTargetsOption
WithToTargetsRemove sets the remove to targets, removing them from activity's the existing ones.
type UserData ¶ added in v1.6.0
type UserData struct {
// contains filtered or unexported fields
}
UserData represents an analytics event user data field, which can either be a single string/integer representing the user's ID, or a dictionary made of an ID (string or integer) and a string alias. For example NewUserData().Int(123).Alias("john") will result in a dictionary like {"user_data":{"id": 123, "alias": "john"}}, while NewUserData().String("bob") will result in {"user_data": "bob"}.
func NewUserData ¶ added in v1.6.0
func NewUserData() *UserData
NewUserData initializes an empty UserData type, which must be populated using the String, Int, and/or Alias methods.
type UsersClient ¶
type UsersClient struct {
// contains filtered or unexported fields
}
UsersClient is a specialized client used to interact with the Users endpoints.
func (*UsersClient) Add ¶
func (c *UsersClient) Add(user User, getOrCreate bool) (*User, error)
Add adds a new user with the specified id and optional extra data.
func (*UsersClient) CreateReference ¶
func (c *UsersClient) CreateReference(id string) string
CreateReference returns a new reference string in the form SU:<id>.
func (*UsersClient) Delete ¶
func (c *UsersClient) Delete(id string) error
Delete deletes a user having the given id.