The protocol an object must implement in order for MSFramework to properly communicate with the web service
website: The base URL the application will be communicating withreadFile: The relative path to a file in the URL that takes a POST object containing`databaseUserPass, websiteUserName, and an SQL statement and returns a JSON formatted object.POST:
PasswordUsernameSQLStatementwriteFile: The relative path to a file in the URL that takes a POST object containing databaseUserPass, websiteUserName, and an SQL statement and processes the SQL statement returning "Success" if the SQLStatement is successfully ran or "Failure" if it failsPOST:
PasswordUsernameSQLStatementwebsiteUserName: The username to log into a protected directory. This value is only used if needed.websiteUserPass: The password to log into a protected directory. This value is only used if needed.databaseUserPass: MySQL databases require user login and password to access the databse schema. MSFramework assumes the login websiteUserName combined with this passwordcoreDataModelName: The file name of your project's CoreData modelencryptionCode: A String containing 32 characters ([A-Za-z0-9] & special characters) that is used to encrypt and decrypt data on deviceiv: The initialization vector for MSFramework's encryptionThe main class through which the API is levereged
public typealias MSFrameworkDownloadCompletion = (_ returnData: [Any]?,_ error: Error?) -> VoidreturnData: The returned JSON Serialized data. This data is usually an array of Dictionarieserror: An error when downloaded, if anypublic typealias MSFrameworkUploadCompletion = (_ success: Bool) -> Voidsuccess: Whether the upload failed or succeededpublic func saveCoreData() throwspublic let dataDownloader : MSDataDownloaderpublic let dataUploader : MSDataUploaderpublic var dataSource : MSFrameworkDataSource!MSFramework contains all necessary information for MSFramework to communicate with your application's web servicepublic var managedObjectContext : NSManagedObjectContext?public static let `default` : MSFrameworkManagerpublic func enableDebug()public func encrypt(string: String) -> Stringstring: A plain text stringpublic func encrypt(object: Any) -> Stringobject: An NSObject (Any in Swift) objectpublic func decrypt(string: String) -> Stringstring: The HEX String returned from encrypt(string:)public func decrypt(object: String) -> Any?object: The HEX String returned from encrypt(object:)nil if the string isn't an encrypted objectpublic func retrieveList(attribute: String, onEntity entity: String) -> [Any]attribute: The attribute to recall values fromentity: The entity name to search inThe data downloader class
MSDataDownloader connects to a URL, sends a POST request, downloads JSON formatted data, then converts that data into an NSArray and returns it via a completionHandler
public func download(sqlStatement: MSSQL, completion: @escaping MSFrameworkDownloadCompletion)website+readFilecompletion. completion will always be ran on the main threadsqlStatement: An MSSQL object that contains a built SQL statementcompletion: A block to be called when all data has been downloadedThe data uploader class
MSDataUploader connects to a URL, sends a POST request containing the SQL statement to run, downloads Success or Failure, and calls completion with a Bool parameter based upon that
public func upload(sqlStatement: MSSQL, completion: @escaping MSFrameworkUploadCompletion)website+writeFilecompletion. completion will always be ran on the main threadsqlStatement: An MSSQL object that contains a built SQL statementcompletion: A block to be called when returned either Success or FailureAn SQL wrapper that provides security, overload safety, and sanitization
public enum MSSQLError : Errorpublic enum MSSQLConjunction : StringJOIN and WHEREpublic enum MSSQLJoin : StringJOIN typespublic enum MSSQLEquivalence : Stringpublic struct MSSQLClauseXX=XX clausepublic struct JoinJOIN `XXXX` ON XX=XX clausepublic struct WhereWHERE XX=XX clausepublic func append(_ sqlStatement : MSSQL)sqlStatement: An MSSQL object. Immutable once placed in the listSELECT ...public func select(_ attribute: String) throws -> MSSQLattribute: the attribute to requestMSSQLError: If no attribute specified, * is used, is empty, or if attribute is greater than 64 characters in lengthpublic func select(_ attributes: [String]) throws -> MSSQLattributes: the attributes to requestMSSQLError: If no attributes specified, * is used, any attribute in attributes is empty, or if any attribute in attributes is greater than 64 characters in lengthFROM ...public func from(_ table: String) throws -> MSSQLtable: the table to queryMSSQLError: If no table specified, * is used, if table is empty, or if table is greater than 64 characters in lengthpublic func from(_ tables: [String]) throws -> MSSQLtables: the tables to queryMSSQLError: If no tables specified, * is used, any table in tables is empty, or if any table in tables is greater than 64 characters in lengthUPDATE ... SETpublic func update(_ table: String, leftHandSide: String, rightHandSide: String) throws -> MSSQLtable: the table to queryleftHandSide: the left hand side of the clauserightHandSide: the right hand side of the clauseMSSQLError: If a parameter is nil, already exists, * is used, is empty, or table | leftHandSide is greater than 64 characters in lengthpublic func update(_ table: String, set clauses: [MSSQLClause]) throws -> MSSQLtables: the tables to queryclauses: The clausesMSSQLError: If a parameter is nil, already exists, * is used, is empty, or the table | leftHandSide of any clause is greater than 64 characters in lengthINSERT INTO ...public func insert(_ table: String, values: [String], attributes: [String]) throws -> MSSQLtable: the table to insert the new row intovalues: the values for entryattributes: the attributes to setMSSQLError: If a parameter is null, already exists, values and attributes do not match in size, * is used, is empty, or table | any attribute in attributes is greater than 64 characters in length JOIN ... ONpublic func join(_ join: MSSQLJoin, table: String, leftHandSide: String, rightHandSide: String) throws -> MSSQLtable: the table to queryleftHandSide: the left hand side of the clauserightHandSide: the right hand side of the clauseMSSQLError: If a parameter is nil, already exists, * is used, is empty, or table | leftHandSide is greater than 64 characters in lengthpublic func join(_ join: MSSQLJoin, joins: [Join]) throws -> MSSQLjoin: the type of joinjoins: The joins to makeMSSQLError: If a parameter is null, already exists, * is used, is empty, or if the table | leftHandSide of any Join is greater than 64 characters in lengthWHEREpublic func `where`(_ equivalence: MSSQLEquivalence, leftHandSide: String, rightHandSide: String) throws -> MSSQLequivalence: The equivalence of the statementleftHandSide: the left hand side of the clauserightHandSide: the right hand side of the clauseMSSQLError: If a parameter is nil, already exists, * is used, is empty, or leftHandSide is greater than 64 characters in lengthpublic func `where`(_ `where`: MSSQLConjunction, equivalence: MSSQLEquivalence, leftHandSides: [String], rightHandSides: [String]) throws -> MSSQL`where`: The conjunction to use when joining successive WHERE statementsequivalence: The equivalence of each statementleftHandSides: The left hand sides of the clausesrightHandSides: The right hand sides of the clausesMSSQLError: If a parameter is nil, already exists, * is used, is empty, or if any leftHandSide in leftHandSides is greater than 64 characters in lengthpublic func `where`(custom: [Where]) throws -> MSSQLcustom: A collection of Where structs. The last Where struct MUST have .none as the conjunctionMSSQLError: If a parameter is null, already exists, * is used as the leftHandSide parameter of any Where, any parameter is empty, any leftHandSide is greater than 64 characters in length, or if the last Where struct does not have .none as its conjunction© 2021 Michael Schloss. All rights reserved.