Data
public protocol Data
Data is an object that represents a set of custom data fields (key/value
pairs) defined in the formats section of the device model. The custom data
is sent by calling the submit method.
The set method returns the Data instance to allow
the data fields to be set in fluent style.
-
Set the value of a field in the
Data. The fields are determined by the format given when the Data is created. The value is validated according to the constraints in the format. If the value is not valid, aClientError.argumentexception is thrown.All fields defined in the format that are not “optional” must be set before calling
submit()Throws
ClientError.argumentiffieldisnilorvalueis not validDeclaration
Swift
func set(field: String, value: AnyObject) throws -> DataParameters
fieldname of a field from the custom data format
valuethe value to set
Return Value
Dataobject that can be used for function chaining -
This method is used to actually send the custom data fields to the server. All mandatory fields (according to the device model definition) must be set before sending, otherwise an error will be thrown. Any error that can arise while sending will be handled by the
VirtualDevice.onErrorhandler, if set.After a successful send all the values are reset so to send again the values must be set again.
Throws
ClientError.argumentif a required field is not setClientError.networkif aMessageDispatchercannot be obtained.
Declaration
Swift
func submit() throws -
Set a callback that is invoked if an error occurs when submitting the
Data. The callback may benil, which will un-set the callback.Declaration
Swift
func setOnError(callback: ((ErrorEvent) -> ())?)Parameters
callbacka callback to invoke, or
nil
Data Protocol Reference