EventsModule

public class EventsModule

Provides Event management.

  • Gets events for the current user associated with the access token. Due to emphasis on returning complete results quickly, Box may return duplicate or out of order events. Duplicate events can be identified by their event IDs. User events are stored for between two weeks and two months, after which the user events are removed.

    Declaration

    Swift

    public func getUserEvents(
        streamType: StreamType? = nil,
        streamPosition: StreamPosition? = nil,
        limit: Int? = nil
    ) -> PagingIterator<Event>

    Parameters

    streamType

    Restricts the types of events returned.

    streamPosition

    The location in the event stream from which you want to start receiving events. If no stream position specified Box API will return all available events beginning with the oldest stream position.

    limit

    The maximum number of items to return. If not specified, default API limit is used.

    Return Value

    An iterator of events or an error.

  • Gets events for all users and content in the enterprise from admin_logs stream type. The emphasis for this stream is on completeness over latency, which means that Box will deliver admin events in chronological order and without duplicates, but with higher latency. Events with admin_logs stream type are accessible via this API up to one year. This method will only work with an API connection for an enterprise admin account.

    Declaration

    Swift

    public func getEnterpriseEvents(
        eventTypes: [EventType]? = nil,
        createdAfter: Date? = nil,
        createdBefore: Date? = nil,
        streamPosition: StreamPosition? = nil,
        limit: Int? = nil
    ) -> PagingIterator<Event>

    Parameters

    eventTypes

    Restricts returned value to listed events.

    createdAfter

    A lower bound on the timestamp of the events returned.

    createdBefore

    An upper bound on the timestamp of the events returned.

    streamPosition

    The location in the event stream from which you want to start receiving events.

    limit

    The maximum number of items to return.

    Return Value

    An iterator of events or an error.

  • Gets events for all users and content in the enterprise from admin_logs_streaming stream type. The emphasis for this feed is on low latency rather than chronological accuracy, which means that Box may return events more than once and out of chronological order. Events are returned via the API around 12 seconds after they are processed by Box (the 12 seconds buffer ensures that new events are not written after your cursor position). Events with admin_logs_streaming stream type are accessible via this API up to two weeks only. This method will only work with an API connection for an enterprise admin account.

    Declaration

    Swift

    public func getEnterpriseEventsStreaming(
        eventTypes: [EventType]? = nil,
        streamPosition: StreamPosition? = nil,
        limit: Int? = nil
    ) -> PagingIterator<Event>

    Parameters

    eventTypes

    Restricts returned value to listed events.

    streamPosition

    The location in the event stream from which you want to start receiving events.

    limit

    The maximum number of items to return.

    Return Value

    An iterator of events or an error.

  • Gets polling URL for checking new changes in an event stream. Works only for user events.

    Declaration

    Swift

    public func getPollingURL(completion: @escaping (Result<PollingURLInfo, BoxSDKError>) -> Void)

    Parameters

    completion

    Returns either polling url information or an error.

  • Makes long-polling request for new changes. Server does not return response immediatelly. It only returns response when either a new change was detected or a new request for long polling is made. Check the timeout value in the PollingURLInfo object to determine the time that the next long-polling request should be made.

    Declaration

    Swift

    public func observeForNewEvents(with urlInfo: PollingURLInfo, completion: @escaping (Result<PollingResult, BoxSDKError>) -> Void)

    Parameters

    url

    Long polling URL info.

    completion

    Returns either an event observer response or an error.