//
//  Section2_6.swift 
//  Pi 
//  Copyright © 2021 Evidation Health Inc. All rights reserved.
//
//  Utility for post ICF section 2.6 questionnaires

import XCTest

class Section2_6 {
    /*
     * Method onBoardingQuestionnaireEcigsUse is to send request to Ecigs use endpoint for on-boarding
     */
    func onBoardingQuestionnaireEcigsUse(authToken: String) {
        // Building the request URL and request body for the Ecgis use endpoint
        let url = URL(string: PiTestConfig.ECIGS_USE_ENDPOINT)!
        let params = [
            "answer": [
                "key": "yes",
                "text": "Yes"
            ]
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireCigsPerDay is to send request to Cigs per day endpoint for on-boarding
     */
    func onBoardingQuestionnaireCigsPerDay(authToken: String) {
        // Building the request URL and request body for the Cigs per day endpoint
        let url = URL(string: PiTestConfig.CIGS_PER_DAY_ENDPOINT)!
        let params = [
            "answer": 3
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireSmokingYears is to send request to smoking years endpoint for on-boarding
     */
    func onBoardingQuestionnaireSmokingYears(authToken: String) {
        // Building the request URL and request body for the smoking years endpoint
        let url = URL(string: PiTestConfig.SMOKING_YEARS_ENDPOINT)!
        let params = [
            "answer": 5
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireCurrentNicotineUse is to send request to current nicotine use endpoint for on-boarding
     */
    func onBoardingQuestionnaireCurrentNicotineUse(authToken: String) {
        // Building the request URL and request body for the current nicotine use endpoint
        let url = URL(string: PiTestConfig.CURRENT_NICOTINE_USE_ENDPOINT)!
        let params = [
            "answer": [
                "key": "less_than_daily",
                "text": "Less than daily"
            ]
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireCannabisUse is to send request to cannabis use endpoint for on-boarding
     */
    func onBoardingQuestionnaireCannabisUse(authToken: String) {
        // Building the request URL and request body for the cannabis use endpoint
        let url = URL(string: PiTestConfig.CANNABIS_USE_ENDPOINT)!
        let params = [
            "answer": [
                "key": "yes",
                "text": "Yes"
            ]
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireCannabisFrequency is to send request to cannabis frequency endpoint for on-boarding
     */
    func onBoardingQuestionnaireCannabisFrequency(authToken: String) {
        // Building the request URL and request body for the cannabis frequency endpoint
        let url = URL(string: PiTestConfig.CANNABIS_FREQUENCY_ENDPOINT)!
        let params = [
            "answer": [
                "key": "once_a_week",
                "text": "once a week"
            ]
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireAlcoholUse is to send request to alcohol use endpoint for on-boarding
     */
    func onBoardingQuestionnaireAlcoholUse(authToken: String) {
        // Building the request URL and request body for the alcohol use endpoint
        let url = URL(string: PiTestConfig.ALCOHOL_USE_ENDPOINT)!
        let params = [
            "answer": [
                "key": "yes",
                "text": "Yes"
            ]
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireAlcoholYears is to send request to alcohol years endpoint for on-boarding
     */
    func onBoardingQuestionnaireAlcoholYears(authToken: String) {
        // Building the request URL and request body for the alcohol years endpoint
        let url = URL(string: PiTestConfig.ALCOHOL_YEARS_ENDPOINT)!
        let params = [
            "answer": [
                "key": "less_one_year",
                "text": "Less than 1 year"
            ]
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireAlcoholMonthlyUse is to send request to alcohol monthly use endpoint for on-boarding
     */
    func onBoardingQuestionnaireAlcoholMonthlyUse(authToken: String) {
        // Building the request URL and request body for the alcohol monthly use endpoint
        let url = URL(string: PiTestConfig.MONTHLY_ALCOHOL_USE_ENDPOINT)!
        let params = [
            "answer": [
                "key": "three_five_month",
                "text": "3-5 days per month"
            ]
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingQuestionnaireAlcoholHeavyUse is to send request to alcohol heavy use endpoint for on-boarding
     */
    func onBoardingQuestionnaireAlcoholHeavyUse(authToken: String) {
        // Building the request URL and request body for the alcohol heavy use endpoint
        let url = URL(string: PiTestConfig.ALCOHOL_HEAVY_USE_ENDPOINT)!
        let params = [
            "answer": [
                "key": "one_two_month",
                "text": "1-2 days per month"
            ]
        ] as [String: Any]
        
        ApiRequestsUtil.sendRequest(method: .post, url: url, parameters: params, token: authToken)
    }
    
    /*
     * Method onBoardingPostICFQuestionnaireSection2_6 is to complete post ICF onboarding questionnaire section 2.6
     */
    func onBoardingPostICFQuestionnaireSection2_6(authToken: String) {
        onBoardingQuestionnaireEcigsUse(authToken: authToken)
        onBoardingQuestionnaireCigsPerDay(authToken: authToken)
        onBoardingQuestionnaireSmokingYears(authToken: authToken)
        onBoardingQuestionnaireCurrentNicotineUse(authToken: authToken)
        onBoardingQuestionnaireCannabisUse(authToken: authToken)
        onBoardingQuestionnaireCannabisFrequency(authToken: authToken)
        onBoardingQuestionnaireAlcoholUse(authToken: authToken)
        onBoardingQuestionnaireAlcoholYears(authToken: authToken)
        onBoardingQuestionnaireAlcoholMonthlyUse(authToken: authToken)
        onBoardingQuestionnaireAlcoholHeavyUse(authToken: authToken)
    }

}
