EventClient
public class EventClient : BaseClient
Responsible for sending data to a PredictionIO Event Server.
-
Creates a client instance to connect to the Event Server.
Declaration
Swift
public init(accessKey: String, baseURL: String = "http://localhost:7070", channel: String? = nil, timout: TimeInterval = 5)Parameters
accessKeyThe access key to the Event Server’s app.
baseURLThe base URL of the Event Server.
http://localhost:8000by default.channelThe channel name of the app.
nilby default.timeoutThe request timeout. 5 seconds by default.
Return Value
The
EventClientinstance.
-
Creates an event in the Event Server.
Declaration
Swift
public func createEvent(_ event: Event, completionHandler: @escaping (Result<CreateEventResponse, PIOError>) -> Void)Parameters
eventThe
Eventto be created.completionHandlerThe callback to be executed when the request has finished.
-
Creates a batch of events in the Event Server.
Declaration
Swift
public func createBatchEvents(_ events: [Event], completionHandler: @escaping (Result<CreateBatchEventsResponse, PIOError>) -> Void)Parameters
eventsThe
Events to be created.completionHandlerThe callback to be executed when the request has finished.
-
Retrieves events from the Event Server.
Declaration
Parameters
startTimeFind events with
eventTime >= startTime.nilby default.endTimeFind events with
eventTime < endTime.nilby default.entityTypeFind events with this
entityTypeonly.nilby default.entityIDFind events with this
entityIDonly.nilby default.limitThe number of record events returned. Set -1 to get all. 20 by default.
reversedReturns events in reversed chronological order. Must be used with both
entityTypeandentityIDspecified.falseby default.completionHandlerThe callback to be executed when the request has finished.
-
Deletes an event from the Event Server.
Declaration
Swift
public func deleteEvent(eventID: String, completionHandler: @escaping (PIOError?) -> Void)Parameters
eventIDThe event ID.
completionHandlerThe callback to be executed when the request has finished.
-
Sets properties of a user.
Declaration
Swift
func setUser(userID: String, properties: [String: Any], eventTime: Date = Date(), completionHandler: @escaping (Result<CreateEventResponse, PIOError>) -> Void)Parameters
userIDThe user ID.
propertiesThe properties to be set.
eventTimeThe event time. Current local time by default.
completionHandlerThe callback to be executed when the request has finished.
-
Unsets properties of a user.
Declaration
Swift
func unsetUser(userID: String, properties: [String: Any], eventTime: Date = Date(), completionHandler: @escaping (Result<CreateEventResponse, PIOError>) -> Void)Parameters
userIDThe user ID.
propertiesThe properties to be unset.
eventTimeThe event time. Current local time by default.
completionHandlerThe callback to be executed when the request has finished.
-
Deletes a user.
Declaration
Swift
func deleteUser(userID: String, eventTime: Date = Date(), completionHandler: @escaping (Result<CreateEventResponse, PIOError>) -> Void)Parameters
userIDThe user ID.
eventTimeThe event time. Current local time by default.
completionHandlerThe callback to be executed when the request has finished.
-
Sets properties of an item.
Declaration
Swift
func setItem(itemID: String, properties: [String: Any], eventTime: Date = Date(), completionHandler: @escaping (Result<CreateEventResponse, PIOError>) -> Void)Parameters
itemIDThe item ID.
propertiesThe properties to be set.
eventTimeThe event time. Current local time by default.
completionHandlerThe callback to be executed when the request has finished.
-
Unsets properties of an item.
Declaration
Swift
func unsetItem(itemID: String, properties: [String: Any], eventTime: Date = Date(), completionHandler: @escaping (Result<CreateEventResponse, PIOError>) -> Void)Parameters
itemIDThe item ID.
propertiesThe properties to be unset.
eventTimeThe event time. Current local time by default.
completionHandlerThe callback to be executed when the request has finished.
-
Deletes an item.
Declaration
Swift
func deleteItem(itemID: String, eventTime: Date = Date(), completionHandler: @escaping (Result<CreateEventResponse, PIOError>) -> Void)Parameters
itemIDThe item ID.
eventTimeThe event time. Current local time by default.
completionHandlerThe callback to be executed when the request has finished.
-
Creates a user-to-item action.
Declaration
Swift
func recordAction(_ action: String, byUserID userID: String, onItemID itemID: String, properties: [String: Any]? = nil, eventTime: Date = Date(), completionHandler: @escaping (Result<CreateEventResponse, PIOError>) -> Void)Parameters
actionThe action to be used as event name.
userIDThe userID.
itemIDThe item ID.
propertiesThe properties of the event.
nilby default.eventTimeThe event time. Current local time by default.
completionHandlerThe callback to be executed when the request has finished.
View on GitHub
Install in Dash
EventClient Class Reference