//
// CoursesAPI.swift
//
// Generated by swagger-codegen
// https://github.com/swagger-api/swagger-codegen
//

import Foundation
import Alamofire



open class CoursesAPI {
    /**
     Get course by id
     
     - parameter courseId: (path) Id of the course 
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func getCourseById(courseId: String, completion: @escaping ((_ error: Error?) -> Void)) {
        getCourseByIdWithRequestBuilder(courseId: courseId).execute { (response, error) -> Void in
            completion(error);
        }
    }


    /**
     Get course by id
     - GET /courses/{courseId}
     - Get course by id
     
     - parameter courseId: (path) Id of the course 

     - returns: RequestBuilder<Void> 
     */
    open class func getCourseByIdWithRequestBuilder(courseId: String) -> RequestBuilder<Void> {
        var path = "/courses/{courseId}"
        path = path.replacingOccurrences(of: "{courseId}", with: "\(courseId)", options: .literal, range: nil)
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil

        let url = NSURLComponents(string: URLString)


        let requestBuilder: RequestBuilder<Void>.Type = SwaggerClientAPI.requestBuilderFactory.getNonDecodableBuilder()

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

    /**
     Get courses
     
     - parameter startDatetime: (query) optional start datetime (optional)
     - parameter endDatetime: (query) optional end datetime (optional)
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func getCourses(startDatetime: String? = nil, endDatetime: String? = nil, completion: @escaping ((_ error: Error?) -> Void)) {
        getCoursesWithRequestBuilder(startDatetime: startDatetime, endDatetime: endDatetime).execute { (response, error) -> Void in
            completion(error);
        }
    }


    /**
     Get courses
     - GET /courses/list
     - Get courses
     
     - parameter startDatetime: (query) optional start datetime (optional)
     - parameter endDatetime: (query) optional end datetime (optional)

     - returns: RequestBuilder<Void> 
     */
    open class func getCoursesWithRequestBuilder(startDatetime: String? = nil, endDatetime: String? = nil) -> RequestBuilder<Void> {
        let path = "/courses/list"
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil

        let url = NSURLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
            "startDatetime": startDatetime, 
            "endDatetime": endDatetime
        ])
        

        let requestBuilder: RequestBuilder<Void>.Type = SwaggerClientAPI.requestBuilderFactory.getNonDecodableBuilder()

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

    /**
     Get user by course Id
     
     - parameter courseId: (path) ID of course where users need to be called 
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func getUsersByCourseId(courseId: String, completion: @escaping ((_ error: Error?) -> Void)) {
        getUsersByCourseIdWithRequestBuilder(courseId: courseId).execute { (response, error) -> Void in
            completion(error);
        }
    }


    /**
     Get user by course Id
     - GET /courses/{courseId}/users/list
     - Get user by course Id
     
     - parameter courseId: (path) ID of course where users need to be called 

     - returns: RequestBuilder<Void> 
     */
    open class func getUsersByCourseIdWithRequestBuilder(courseId: String) -> RequestBuilder<Void> {
        var path = "/courses/{courseId}/users/list"
        path = path.replacingOccurrences(of: "{courseId}", with: "\(courseId)", options: .literal, range: nil)
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil

        let url = NSURLComponents(string: URLString)


        let requestBuilder: RequestBuilder<Void>.Type = SwaggerClientAPI.requestBuilderFactory.getNonDecodableBuilder()

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

    /**
     Update call by course Id
     
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func updateCallByCourseId(completion: @escaping ((_ error: Error?) -> Void)) {
        updateCallByCourseIdWithRequestBuilder().execute { (response, error) -> Void in
            completion(error);
        }
    }


    /**
     Update call by course Id
     - POST /courses/{courseId}/call
     - Update call by course Id

     - returns: RequestBuilder<Void> 
     */
    open class func updateCallByCourseIdWithRequestBuilder() -> RequestBuilder<Void> {
        let path = "/courses/{courseId}/call"
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil

        let url = NSURLComponents(string: URLString)


        let requestBuilder: RequestBuilder<Void>.Type = SwaggerClientAPI.requestBuilderFactory.getNonDecodableBuilder()

        return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
    }

}
