API
class API
This is api file to generate apis for the app
-
This is
X5GONAPIAdapterDeclaration
Swift
static let oldAdapter: X5GONAPIAdapter.Type -
This is
X5LearnAPIAdapterDeclaration
Swift
static let newAdapter: X5LearnAPIAdapter.Type -
This is Authentication Token
Declaration
Swift
static var authenticationToken: String -
Fetching the content using given
keywordsandcontentTypeand return a list ofContentUsage Example:
API.fetchContents ("science", "pdf")Declaration
Swift
static func fetchContents(keyWord: String, contentType: String, fetchSwitch: @escaping (URLSessionDataTask, DispatchSemaphore) -> Void) -> [Content]Parameters
keyWordStringKeyword that used for searching in the X5GON backendcontentTypeStringType of the content, current support format isaudio,video,text(This will be converted into pdf)Return Value
list of
Content -
Using
featuredURLto request from X5GON backend and return with a list ofContentUsage Example:
let content = API.fetchFeaturedContents ()Declaration
Swift
static func fetchFeaturedContents(fetchSwitch: @escaping (URLSessionDataTask, DispatchSemaphore) -> Void) -> [Content]Return Value
List of
Content -
Creating
CSRFTokenfor loginUsage Example:
let csrfToken = API.fetchCSRFToken()Declaration
Swift
static func fetchCSRFToken() -> StringReturn Value
CSRFToken type : String
-
Logout
Usage Example:
API.logout()Declaration
Swift
static func logout() -
Get login authenticationToken
Usage Example:
let authenticationToken = API.fetchLoginTokenWith(username,password,csrfToken)Declaration
Swift
static func fetchLoginTokenWith(username: String, password: String, csrfToken: String) -> StringParameters
usernameUsername type:
Stringread from UITextFieldpasswordPasssword type
Stringread from UITextFieldcsrfTokencsrfToken type
Stringgenerated by calling API.csrfToken( )Return Value
login authenticationToken in String type
-
create notes with cotent id
Declaration
Swift
static func createNotes(id _: Int, text _: String) -
Get notes with content id
Declaration
Swift
static func getNotes(id _: Int) -> String -
Update Bookmark Info
Usage Example:
API.updateBookmark(13, true)Declaration
Swift
static func updateBookmark(id: Int, bookmark: Bool)Parameters
idContent id
bookmarkBoolto show if the content is bookmarked -
Fetching content
Usage Example:
let content = API.DEPRECATED_fetchContents("science")Declaration
Swift
static func DEPRECATED_fetchContents(keyWord: String) -> [Content]Parameters
keyWordkeyword used to search
Return Value
login authenticationToken in String type
-
Fetching content
Usage Example:
let content = API.DEPRECATED_fetchContents("science","pdf")Declaration
Swift
static func DEPRECATED_fetchContents(keyWord: String, contentType: String) -> [Content]Parameters
keyWordStringKeyword that used for searching in the X5GON backendcontentTypeStringType of the content, current support format isaudio,video,text(This will be converted into pdf)Return Value
login authenticationToken in String type
-
Declaration
Swift
static func TBD_report(id _: Int, reason _: String)Parameters
idContent id
reasonString, the reason you report this contentReturn Value
Nil
-
Declaration
Swift
static func TBD_vote(id _: Int, vote _: Bool)Parameters
idContent id
voteBool, true for UpVoting and false for DownVotingReturn Value
Nil
API Class Reference