RequestOptions
open class RequestOptions : ObjectBase
Options for processing of data requests.
If request options are used for repeatable
requests, a new request options object should be used for each distinct request (or the repeatability properties should be reset before object re-use). The repeated execution of a failed request should re-use the original request options object without repeatable
being reset beforehand.
-
Immutable value for “no” request options.
Declaration
Swift
public static let none: RequestOptions
-
Default initializer.
Declaration
Swift
override public init()
-
File for background download request
Declaration
Swift
open var backgroundFile: String? { get set }
-
Name for background download request
Declaration
Swift
open var backgroundName: String? { get set }
-
In offline scenarios, can this request be combined with a previous request? Defaults to
true
. A delete request can be combined with a previous create request by canceling the create request. An update request can be combined with a previous create or update request by merging the newly changed properties with the previously changed properties.Declaration
Swift
open var canCombineRequests: Bool { get set }
-
Set this to a cancellation token before initiating an async request if request cancellation may be needed.
Declaration
Swift
open var cancelToken: CancelToken? { get set }
-
Set the
cancelToken
and return this options object.Declaration
Swift
open func cancelable(_ token: CancelToken = CancelToken()) -> RequestOptions
Parameters
token
Cancellation token.
Return Value
This options object.
-
Enable capturing of response headers into the specified object (which should have type
HTTPHeaders
).Declaration
Swift
open var captureResponseHeaders: AnyObject? { get set }
-
In offline scenarios, can this request be grouped with others having the same atomicity group? Intended as a performance optimization where grouping requests in a single transaction gives throughput benefits. Any such grouping is not guaranteed for requests having the same atomicity group, as there may be inter-request dependencies that prevent the grouping.
Example using proxy classes
open func transactionExample(patient: Patient) throws -> Void { let service = self.healthService let transactionID = GuidValue.random().toString() let appointment1 = Appointment() appointment1.patient = patient try service.createEntity(appointment1, headers: nil, options: RequestOptions() .transaction(transactionID)) let appointment2 = Appointment() appointment2.patient = patient try service.createEntity(appointment2, headers: nil, options: RequestOptions() .transaction(transactionID)) // Some time later... Upload both appointments in the same backend transaction. try service.upload() }
Declaration
Swift
open var changeSet: String? { get set }
-
Declaration
Swift
open func copy() -> RequestOptions
Return Value
a new (mutable) request options object that is a copy of this request options object.
-
Set the
customTag
and return this options object.Declaration
Swift
open func custom(_ tag: String) -> RequestOptions
Parameters
tag
Custom tag.
Return Value
This options object.
-
Set this to a custom tag when submitting a request for later upload in an offline scenario.
Declaration
Swift
open var customTag: String? { get set }
-
Must entities for offline create requests be retained after successful upload? Defaults to
true
.Declaration
Swift
open var mustRetainCreates: Bool { get set }
-
Set the
canCombineRequests
property tofalse
and return this options object.Declaration
Swift
open func noCombine() -> RequestOptions
Return Value
This options object.
-
Set the
mustRetainCreates
property tofalse
and return this options object.Declaration
Swift
open func noRetain() -> RequestOptions
Return Value
This options object.
-
Declaration
Swift
open class func noneIfNull(options: RequestOptions?) -> RequestOptions
Parameters
options
Options to be checked.
Return Value
The
options
parameter, if non-nil
; otherwisenone
. -
Should create/update requests receive no content in the response? Defaults to
false
.Declaration
Swift
open var preferNoContent: Bool { get set }
-
Repeatability first sent time for this request.
See also
repeatable
.Declaration
Swift
open var repeatabilityFirstSent: GlobalDateTime? { get set }
-
Repeatability global request ID for this request.
See also
repeatable
.Declaration
Swift
open var repeatabilityRequestID: GuidValue? { get set }
-
Set the
repeatabilityRequestID
andrepeatabilityFirstSent
and return this options object.Declaration
Swift
open func repeatable(requestID: GuidValue, firstSent: GlobalDateTime) -> RequestOptions
Parameters
requestID
Value for
repeatabilityRequestID
.firstSent
Value for
repeatabilityFirstSent
.Return Value
This options object.
-
Should no-change update requests be sent to the server? Defaults to
false
.Declaration
Swift
open var sendEmptyUpdate: Bool { get set }
-
Set the
changeSet
and return this options object.Example using proxy classes
open func transactionExample(patient: Patient) throws -> Void { let service = self.healthService let transactionID = GuidValue.random().toString() let appointment1 = Appointment() appointment1.patient = patient try service.createEntity(appointment1, headers: nil, options: RequestOptions() .transaction(transactionID)) let appointment2 = Appointment() appointment2.patient = patient try service.createEntity(appointment2, headers: nil, options: RequestOptions() .transaction(transactionID)) // Some time later... Upload both appointments in the same backend transaction. try service.upload() }
Declaration
Swift
open func transaction(_ id: String) -> RequestOptions
Parameters
id
Transaction ID to be copied into
changeSet
.Return Value
This options object.
-
Set the
updateMode
and return this options object.Declaration
Swift
open func update(_ mode: UpdateMode) -> RequestOptions
Parameters
mode
Update mode.
Return Value
This options object.
-
Determines if updates use merge (HTTP PATCH) or replace (HTTP PUT) semantics. Defaults to merge semantics.
Declaration
Swift
open var updateMode: UpdateMode { get set }
-
Set the
uploadGroup
and return this options object.Example using proxy classes
open func uploadGroupExample(patient: Patient) throws -> Void { let service = self.healthService let appointment1 = Appointment() appointment1.patient = patient appointment1.purpose = "Fix Broken Leg" try service.createEntity(appointment1, headers: nil, options: RequestOptions() .upload("Urgent")) let appointment2 = Appointment() appointment2.patient = patient appointment2.purpose = "Check Sore Arm" try service.createEntity(appointment2, headers: nil, options: RequestOptions() .upload("Non-Urgent")) // Some time later... Upload only the urgent appointments. try service.upload(groups: StringList.of("Urgent")) }
Declaration
Swift
open func upload(_ group: String) -> RequestOptions
Parameters
group
Upload group.
Return Value
This options object.
-
In offline scenarios, can this request be grouped with others to enable selective uploading by group name?
Example using proxy classes
open func uploadGroupExample(patient: Patient) throws -> Void { let service = self.healthService let appointment1 = Appointment() appointment1.patient = patient appointment1.purpose = "Fix Broken Leg" try service.createEntity(appointment1, headers: nil, options: RequestOptions() .upload("Urgent")) let appointment2 = Appointment() appointment2.patient = patient appointment2.purpose = "Check Sore Arm" try service.createEntity(appointment2, headers: nil, options: RequestOptions() .upload("Non-Urgent")) // Some time later... Upload only the urgent appointments. try service.upload(groups: StringList.of("Urgent")) }
Declaration
Swift
open var uploadGroup: String? { get set }
-
Set
useBatchRequest
totrue
and this options object.Declaration
Swift
open func useBatch() -> RequestOptions
Return Value
This options object.
-
Should this request be tunneled inside a batch request, e.g. for security reasons.
Declaration
Swift
open var useBatchRequest: Bool { get set }