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
:
Password
Username
SQLStatement
writeFile
: 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
:
Password
Username
SQLStatement
websiteUserName
: 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?) -> Void
returnData
: The returned JSON Serialized data. This data is usually an array of Dictionarieserror
: An error when downloaded, if anypublic typealias MSFrameworkUploadCompletion = (_ success: Bool) -> Void
success
: Whether the upload failed or succeededpublic func saveCoreData() throws
public let dataDownloader : MSDataDownloader
public let dataUploader : MSDataUploader
public 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` : MSFrameworkManager
public func enableDebug()
public func encrypt(string: String) -> String
string
: A plain text stringpublic func encrypt(object: Any) -> String
object
: An NSObject
(Any
in Swift) objectpublic func decrypt(string: String) -> String
string
: 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
+readFile
completion
. 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
+writeFile
completion
. 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 : Error
public enum MSSQLConjunction : String
JOIN
and WHERE
public enum MSSQLJoin : String
JOIN
typespublic enum MSSQLEquivalence : String
public struct MSSQLClause
XX=XX
clausepublic struct Join
JOIN `XXXX` ON XX=XX
clausepublic struct Where
WHERE XX=XX
clausepublic func append(_ sqlStatement : MSSQL)
sqlStatement
: An MSSQL object. Immutable once placed in the listSELECT ...
public func select(_ attribute: String) throws -> MSSQL
attribute
: 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 -> MSSQL
attributes
: 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 -> MSSQL
table
: 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 -> MSSQL
tables
: 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 ... SET
public func update(_ table: String, leftHandSide: String, rightHandSide: String) throws -> MSSQL
table
: 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 -> MSSQL
tables
: 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 -> MSSQL
table
: 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 ... ON
public func join(_ join: MSSQLJoin, table: String, leftHandSide: String, rightHandSide: String) throws -> MSSQL
table
: 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 -> MSSQL
join
: 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 lengthWHERE
public func `where`(_ equivalence: MSSQLEquivalence, leftHandSide: String, rightHandSide: String) throws -> MSSQL
equivalence
: 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 -> MSSQL
custom
: 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.