API
class API
This is api file to generate apis for the app
-
This is
X5GONAPIAdapter
Declaration
Swift
static let oldAdapter: X5GONAPIAdapter.Type
-
This is
X5LearnAPIAdapter
Declaration
Swift
static let newAdapter: X5LearnAPIAdapter.Type
-
This is Authentication Token
Declaration
Swift
static var authenticationToken: String
-
Fetching the content using given
keywords
andcontentType
and return a list ofContent
Usage Example:
API.fetchContents ("science", "pdf")
Declaration
Swift
static func fetchContents(keyWord: String, contentType: String, fetchSwitch: @escaping (URLSessionDataTask, DispatchSemaphore) -> Void) -> [Content]
Parameters
keyWord
String
Keyword that used for searching in the X5GON backendcontentType
String
Type of the content, current support format isaudio
,video
,text
(This will be converted into pdf)Return Value
list of
Content
-
Using
featuredURL
to request from X5GON backend and return with a list ofContent
Usage Example:
let content = API.fetchFeaturedContents ()
Declaration
Swift
static func fetchFeaturedContents(fetchSwitch: @escaping (URLSessionDataTask, DispatchSemaphore) -> Void) -> [Content]
Return Value
List of
Content
-
Creating
CSRFToken
for loginUsage Example:
let csrfToken = API.fetchCSRFToken()
Declaration
Swift
static func fetchCSRFToken() -> String
Return 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) -> String
Parameters
username
Username type:
String
read from UITextFieldpassword
Passsword type
String
read from UITextFieldcsrfToken
csrfToken type
String
generated 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
id
Content id
bookmark
Bool
to 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
keyWord
keyword 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
keyWord
String
Keyword that used for searching in the X5GON backendcontentType
String
Type 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
id
Content id
reason
String
, the reason you report this contentReturn Value
Nil
-
Declaration
Swift
static func TBD_vote(id _: Int, vote _: Bool)
Parameters
id
Content id
vote
Bool
, true for UpVoting and false for DownVotingReturn Value
Nil