APIManager
public class APIManager
extension APIManager: RequestInterceptor
Main class of framework, which allow to play with the 4D rest api.
-
Default instance of
Selfwhich useURL.qmobileas base urlDeclaration
Swift
public static var instance: APIManager { get set } -
Delegates.
Declaration
Swift
public weak var delegate: APIManagerDelegate?
-
Alias for network completion request callback.
Declaration
Swift
public typealias Completion = (Result<Moya.Response, APIError>) -> Swift.Void -
Alias for network progression request callback.
Declaration
Swift
public typealias ProgressHandler = Moya.ProgressBlock -
Alias to customize records request
Declaration
Swift
public typealias ConfigureRecordsRequest = (RecordsRequest) -> Void
-
Create an api manager using server URL
Declaration
Swift
public init(url: URL)
-
Target for all rest request.
Declaration
Swift
public let base: BaseTarget -
Target to get info from web server
Declaration
Swift
public let webTest: WebTestTarget -
Lattest info from server
Declaration
Swift
public var webTestInfo: WebTestInfo?
-
Token for authentication
Declaration
Swift
public var authToken: AuthToken? { get set } -
Return if api shared instance has valid token ie. we are logged
Declaration
Swift
public static var isSignIn: Bool { get } -
Remove auth token from keychain.
Declaration
Swift
public static func removeAuthToken()
-
Activate stub response for test.
Declaration
Swift
public var stub: Bool -
A delegate to customize stub feature to test.
Declaration
Swift
public weak var stubDelegate: StubDelegate?
-
Log level for network. By default .verbose. Pref key: api.network.logLevel
Declaration
Swift
public lazy var networkLogLevel: LogLevel { get set } -
List of Moya plugins.
Declaration
Swift
public var plugins: [PluginType] -
Undocumented
Declaration
Swift
public var defaultQueue: DispatchQueue? -
URL session configuration. Configure timeout, and other properties
Declaration
Swift
public lazy var configuration: URLSessionConfiguration { get set }
-
Return the
ServerTrustManagerDeclaration
Swift
open func serverTrustManager() -> ServerTrustManager? -
Create a moya
SessionDeclaration
Swift
open func session() -> Moya.Session -
Undocumented
Declaration
Swift
open func initPlugins() -
Undocumented
Declaration
Swift
public typealias CompletionApplicationInfoHandler = ((Result<ApplicationInfo, APIError>) -> Void) -
Get server status
Declaration
Swift
public func loadApplicationInfo(actionName: String = "mdm_application", bundleId: String, callbackQueue: DispatchQueue? = nil, completionHandler: @escaping CompletionApplicationInfoHandler) -> Cancellable -
Call mobile action by name.
Declaration
Swift
public typealias CompletionActionHandler = ((Result<ActionResult, APIError>) -> Void) -
Undocumented
Declaration
Swift
public func action(name: String, parameters: ActionParameters = [:], encodeParameters: Bool = true, httpMethod: Moya.Method = ActionAbstractTarget.defaultMethod, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionActionHandler) -> Cancellable -
Call mobile action.
Declaration
Swift
public func action(_ action: Action, parameters: ActionParameters = [:], httpMethod: Moya.Method = ActionAbstractTarget.defaultMethod, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionActionHandler) -> Cancellable -
Call mobile action request.
Declaration
Swift
public func action(_ request: ActionRequest, httpMethod: Moya.Method = ActionAbstractTarget.defaultMethod, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionActionHandler) -> Cancellable -
Authentificate with login and password.
Declaration
Swift
open func authentificate(login: String, password: String? = nil, send: AuthTarget.Send = .link, parameters: [String: Any]? = nil, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionAuthTokenHandler) -> Cancellable -
Authentificate with token.
Declaration
Swift
open func authentificate(token: String, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionAuthTokenHandler) -> Cancellable -
Undocumented
Declaration
Swift
open func logout(token: String? = nil, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionLogOutHandler) -> Cancellable -
Get server status
Declaration
Swift
func status(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<Status, APIError> -
Get server info
Declaration
Swift
func info(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<Info, APIError> -
Get server session info
Declaration
Swift
func sessionInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<[SessionInfo], APIError> -
Get server Progress Info
Declaration
Swift
func progressInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<[ProgressInfo], APIError> -
Get server Cache Info
Declaration
Swift
func cacheInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<[CacheInfo], APIError> -
Get server Entity Set Info
Declaration
Swift
func entitySetInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<EntitySetInfo, APIError> -
Get the catalog, list description of URI for tables and records
Declaration
Swift
func catalog(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<[Catalog], APIError> -
Get all tables
Declaration
Swift
func tables(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<[Table], APIError> -
Get one table by name @param table the wanted table name
Declaration
Swift
func table(name: String, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<Table, APIError> -
Get deleted records
Declaration
Swift
func deletedRecordPage(configure: ConfigureRecordsRequest? = nil, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<Page, APIError> -
Upload data to the server. Could be an image or a blob. An id will be returned to use to associate this upload to record field or action parameters.
Declaration
Swift
func upload(data: Data, image: Bool = false, mimeType: String?, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<UploadResult, APIError> -
Upload file url data to server. An id will be returned to use to associate this upload to record field or action parameters.
Declaration
Swift
func upload(url: URL, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> Future<UploadResult, APIError> -
Get the records into simple structures. Only one page is loaded. You must get information from page to configure next request. @param tableName the table name @param attribute get only this attributes @param recursive receive all page until last one (default: false) @param configure closure to configure the request
Declaration
Swift
func recordPage(tableName: String, attributes: [String: Any] = [:], setID: QMobileAPI.EntitySetIdConvertible? = nil, recursive: Bool = false, configure: QMobileAPI.APIManager.ConfigureRecordsRequest? = nil, callbackQueue: DispatchQueue? = nil, progress: QMobileAPI.APIManager.ProgressHandler? = nil) -> Future<Page, APIError> -
Undocumented
Declaration
Swift
static func status(for urls: [URL], callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil) -> AnyPublisher<[URL : Result<Status, APIError>], Never> -
create new record
Declaration
Swift
public func createRecordJSON( table: Table, key: CustomStringConvertible, completionHandler: @escaping CompletionRecordJSONHandler) -> Cancellable -
Create or update a record
Declaration
Swift
public func createOrUpdate( recordJSON: RecordJSON, callbackQueue: DispatchQueue? = nil, completionHandler: CompletionRecordJSONHandler? = nil) -> Cancellable -
Alias for [RecordJSON]
Declaration
Swift
public typealias CompletionRecordJSONsHandler = ((Result<[RecordJSON], APIError>) -> Void) -
Undocumented
Declaration
Swift
public func createOrUpdate( recordJSONs: [RecordJSON], callbackQueue: DispatchQueue? = nil, completionHandler: CompletionRecordJSONsHandler? = nil) -> Cancellable -
create a new entityset (could be done by using configuration of RecordsRequest of
loadPage`)Declaration
Swift
public func createEntitySet( tableName: String, callbackQueue: DispatchQueue? = nil, configure: ConfigureRecordsRequest? = nil, completionHandler: @escaping CompletionPageHandler) -> Cancellable -
Undocumented
Declaration
Swift
public func delete(recordJSON: RecordJSON, completionHandler: CompletionStatusHandler? = nil) -> Cancellable? -
Undocumented
Declaration
Swift
public func deleteRecord( tableName: String, key: CustomStringConvertible, callbackQueue: DispatchQueue? = nil, completionHandler: CompletionStatusHandler? = nil) -> Cancellable -
delete records
Declaration
Swift
public func deleteRecords( tableName: String, configure: ConfigureRecordsRequest? = nil, callbackQueue: DispatchQueue? = nil, completionHandler: CompletionStatusHandler? = nil) -> Cancellable -
delete entity set
Declaration
Swift
public func delete(entitySet: EntitySet, callbackQueue: DispatchQueue? = nil, completionHandler: CompletionStatusHandler? = nil) -> Cancellable -
delete entity set
Declaration
Swift
public func deleteEntitySet( tableName: String, setID: String, callbackQueue: DispatchQueue? = nil, completionHandler: CompletionStatusHandler? = nil) -> Cancellable -
release entity set
Declaration
Swift
public func release(entitySet: EntitySet, callbackQueue: DispatchQueue? = nil, completionHandler: CompletionStatusHandler? = nil) -> Cancellable -
release entity set
Declaration
Swift
public func releaseEntitySet( tableName: String, setID: String, callbackQueue: DispatchQueue? = nil, completionHandler: CompletionStatusHandler? = nil) -> Cancellable -
Get server status
Declaration
Swift
public func status(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionStatusHandler) -> Cancellable -
Get server info
Declaration
Swift
public func info(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionInfoHandler) -> Cancellable -
Undocumented
Declaration
Swift
public typealias CompletionSessionInfoHandler = ((Result<[SessionInfo], APIError>) -> Void) -
Get server session info
Declaration
Swift
public func sessionInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionSessionInfoHandler) -> Cancellable -
Undocumented
Declaration
Swift
public typealias CompletionProgressInfoHandler = ((Result<[ProgressInfo], APIError>) -> Void) -
Get server Progress Info
Declaration
Swift
public func progressInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionProgressInfoHandler) -> Cancellable -
Get server Cache Info
Declaration
Swift
public func cacheInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionCacheInfoHandler) -> Cancellable -
Undocumented
Declaration
Swift
public typealias CompletionEntitySetInfoHandler = ((Result<EntitySetInfo, APIError>) -> Void) -
Get server Entity Set
Declaration
Swift
public func entitySetInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionEntitySetInfoHandler) -> Cancellable -
Get the catalog, list description of URI for tables and records
Declaration
Swift
public func catalog(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionCatalogHandler) -> Cancellable -
Get all tables
Declaration
Swift
public func tables(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionTablesHandler) -> Cancellable -
Get one table by name @param table the wanted table name
Declaration
Swift
public func table(name: String, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionTableHandler) -> Cancellable -
Alias for record json result.
Declaration
Swift
public typealias CompletionRecordJSONHandler = ((Result<RecordJSON, APIError>) -> Void) -
Get one record into simple structures @param table the table @param key the primary key of wanted record @param attribute get only this attributes
Declaration
Swift
public func recordJSON( table: Table, key: CustomStringConvertible, attributes: [String: Any] = [:], callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionRecordJSONHandler) -> Cancellable -
Get the records into simple structures. You must get information from page to configure next request. @param table the table @param attribute get only this attributes @param recursive receive all page until last one (default: false) @param configure closure to configure the request
Declaration
Swift
public func recordPage( table: Table, attributes: [String: Any] = [:], setID: EntitySetIdConvertible? = nil, recursive: Bool = false, configure: ConfigureRecordsRequest? = nil, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionPageHandler) -> Cancellable -
recordPage(tableName:attributes: setID: recursive: configure: callbackQueue: progress: completionHandler: ) Get the records into simple structures. Only one page is loaded. You must get information from page to configure next request. @param tableName the table name @param attribute get only this attributes @param recursive receive all page until last one (default: false) @param configure closure to configure the request
Declaration
Swift
public func recordPage( tableName: String, attributes: [String: Any] = [:], setID: EntitySetIdConvertible? = nil, recursive: Bool = false, configure: ConfigureRecordsRequest? = nil, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionPageHandler) -> Cancellable -
Get the deleted records information into simple structures. Only one page is loaded. You must get information from page to configure next request. @param configure closure to configure the request
Declaration
Swift
public func deletedRecordPage( configure: ConfigureRecordsRequest? = nil, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionPageHandler) -> Cancellable -
Compute an operation on specific attribute of one table. @param table the table @param attribute the attribute @param operation the operation to execute
Declaration
Swift
public func compute(table: String, attribute: String, operation: ComputeOperation, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionComputeHandler) -> Cancellable -
Alias for
UploadResultrequest resultDeclaration
Swift
public typealias CompletionUploadResultHandler = ((Result<UploadResult, APIError>) -> Void)
-
Upload data to the server. Could be an image or a blob. An id will be returned to use to associate this upload to record field or action parameters.
Declaration
Swift
public func upload(data: Data, image: Bool = false, mimeType: String?, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionUploadResultHandler) -> Cancellable -
Upload file url data to server. An id will be returned to use to associate this upload to record field or action parameters.
Declaration
Swift
public func upload(url: URL, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionUploadResultHandler) -> Cancellable -
Alias for UserInfoResult
Declaration
Swift
public typealias CompletionUserInfoHandler = ((Result<UserInfoResult, APIError>) -> Void) -
POST userInfo on server
Declaration
Swift
public func userInfo(_ userInfo: [String: Any]? = nil, deviceToken: String? = nil, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionUserInfoHandler) -> Cancellable -
POST deviceToken on server
Declaration
Swift
public func sendDeviceToken(_ deviceToken: String? = nil, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionUserInfoHandler) -> Cancellable -
Call method on table.
Declaration
Swift
public func method(table: String, name: String, parameters: [String: Any] = [:], httpMethod: Moya.Method = Moya.Method.get, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping APIManager.Completion) -> Cancellable -
Undocumented
Declaration
Swift
public func method(table: Table, method: TableMethod, parameters: [String: Any] = [:], httpMethod: Moya.Method = Moya.Method.get, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping APIManager.Completion) -> Cancellable -
Notify about log in success
Declaration
Swift
public static let loginSuccess: Notification.Name -
Notify about log in wait for validation
Declaration
Swift
public static let loginPending: Notification.Name -
Notify about log in failure
Declaration
Swift
public static let loginFailed: Notification.Name -
Notify about log out
Declaration
Swift
public static let logout: Notification.Name -
Notify default instance change.
Declaration
Swift
public static let didChangeDefaultInstance: Notification.Name -
Observe
APIManageron specific event usung closure.Declaration
Swift
public static func observe(_ name: Notification.Name, queue: OperationQueue? = nil, using: @escaping (Notification) -> Void) -> NSObjectProtocol -
Unobserve
APIManagerby passing the handle returned byobervefunction.Declaration
Swift
public static func unobserve(_ observer: NSObjectProtocol) -
Unobserve
APIManagerby passing the handle returned byobervefunction.Declaration
Swift
public static func unobserve(_ observers: [NSObjectProtocol]) -
Undocumented
Declaration
Swift
public func reachability(handler: @escaping NetworkReachabilityManager.Listener) -> Cancellable? -
Start reachability task.
Declaration
Swift
public static func reachability(handler: @escaping NetworkReachabilityManager.Listener) -> Cancellable? -
Declaration
Swift
public func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -> Void) -
Find a target from an URL path. path could come from /rest api json data.
Declaration
Swift
public func target(for path: URLPath) -> TargetType? -
Undocumented
Declaration
Swift
public func target(for deffered: Deferred) -> TargetType? -
Undocumented
Declaration
Swift
public func target(for url: URL) -> TargetType? -
Undocumented
Declaration
Swift
public typealias CompletionWebTestInfoHandler = ((Result<WebTestInfo, APIError>) -> Void) -
Get server status
Declaration
Swift
public func loadWebTestInfo(callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping CompletionWebTestInfoHandler) -> Cancellable -
Configure a custom URL request with all needed headers.
Declaration
Swift
open func configure(request: URLRequest) -> URLRequest
-
Make a request.
Declaration
Swift
public func request<T>(_ target: T, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completion: @escaping APIManager.Completion) -> Cancellable where T : TargetTypeParameters
targetthe target.
callbackQueuean optional queue for callback
progresscallback to receive progression info
completioncompletion callback to receive raw moya response.
Return Value
a cancellable object for this request.
-
Make a request.
Declaration
Swift
public func request<T>(_ target: T, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completion: @escaping (Result<T.ResultType, APIError>) -> Void) -> Cancellable where T : DecodableTargetTypeParameters
targetthe target.
callbackQueuean optional queue for callback
progresscallback to receive progression info
completioncompletion callback to receive data as decoded object.
Return Value
a cancellable object for this request.
-
Make a request.
Declaration
Swift
public func request<T>(_ target: T, callbackQueue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completion: @escaping (Result<[T.ResultType], APIError>) -> Void) -> Cancellable where T : DecodableTargetTypeParameters
targetthe target.
callbackQueuean optional queue for callback
progresscallback to receive progression info
completioncompletion callback to receive data as a collection of decoded object.
Return Value
a cancellable object for this request.
-
Get records using specific object builder. This avoid passing by an intermediate object RecordObject which contains only JSON data.
Declaration
Swift
public func records<B: ImportableBuilder>( table: Table, attributes: [String: Any] = [:], setID: String? = nil, recursive: Bool = true, configure: ((RecordsRequest) -> Void)? = nil, initializer: B, queue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping ((Result<([B.Importable], PageInfo), APIError>) -> Void)) -> Cancellable -
Undocumented
Declaration
Swift
public func loadRecord<B: ImportableBuilder>( table: Table, key: CustomStringConvertible, attributes: [String: Any] = [:], initializer: B, queue: DispatchQueue? = nil, progress: ProgressHandler? = nil, completionHandler: @escaping ((Result<B.Importable, APIError>) -> Void)) -> Cancellable
APIManager Class Reference