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

import Foundation
import Alamofire


open class SecurityQuestionAnswerAPI: APIBase {
    /**
     Check if security questions are needed
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func checkSecurityStatus(completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
        checkSecurityStatusWithRequestBuilder().execute { (response, error) -> Void in
            completion(error)
        }
    }


    /**
     Check if security questions are needed
     - GET /user/security/location
     - BASIC:
       - type: http
       - name: PlayerAccessToken
     - returns: RequestBuilder<Void> 
     */
    open class func checkSecurityStatusWithRequestBuilder() -> RequestBuilder<Void> {
        let path = "/user/security/location"
        let URLString = OpenAPIClientAPI.basePath + path
        let parameters: [String:Any]? = nil
        
        let url = URLComponents(string: URLString)

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

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

    /**
     Get list of questions
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func listPendingSecurityQuestions(completion: @escaping ((_ data: [SecurityChallenge]?, _ error: ErrorResponse?) -> Void)) {
        listPendingSecurityQuestionsWithRequestBuilder().execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Get list of questions
     - GET /user/security/challenges
     - BASIC:
       - type: http
       - name: PlayerAccessToken
     - returns: RequestBuilder<[SecurityChallenge]> 
     */
    open class func listPendingSecurityQuestionsWithRequestBuilder() -> RequestBuilder<[SecurityChallenge]> {
        let path = "/user/security/challenges"
        let URLString = OpenAPIClientAPI.basePath + path
        let parameters: [String:Any]? = nil
        
        let url = URLComponents(string: URLString)

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

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

    /**
     Send back the answers
     - parameter securityAnswer: (body) An array with all the answers 
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func sendSecurityQuestionAnswers(securityAnswer: [SecurityAnswer], completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
        sendSecurityQuestionAnswersWithRequestBuilder(securityAnswer: securityAnswer).execute { (response, error) -> Void in
            completion(error)
        }
    }


    /**
     Send back the answers
     - POST /user/security/location
     - BASIC:
       - type: http
       - name: PlayerAccessToken
     - parameter securityAnswer: (body) An array with all the answers 
     - returns: RequestBuilder<Void> 
     */
    open class func sendSecurityQuestionAnswersWithRequestBuilder(securityAnswer: [SecurityAnswer]) -> RequestBuilder<Void> {
        let path = "/user/security/location"
        let URLString = OpenAPIClientAPI.basePath + path
        let parameters = securityAnswer.encodeToJSON()

        let url = URLComponents(string: URLString)

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

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

}
