//
// AccountsAPI.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

open class AccountsAPI {
    /**
     List accounts
     
     - parameter start: (query) Offset used to paginate results (optional)
     - parameter count: (query) Number of items to return (optional, default to 15)
     - parameter sort: (query) Sort column (optional)
     - parameter apiResponseQueue: The queue on which api response is dispatched.
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func accountsGet(start: Int? = nil, count: Int? = nil, sort: String? = nil, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: [Account]?, _ error: Error?) -> Void)) {
        accountsGetWithRequestBuilder(start: start, count: count, sort: sort).execute(apiResponseQueue) { result -> Void in
            switch result {
            case let .success(response):
                completion(response.body, nil)
            case let .failure(error):
                completion(nil, error)
            }
        }
    }

    /**
     List accounts
     - GET /accounts
     - parameter start: (query) Offset used to paginate results (optional)
     - parameter count: (query) Number of items to return (optional, default to 15)
     - parameter sort: (query) Sort column (optional)
     - returns: RequestBuilder<[Account]> 
     */
    open class func accountsGetWithRequestBuilder(start: Int? = nil, count: Int? = nil, sort: String? = nil) -> RequestBuilder<[Account]> {
        let path = "/accounts"
        let URLString = OpenAPIClientAPI.basePath + path
        let parameters: [String: Any]? = nil

        var url = URLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems([
            "start": start?.encodeToJSON(),
            "count": count?.encodeToJSON(),
            "sort": sort?.encodeToJSON(),
        ])

        let nillableHeaders: [String: Any?] = [
            :
        ]

        let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)

        let requestBuilder: RequestBuilder<[Account]>.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, headers: headerParameters)
    }

    /**
     Get an account
     
     - parameter name: (path) The username or handle of the account 
     - parameter apiResponseQueue: The queue on which api response is dispatched.
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func accountsNameGet(name: String, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: Account?, _ error: Error?) -> Void)) {
        accountsNameGetWithRequestBuilder(name: name).execute(apiResponseQueue) { result -> Void in
            switch result {
            case let .success(response):
                completion(response.body, nil)
            case let .failure(error):
                completion(nil, error)
            }
        }
    }

    /**
     Get an account
     - GET /accounts/{name}
     - parameter name: (path) The username or handle of the account 
     - returns: RequestBuilder<Account> 
     */
    open class func accountsNameGetWithRequestBuilder(name: String) -> RequestBuilder<Account> {
        var path = "/accounts/{name}"
        let namePreEscape = "\(APIHelper.mapValueToPathItem(name))"
        let namePostEscape = namePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
        path = path.replacingOccurrences(of: "{name}", with: namePostEscape, options: .literal, range: nil)
        let URLString = OpenAPIClientAPI.basePath + path
        let parameters: [String: Any]? = nil

        let url = URLComponents(string: URLString)

        let nillableHeaders: [String: Any?] = [
            :
        ]

        let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)

        let requestBuilder: RequestBuilder<Account>.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, headers: headerParameters)
    }

    /**
     * enum for parameter rating
     */
    public enum Rating_accountsNameRatingsGet: String, CaseIterable {
        case like = "like"
        case dislike = "dislike"
    }

    /**
     List ratings of an account
     
     - parameter name: (path) The username or handle of the account 
     - parameter start: (query) Offset used to paginate results (optional)
     - parameter count: (query) Number of items to return (optional, default to 15)
     - parameter sort: (query) Sort column (optional)
     - parameter rating: (query) Optionally filter which ratings to retrieve (optional)
     - parameter apiResponseQueue: The queue on which api response is dispatched.
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func accountsNameRatingsGet(name: String, start: Int? = nil, count: Int? = nil, sort: String? = nil, rating: Rating_accountsNameRatingsGet? = nil, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: [VideoRating]?, _ error: Error?) -> Void)) {
        accountsNameRatingsGetWithRequestBuilder(name: name, start: start, count: count, sort: sort, rating: rating).execute(apiResponseQueue) { result -> Void in
            switch result {
            case let .success(response):
                completion(response.body, nil)
            case let .failure(error):
                completion(nil, error)
            }
        }
    }

    /**
     List ratings of an account
     - GET /accounts/{name}/ratings
     - OAuth:
       - type: oauth2
       - name: OAuth2
     - parameter name: (path) The username or handle of the account 
     - parameter start: (query) Offset used to paginate results (optional)
     - parameter count: (query) Number of items to return (optional, default to 15)
     - parameter sort: (query) Sort column (optional)
     - parameter rating: (query) Optionally filter which ratings to retrieve (optional)
     - returns: RequestBuilder<[VideoRating]> 
     */
    open class func accountsNameRatingsGetWithRequestBuilder(name: String, start: Int? = nil, count: Int? = nil, sort: String? = nil, rating: Rating_accountsNameRatingsGet? = nil) -> RequestBuilder<[VideoRating]> {
        var path = "/accounts/{name}/ratings"
        let namePreEscape = "\(APIHelper.mapValueToPathItem(name))"
        let namePostEscape = namePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
        path = path.replacingOccurrences(of: "{name}", with: namePostEscape, options: .literal, range: nil)
        let URLString = OpenAPIClientAPI.basePath + path
        let parameters: [String: Any]? = nil

        var url = URLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems([
            "start": start?.encodeToJSON(),
            "count": count?.encodeToJSON(),
            "sort": sort?.encodeToJSON(),
            "rating": rating?.encodeToJSON(),
        ])

        let nillableHeaders: [String: Any?] = [
            :
        ]

        let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)

        let requestBuilder: RequestBuilder<[VideoRating]>.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, headers: headerParameters)
    }

    /**
     List video channels of an account
     
     - parameter name: (path) The username or handle of the account 
     - parameter withStats: (query) include view statistics for the last 30 days (only if authentified as the account user) (optional)
     - parameter start: (query) Offset used to paginate results (optional)
     - parameter count: (query) Number of items to return (optional, default to 15)
     - parameter sort: (query) Sort column (optional)
     - parameter apiResponseQueue: The queue on which api response is dispatched.
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func accountsNameVideoChannelsGet(name: String, withStats: Bool? = nil, start: Int? = nil, count: Int? = nil, sort: String? = nil, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: [VideoChannel]?, _ error: Error?) -> Void)) {
        accountsNameVideoChannelsGetWithRequestBuilder(name: name, withStats: withStats, start: start, count: count, sort: sort).execute(apiResponseQueue) { result -> Void in
            switch result {
            case let .success(response):
                completion(response.body, nil)
            case let .failure(error):
                completion(nil, error)
            }
        }
    }

    /**
     List video channels of an account
     - GET /accounts/{name}/video-channels
     - parameter name: (path) The username or handle of the account 
     - parameter withStats: (query) include view statistics for the last 30 days (only if authentified as the account user) (optional)
     - parameter start: (query) Offset used to paginate results (optional)
     - parameter count: (query) Number of items to return (optional, default to 15)
     - parameter sort: (query) Sort column (optional)
     - returns: RequestBuilder<[VideoChannel]> 
     */
    open class func accountsNameVideoChannelsGetWithRequestBuilder(name: String, withStats: Bool? = nil, start: Int? = nil, count: Int? = nil, sort: String? = nil) -> RequestBuilder<[VideoChannel]> {
        var path = "/accounts/{name}/video-channels"
        let namePreEscape = "\(APIHelper.mapValueToPathItem(name))"
        let namePostEscape = namePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
        path = path.replacingOccurrences(of: "{name}", with: namePostEscape, options: .literal, range: nil)
        let URLString = OpenAPIClientAPI.basePath + path
        let parameters: [String: Any]? = nil

        var url = URLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems([
            "withStats": withStats?.encodeToJSON(),
            "start": start?.encodeToJSON(),
            "count": count?.encodeToJSON(),
            "sort": sort?.encodeToJSON(),
        ])

        let nillableHeaders: [String: Any?] = [
            :
        ]

        let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)

        let requestBuilder: RequestBuilder<[VideoChannel]>.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, headers: headerParameters)
    }

    /**
     * enum for parameter nsfw
     */
    public enum Nsfw_accountsNameVideosGet: String, CaseIterable {
        case _true = "true"
        case _false = "false"
    }

    /**
     * enum for parameter filter
     */
    public enum Filter_accountsNameVideosGet: String, CaseIterable {
        case local = "local"
        case allLocal = "all-local"
    }

    /**
     * enum for parameter skipCount
     */
    public enum SkipCount_accountsNameVideosGet: String, CaseIterable {
        case _true = "true"
        case _false = "false"
    }

    /**
     * enum for parameter sort
     */
    public enum Sort_accountsNameVideosGet: String, CaseIterable {
        case name = "name"
        case duration = "-duration"
        case createdat = "-createdAt"
        case publishedat = "-publishedAt"
        case views = "-views"
        case likes = "-likes"
        case trending = "-trending"
        case hot = "-hot"
    }

    /**
     List videos of an account
     
     - parameter name: (path) The username or handle of the account 
     - parameter categoryOneOf: (query) category id of the video (see [/videos/categories](#tag/Video/paths/~1videos~1categories/get)) (optional)
     - parameter tagsOneOf: (query) tag(s) of the video (optional)
     - parameter tagsAllOf: (query) tag(s) of the video, where all should be present in the video (optional)
     - parameter licenceOneOf: (query) licence id of the video (see [/videos/licences](#tag/Video/paths/~1videos~1licences/get)) (optional)
     - parameter languageOneOf: (query) language id of the video (see [/videos/languages](#tag/Video/paths/~1videos~1languages/get)). Use &#x60;_unknown&#x60; to filter on videos that don&#39;t have a video language (optional)
     - parameter nsfw: (query) whether to include nsfw videos, if any (optional)
     - parameter filter: (query) Special filters which might require special rights:  * &#x60;local&#x60; - only videos local to the instance  * &#x60;all-local&#x60; - only videos local to the instance, but showing private and unlisted videos (requires Admin privileges)  * &#x60;all&#x60; - all videos, showing private and unlisted videos (requires Admin privileges)  (optional)
     - parameter skipCount: (query) if you don&#39;t need the &#x60;total&#x60; in the response (optional, default to ._false)
     - parameter start: (query) Offset used to paginate results (optional)
     - parameter count: (query) Number of items to return (optional, default to 15)
     - parameter sort: (query) Sort videos by criteria (optional)
     - parameter apiResponseQueue: The queue on which api response is dispatched.
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func accountsNameVideosGet(name: String, categoryOneOf: OneOfintegerarray? = nil, tagsOneOf: OneOfstringarray? = nil, tagsAllOf: OneOfstringarray? = nil, licenceOneOf: OneOfintegerarray? = nil, languageOneOf: OneOfstringarray? = nil, nsfw: Nsfw_accountsNameVideosGet? = nil, filter: Filter_accountsNameVideosGet? = nil, skipCount: SkipCount_accountsNameVideosGet? = nil, start: Int? = nil, count: Int? = nil, sort: Sort_accountsNameVideosGet? = nil, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: VideoListResponse?, _ error: Error?) -> Void)) {
        accountsNameVideosGetWithRequestBuilder(name: name, categoryOneOf: categoryOneOf, tagsOneOf: tagsOneOf, tagsAllOf: tagsAllOf, licenceOneOf: licenceOneOf, languageOneOf: languageOneOf, nsfw: nsfw, filter: filter, skipCount: skipCount, start: start, count: count, sort: sort).execute(apiResponseQueue) { result -> Void in
            switch result {
            case let .success(response):
                completion(response.body, nil)
            case let .failure(error):
                completion(nil, error)
            }
        }
    }

    /**
     List videos of an account
     - GET /accounts/{name}/videos
     - parameter name: (path) The username or handle of the account 
     - parameter categoryOneOf: (query) category id of the video (see [/videos/categories](#tag/Video/paths/~1videos~1categories/get)) (optional)
     - parameter tagsOneOf: (query) tag(s) of the video (optional)
     - parameter tagsAllOf: (query) tag(s) of the video, where all should be present in the video (optional)
     - parameter licenceOneOf: (query) licence id of the video (see [/videos/licences](#tag/Video/paths/~1videos~1licences/get)) (optional)
     - parameter languageOneOf: (query) language id of the video (see [/videos/languages](#tag/Video/paths/~1videos~1languages/get)). Use &#x60;_unknown&#x60; to filter on videos that don&#39;t have a video language (optional)
     - parameter nsfw: (query) whether to include nsfw videos, if any (optional)
     - parameter filter: (query) Special filters which might require special rights:  * &#x60;local&#x60; - only videos local to the instance  * &#x60;all-local&#x60; - only videos local to the instance, but showing private and unlisted videos (requires Admin privileges)  * &#x60;all&#x60; - all videos, showing private and unlisted videos (requires Admin privileges)  (optional)
     - parameter skipCount: (query) if you don&#39;t need the &#x60;total&#x60; in the response (optional, default to ._false)
     - parameter start: (query) Offset used to paginate results (optional)
     - parameter count: (query) Number of items to return (optional, default to 15)
     - parameter sort: (query) Sort videos by criteria (optional)
     - returns: RequestBuilder<VideoListResponse> 
     */
    open class func accountsNameVideosGetWithRequestBuilder(name: String, categoryOneOf: OneOfintegerarray? = nil, tagsOneOf: OneOfstringarray? = nil, tagsAllOf: OneOfstringarray? = nil, licenceOneOf: OneOfintegerarray? = nil, languageOneOf: OneOfstringarray? = nil, nsfw: Nsfw_accountsNameVideosGet? = nil, filter: Filter_accountsNameVideosGet? = nil, skipCount: SkipCount_accountsNameVideosGet? = nil, start: Int? = nil, count: Int? = nil, sort: Sort_accountsNameVideosGet? = nil) -> RequestBuilder<VideoListResponse> {
        var path = "/accounts/{name}/videos"
        let namePreEscape = "\(APIHelper.mapValueToPathItem(name))"
        let namePostEscape = namePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
        path = path.replacingOccurrences(of: "{name}", with: namePostEscape, options: .literal, range: nil)
        let URLString = OpenAPIClientAPI.basePath + path
        let parameters: [String: Any]? = nil

        var url = URLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems([
            "categoryOneOf": categoryOneOf?.encodeToJSON(),
            "tagsOneOf": tagsOneOf?.encodeToJSON(),
            "tagsAllOf": tagsAllOf?.encodeToJSON(),
            "licenceOneOf": licenceOneOf?.encodeToJSON(),
            "languageOneOf": languageOneOf?.encodeToJSON(),
            "nsfw": nsfw?.encodeToJSON(),
            "filter": filter?.encodeToJSON(),
            "skipCount": skipCount?.encodeToJSON(),
            "start": start?.encodeToJSON(),
            "count": count?.encodeToJSON(),
            "sort": sort?.encodeToJSON(),
        ])

        let nillableHeaders: [String: Any?] = [
            :
        ]

        let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)

        let requestBuilder: RequestBuilder<VideoListResponse>.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, headers: headerParameters)
    }

}
