Request
public struct Request
Generic representation of API request specifically designed by, and used by ForgeRock iOS SDK core
-
Enumeration for ContentType used in request/response
- plainText: “text/plain”
- json: “application/json”
- urlEncoded: “application/x-www-form-urlencoded”
Declaration
Swift
public enum ContentType : String
-
Declaration
Swift
public enum HTTPMethod : String
-
String value of request URL
Declaration
Swift
public let url: String
-
HTTP Method as String
Declaration
Swift
public let method: HTTPMethod
-
HTTP request headers as dictionary
Declaration
Swift
private(set) public var headers: [String : String] { get }
-
HTTP body parameters as dictionary
Declaration
Swift
public let bodyParams: [String : Any]
-
URL parameters as dictionary
Declaration
Swift
public let urlParams: [String : String]
-
Response type as
ContentType
; “Accept” header will be automatically addedDeclaration
Swift
public let responseType: ContentType?
-
Request type as
ContentType
; “Content-type” header will be automatically addedDeclaration
Swift
public let requestType: ContentType
-
Request timeout interval in second
Declaration
Swift
public let timeoutInterval: Double
-
Initializes a Request object to invoke API request
Declaration
Swift
public init(url: String, method: HTTPMethod, headers: [String : String] = [:], bodyParams: [String : Any] = [:], urlParams: [String : String] = [:], requestType: ContentType = .json, responseType: ContentType? = .json, timeoutInterval: Double = 60)
Parameters
url
Full URL, including path, of API request
method
HTTP method for the request
headers
Additional HTTP headers for the request in dictionary
bodyParams
HTTP body in dictionary
urlParams
URL parameters in dictionary
requestType
ContentType of request content; enumeration value of
ContentType
responseType
ContentType of expected response content; enumeration value of
ContentType
timeoutInterval
Timeout interval in second for the request
-
Updates and merges HTTP header with new header values
Declaration
Swift
public mutating func updateHeader(headers: [String : String])
Parameters
headers
merged HTTP header dictionary
-
Builds
URLRequest
object based onRequest
instanceDeclaration
Swift
public func build() -> URLRequest?
Return Value
URLRequest object if
Request
object was valid; otherwisenil
is returned