SpongeClient class

A Sponge Remote API client.

SpongeClient performs best when you create a single instance and reuse it for all of your Remote API calls. It keeps action metadata cache.

Constructors

SpongeClient(SpongeClientConfiguration _configuration, {TypeConverter typeConverter, FeatureConverter featureConverter})

Properties

configuration SpongeClientConfiguration
The Remote API client configuration.
read-only
currentAuthToken String
read-only
currentRequestId int
read-only
featureConverter FeatureConverter
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
typeConverter TypeConverter
The type converter.
read-only

Methods

addOnRequestSerializedListener(OnRequestSerializedListener listener) → void
addOnResponseDeserializedListener(OnResponseDeserializedListener listener) → void
call(String actionName, {List args, Map<String, dynamic> namedArgs, ActionMeta actionMeta, bool allowFetchMetadata: true}) Future
Sends the call request to the server and returns the response. See callByRequest.
callByRequest(ActionCallRequest request, {ActionMeta actionMeta, bool allowFetchMetadata: true, SpongeRequestContext context}) Future<ActionCallResponse>
Sends the call request to the server and returns the response. [...]
clearActionMetaCache() Future<void>
Clears the action metadata cache.
clearCache() Future<void>
Clears caches.
clearEventTypeCache() Future<void>
Clears the event type cache.
clearFeaturesCache() Future<void>
clearSession() Future<void>
Clears the session, i.e. the auth token.
execute<T extends SpongeRequest, R extends SpongeResponse>(T request, ResponseFromJsonCallback<R> fromJson, [SpongeRequestContext context]) Future<R>
Sends the request to the server and returns the response.
executeWithAuthentication<T>({String requestUsername, String requestPassword, String requestAuthToken, Future<T> onExecute(), void onClearAuthToken()}) Future<T>
getActionMeta(String actionName, {bool allowFetchMetadata: true, SpongeRequestContext context}) Future<ActionMeta>
Returns the metadata for the specified action or null if there is no such action or that action has no metadata. [...]
getActions({String name, bool metadataRequired}) Future<List<ActionMeta>>
Sends the actions request to the server and returns the list of available actions metadata.
getActionsByRequest(GetActionsRequest request, {SpongeRequestContext context}) Future<GetActionsResponse>
Sends the actions request to the server and returns the response. This method may populate the action metadata cache.
getEventType(String eventTypeName, {bool allowFetchEventType: true, SpongeRequestContext context}) Future<RecordType>
Returns the event type for the specified event type name or null if there is no such event type. [...]
getEventTypes({String name}) Future<Map<String, RecordType>>
Sends the eventTypes request to the server.
getEventTypesByRequest(GetEventTypesRequest request, {SpongeRequestContext context}) Future<GetEventTypesResponse>
Sends the eventTypes request to the server.
getFeatures() Future<Map<String, dynamic>>
Returns the Sponge API features by sending the features request to the server and returning the features or using the cache.
getFeaturesByRequest(GetFeaturesRequest request, {SpongeRequestContext context}) Future<GetFeaturesResponse>
Sends the features request to the server and returns the response.
getKnowledgeBases() Future<List<KnowledgeBaseMeta>>
Sends the knowledgeBases request to the server and returns the list of available knowledge bases metadata.
getKnowledgeBasesByRequest(GetKnowledgeBasesRequest request, {SpongeRequestContext context}) Future<GetKnowledgeBasesResponse>
Sends the knowledgeBases request to the server and returns the response.
getVersion() Future<String>
Sends the version request to the server and returns the version.
getVersionByRequest(GetVersionRequest request, {SpongeRequestContext context}) Future<GetVersionResponse>
Sends the version request to the server and returns the response.
handleErrorResponse(String method, ResponseError error) → void
isActionActive(List<IsActionActiveEntry> entries) Future<List<bool>>
Fetches activity statuses for actions specified in the entries. If none of the actions is activatable (based on the cached metadata), returns positive activity statuses without connecting the server.
isActionActiveByRequest(IsActionActiveRequest request, {SpongeRequestContext context}) Future<IsActionActiveResponse>
Sends the isActionActive request to the server.
login() Future<String>
Sends the login request to the server and returns the auth token. See loginByRequest.
loginByRequest(LoginRequest request, {SpongeRequestContext context}) Future<LoginResponse>
Sends the login request to the server and returns the response. Sets the auth token in the client for further requests.
logout() Future<void>
Sends the logout request to the server. See logoutByRequest.
logoutByRequest(LogoutRequest request, {SpongeRequestContext context}) Future<LogoutResponse>
Sends the logout request to the server and returns the response. Clears the auth token in the client.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
provideActionArgs(String actionName, {List<String> provide, List<String> submit, Map<String, Object> current, Map<String, DataType> dynamicTypes, Map<String, Map<String, Object>> argFeatures, bool initial}) Future<Map<String, ProvidedValue>>
Submits action arguments to the server and/or fetches action arguments from the server.
provideActionArgsByRequest(ProvideActionArgsRequest request, {SpongeRequestContext context}) Future<ProvideActionArgsResponse>
Sends the provideActionArgs request to the server. Fetches the provided action arguments from the server.
reload() Future<void>
Sends the reload request to the server.
reloadByRequest(ReloadRequest request, {SpongeRequestContext context}) Future<ReloadResponse>
Sends the reload request to the server and returns the response.
removeOnRequestSerializedListener(OnRequestSerializedListener listener) bool
removeOnResponseDeserializedListener(OnResponseDeserializedListener listener) bool
send(String eventName, {Map<String, Object> attributes, String label, String description, Map<String, Object> features}) Future<String>
Sends the event named eventName with optional attributes, label, description and features to the server.
sendByRequest(SendEventRequest request, {SpongeRequestContext context}) Future<SendEventResponse>
Sends the send request to the server and returns the response.
setupRequest<T extends SpongeRequest>(T request) → T
toString() String
Returns a string representation of this object.
inherited
validateCallArgs(ActionMeta actionMeta, List args) → void
Validates the action call arguments. Throws exception on validation failure.
validateCallNamedArgs(ActionMeta actionMeta, Map<String, dynamic> args) → void

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited