API

class API

This is api file to generate apis for the app

  • This is X5GONAPIAdapter

    Declaration

    Swift

    static let oldAdapter: X5GONAPIAdapter.Type
  • Declaration

    Swift

    static let newAdapter: X5LearnAPIAdapter.Type
  • This is Authentication Token

    Declaration

    Swift

    static var authenticationToken: String
  • Fetching the content using given keywords and contentType and return a list of Content

    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 backend

    contentType

    String Type of the content, current support format is audio,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 of Content

    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 login

    Usage 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 UITextField

    password

    Passsword type String read from UITextField

    csrfToken

    csrfToken type String generated by calling API.csrfToken( )

    Return Value

    login authenticationToken in String type

  • Fetch User Json sent from X5GON backend, to get user’s login status , name, email and profile picture

    ### Usage Example: ###

     let user = API.fetchUser()
    

    Declaration

    Swift

    static func fetchUser() -> User

    Return Value

    Type User

  • 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 backend

    contentType

    String Type of the content, current support format is audio,video,text(This will be converted into pdf)

    Return Value

    login authenticationToken in String type

  • Fetch WikichunkEnrichments

    Usage Example:

    let content = API.fetchWikiChunkEnrichments([Int])
    

    Declaration

    Swift

    static func fetchWikiChunkEnrichments(ids: [Int]) -> Wiki

    Parameters

    ids

    Return Value

    Self defined type Wiki

  • Report a Content

    Usage Example:

    API.TBD_report(8, "Just want to report it")
    

    Declaration

    Swift

    static func TBD_report(id _: Int, reason _: String)

    Parameters

    id

    Content id

    reason

    String , the reason you report this content

    Return Value

    Nil

  • Vote for a Content

    Usage Example:

    API.TBD_vote(8, True)
    

    Declaration

    Swift

    static func TBD_vote(id _: Int, vote _: Bool)

    Parameters

    id

    Content id

    vote

    Bool, true for UpVoting and false for DownVoting

    Return Value

    Nil