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
urlFull URL, including path, of API request
methodHTTP method for the request
headersAdditional HTTP headers for the request in dictionary
bodyParamsHTTP body in dictionary
urlParamsURL parameters in dictionary
requestTypeContentType of request content; enumeration value of
ContentTyperesponseTypeContentType of expected response content; enumeration value of
ContentTypetimeoutIntervalTimeout 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
headersmerged HTTP header dictionary
-
Builds
URLRequestobject based onRequestinstanceDeclaration
Swift
public func build() -> URLRequest?Return Value
URLRequest object if
Requestobject was valid; otherwisenilis returned
View on GitHub