AppBaseApi
open class AppBaseApi
Basic Api class.
Handles remote HTTP requests using Apple APIs.
-
Inits the class using the given the root url.
Declaration
Swift
public init(_ rootUrl: String)Parameters
rootUrlThe server base url.
-
Performs a
HTTP GETrequest to the given path. If the requests succeeds, thecompletionblock will be called after converting the result using the given transformer. If the request fails, the ‘errorHandler’ block will be called instead.Declaration
Swift
open func get<Type, TransformerType>( _ targetUrl: String, responseTransformer: TransformerType, success: @escaping ((Type) -> Void), failure: @escaping ((Error) -> Void), retryAttempts: Int) where TransformerType: Transformer, TransformerType.IType == AnyObject?, TransformerType.OType == TypeParameters
targetUrlThe request path.
responseTransformerthe
Transformerthat will be used to transform the returned value from the request into the object thecompletionexpects.successThe block to be called if request succeeds.
failureThe block to be called if request fails.
retryAttemptsHow many tries before calling
errorblock. -
Performs a
HTTP GETrequest to the given path. If the requests succeeds, thecompletionblock will be called after converting the result using the given transformer. If the request fails, the ‘errorHandler’ block will be called instead.Declaration
Swift
open func get<Type, TransformerType>( _ targetUrl: String, responseTransformer: TransformerType, parameters: [String: Any]?, headers: [String: String]?, success: @escaping ((Type) -> Void), failure: @escaping ((Error) -> Void), retryAttempts: Int) where TransformerType: Transformer, TransformerType.IType == AnyObject?, TransformerType.OType == TypeParameters
targetUrlThe request path.
responseTransformerthe
Transformerthat will be used to transform the returned value from the request into the object thecompletionexpects.parametersParameters to be sent with the request.
headersHttp Headers to be sent with the request.
successThe block to be called if request succeeds.
failureThe block to be called if request fails.
retryAttemptsHow many tries before calling
errorHandlerblock. -
Performs a
HTTP GETrequest to the given path. If the requests succeeds, thecompletionblock will be called after converting the result using the given transformer. If the request fails, the ‘errorHandler’ block will be called instead.Declaration
Swift
open func get<Type, TransformerType>( _ endpointUrl: String, targetUrl: String, responseTransformer: TransformerType, parameters: [String: Any]?, headers: [String: String]?, success: @escaping ((Type) -> Void), failure: @escaping ((Error) -> Void), retryAttempts: Int) where TransformerType: Transformer, TransformerType.IType == AnyObject?, TransformerType.OType == TypeParameters
targetUrlThe request path.
responseTransformerthe
Transformerthat will be used to transform the returned value from the request into the object thecompletionexpects.parametersParameters to be sent with the request.
headersHttp Headers to be sent with the request.
successThe block to be called if request succeeds.
failureThe block to be called if request fails.
retryAttemptsHow many tries before calling
errorHandlerblock.
-
Performs a
HTTP POSTrequest to the given path. If the requests succeeds, thecompletionblock will be called after converting the result using the given transformer. If the request fails, the ‘errorHandler’ block will be called instead.Declaration
Swift
open func post<Type, TransformerType>( _ targetUrl: String, responseTransformer: TransformerType, success: @escaping ((Type) -> Void), failure: @escaping ((Error) -> Void), retryAttempts: Int) where TransformerType: Transformer, TransformerType.IType == AnyObject?, TransformerType.OType == TypeParameters
targetUrlThe request path.
responseTransformerthe
Transformerthat will be used to transform the returned value from the request into the object thecompletionexpects.successThe block to be called if request succeeds.
failureThe block to be called if request fails.
retryAttemptsHow many tries before calling
errorblock. -
Performs a
HTTP POSTrequest to the given path. If the requests succeeds, thecompletionblock will be called after converting the result using the given transformer. If the request fails, the ‘errorHandler’ block will be called instead.Declaration
Swift
open func post<Type, TransformerType>( _ targetUrl: String, responseTransformer: TransformerType, parameters: [String: Any]?, headers: [String: String]?, success: @escaping ((Type) -> Void), failure: @escaping ((Error) -> Void), retryAttempts: Int) where TransformerType: Transformer, TransformerType.IType == AnyObject?, TransformerType.OType == TypeParameters
targetUrlThe request path.
responseTransformerthe
Transformerthat will be used to transform the returned value from the request into the object thecompletionexpects.parametersParameters to be sent with the request.
headersHttp Headers to be sent with the request.
successThe block to be called if request succeeds.
failureThe block to be called if request fails.
retryAttemptsHow many tries before calling
errorHandlerblock. -
Performs a
HTTP POSTrequest to the given path. If the requests succeeds, thecompletionblock will be called after converting the result using the given transformer. If the request fails, the ‘errorHandler’ block will be called instead.Declaration
Swift
open func post<Type, TransformerType>( _ endpointUrl: String, targetUrl: String, responseTransformer: TransformerType, parameters: [String: Any]?, headers: [String: String]?, success: @escaping ((Type) -> Void), failure: @escaping ((Error) -> Void), retryAttempts: Int) where TransformerType: Transformer, TransformerType.IType == AnyObject?, TransformerType.OType == TypeParameters
targetUrlThe request path.
responseTransformerthe
Transformerthat will be used to transform the returned value from the request into the object thecompletionexpects.parametersParameters to be sent with the request.
headersHttp Headers to be sent with the request.
successThe block to be called if request succeeds.
failureThe block to be called if request fails.
retryAttemptsHow many tries before calling
errorHandlerblock.
-
executeRequest(httpMethod:_:targetUrl:responseTransformer:parameters:headers:success:failure:retryAttempts:)Performs a httpMethod kind request to the given path. If the requests succeeds, the
completionblock will be called after converting the result using the given transformer. If the request fails, the ‘errorHandler’ block will be called instead.Declaration
Swift
open func executeRequest<Type, TransformerType>( httpMethod: HttpMethod, _ endpointUrl: String, targetUrl: String, responseTransformer: TransformerType, parameters: [String: Any]?, headers: [String: String]?, success: @escaping ((Type) -> Void), failure: @escaping ((Error) -> Void), retryAttempts: Int) where TransformerType: Transformer, TransformerType.IType == AnyObject?, TransformerType.OType == TypeParameters
httpMethodHttp method to execute.
targetUrlThe request path.
responseTransformerthe
Transformerthat will be used to transform the returned value from the request into the object thecompletionexpects.parametersParameters to be sent with the request.
headersHttp Headers to be sent with the request.
successThe block to be called if request succeeds.
failureThe block to be called if request fails.
retryAttemptsHow many tries before calling
errorHandlerblock.
View on GitHub
AppBaseApi Class Reference