APIStub

open class APIStub

APIStub instance that is used to represent stubbed response. Any properties of this class is presented to serialization classes as if they would be received by URL loading system.

  • URLRequest object to use when request is being stubbed.

    Declaration

    Swift

    open var request: URLRequest?
  • HTTPURLResponse to use when request is being stubbed.

    Declaration

    Swift

    open var response: HTTPURLResponse?
  • Data to use when request is being stubbed. This property is ignored for DownloadAPIRequest.

    Declaration

    Swift

    open var data: Data?
  • Error to use when request is being stubbed.

    Declaration

    Swift

    open var error: Error?
  • File URL to use when stubbing DownloadAPIRequest. This property is ignored for APIRequest and UploadAPIRequest.

    Declaration

    Swift

    open var fileURL: URL?
  • Delay before stub is executed

    Declaration

    Swift

    open var stubDelay: TimeInterval
  • When this property is set to true, stub will be activated. Defaults to false.

    Declaration

    Swift

    open var isEnabled: Bool
  • Creates APIStub instance for APIRequest and UploadAPIRequest.

    Declaration

    Swift

    public init(request: URLRequest? = nil,
                response: HTTPURLResponse? = nil,
                data: Data? = nil,
                error: Error? = nil)

    Parameters

    request

    URLRequest object ot use when request is being stubbed. Defaults to nil.

    response

    HTTPURLResponse object to use when request is being stubbed. Defaults to nil.

    data

    Data object to use when request is being stubbed. Defaults to nil.

    error

    Error to use when request is being stubbed. Defaults to nil.

  • Creates APIStub instance for DownloadAPIRequest.

    Declaration

    Swift

    public init(request: URLRequest? = nil,
                response: HTTPURLResponse? = nil,
                fileURL: URL? = nil,
                error: Error? = nil)

    Parameters

    request

    URLRequest object ot use when request is being stubbed. Defaults to nil.

    response

    HTTPURLResponse object to use when request is being stubbed. Defaults to nil.

    fileURL

    File URL of downloaded file to use when request is being stubbed. Defaults to nil.

    error

    Error to use when request is being stubbed. Defaults to nil.