# -*- coding: utf-8 -*-

"""
pqapiv2

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""

import json
import dateutil.parser

from tests.controllers.controller_test_base import ControllerTestBase
from tests.test_helper import TestHelper
from pqapiv2.api_helper import APIHelper
from pqapiv2.models.user_base import UserBase


class UsersControllerTests(ControllerTestBase):

    @classmethod
    def setUpClass(cls):
        super(UsersControllerTests, cls).setUpClass()
        cls.controller = cls.client.users
        cls.response_catcher = cls.controller.http_call_back

    # Update a user object (change email, address change, etc.) using a user token.
    def test_update_user(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        x_my_pay_quicker_version = '2020.02.24'
        body = None

        # Perform the API call through the SDK function
        result = self.controller.update_user(user_token, x_my_pay_quicker_version, body)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

        # Test headers
        expected_headers = {}
        expected_headers['content-type'] = 'application/json'

        self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers))

        
        # Test whether the captured response is as we expected
        self.assertIsNotNone(result)
        expected_body = APIHelper.json_deserialize('{"firstName":"Jane","lastName":"Smith","dateOfBirth":"1977-12-14",'
            '"phoneNumber":"760-350-0324","phoneNumberCountry":"US","mobileNumb'
            'er":"213-446-5755","mobileNumberCountry":"US","addressLine1":"290 '
            'Carriage Court","city":"Los Angeles","region":"CA","country":"US",'
            '"postalCode":"90017","addressType":"RESIDENTIAL","email":"jsmith@p'
            'ayquicker.com","gender":"FEMALE","userType":"INDIVIDUAL","programU'
            'serId":"d97ce0519b2d","language":"en-US","countryOfBirth":"US","co'
            'untryOfNationality":"US","token":"user-f012bc86-4d42-415b-a8b2-be5'
            'e0b90e59a","status":"PRE_ACTIVATED","createdOn":"2020-02-24T22:00:'
            '00Z","links":[{"params":{"rel":"self"},"href":"https://platform.my'
            'payquicker.com/api/v2/users/user-f012bc86-4d42-415b-a8b2-be5e0b90e'
            '59a"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve a single user record by user token.
    def test_retrieve_user(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        result = self.controller.retrieve_user(user_token, x_my_pay_quicker_version)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

        # Test headers
        expected_headers = {}
        expected_headers['content-type'] = 'application/json'

        self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers))

        
        # Test whether the captured response is as we expected
        self.assertIsNotNone(result)
        expected_body = APIHelper.json_deserialize('{"firstName":"Jane","lastName":"Smith","dateOfBirth":"1977-12-14",'
            '"phoneNumber":"760-350-0324","phoneNumberCountry":"US","mobileNumb'
            'er":"213-446-5755","mobileNumberCountry":"US","addressLine1":"290 '
            'Carriage Court","city":"Los Angeles","region":"CA","country":"US",'
            '"postalCode":"90017","addressType":"RESIDENTIAL","email":"jsmith@p'
            'ayquicker.com","gender":"FEMALE","userType":"INDIVIDUAL","programU'
            'serId":"d97ce0519b2d","language":"en-US","countryOfBirth":"US","co'
            'untryOfNationality":"US","token":"user-f012bc86-4d42-415b-a8b2-be5'
            'e0b90e59a","status":"PRE_ACTIVATED","createdOn":"2020-02-24T22:00:'
            '00Z","links":[{"params":{"rel":"self"},"href":"https://platform.my'
            'payquicker.com/api/v2/users/user-f012bc86-4d42-415b-a8b2-be5e0b90e'
            '59a"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve a list of all users that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_users(self):
        # Parameters for the API call
        x_my_pay_quicker_version = '2020.02.24'
        page = None
        page_size = 20
        filter = '\'name\'*\'Fra\'||*\'Ger\',\'numericCode\'>\'5\''
        sort = '-name'
        language = 'en-US'

        # Perform the API call through the SDK function
        result = self.controller.list_users(x_my_pay_quicker_version, page, page_size, filter, sort, language)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

        # Test headers
        expected_headers = {}
        expected_headers['x-timezone'] = None
        expected_headers['x-paging-pageno'] = None
        expected_headers['x-paging-pagecount'] = None
        expected_headers['x-paging-pagesize'] = None
        expected_headers['x-paging-totalrecordcount'] = None
        expected_headers['content-type'] = 'application/json'

        self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers))

        
        # Test whether the captured response is as we expected
        self.assertIsNotNone(result)
        expected_body = APIHelper.json_deserialize('{"payload":[{"firstName":"Jane","lastName":"Smith","dateOfBirth":"'
            '1977-12-14","phoneNumber":"760-350-0324","phoneNumberCountry":"US"'
            ',"mobileNumber":"213-446-5755","mobileNumberCountry":"US","address'
            'Line1":"290 Carriage Court","city":"Los Angeles","region":"CA","co'
            'untry":"US","postalCode":"90017","addressType":"RESIDENTIAL","emai'
            'l":"jsmith@payquicker.com","gender":"FEMALE","userType":"INDIVIDUA'
            'L","programUserId":"d97ce0519b2d","language":"en-US","countryOfBir'
            'th":"US","countryOfNationality":"US","token":"usr-3b8a0c25-c7e2-4b'
            'b7-904e-0a2a66001357","status":"PRE_ACTIVATED","links":[{"params":'
            '{"rel":"self"},"href":"https://platform.mypayquicker.com/api/v2/us'
            'ers/usr-3b8a0c25-c7e2-4bb7-904e-0a2a66001357"}]}],"links":[{"param'
            's":{"rel":"self"},"href":"https://platform.mypayquicker.com/api/v2'
            '/users"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Create a new user. Payload contains both required and optional fields for user- and company-based users, allowing for the creation of a corporate/partnership/dba (i.e., Grubhub model) user along with a standard end user (i.e., <i>Payee</i>). The type of the user (<i>Business</i> vs. <i>User</i>) and type of business (<i>Corporation</i> vs. <i>Partnership</i>) provide context that impacts KYC etc.
    def test_create_user(self):
        # Parameters for the API call
        x_my_pay_quicker_version = '2020.02.24'
        body = APIHelper.json_deserialize('{"firstName":"Jane","lastName":"Smith","dateOfBirth":"1977-12-14",'
            '"phoneNumber":"760-350-0324","phoneNumberCountry":"US","mobileNumb'
            'er":"213-446-5755","mobileNumberCountry":"US","addressLine1":"290 '
            'Carriage Court","city":"Los Angeles","region":"CA","country":"US",'
            '"postalCode":"90017","addressType":"RESIDENTIAL","email":"jsmith@p'
            'ayquicker.com","gender":"FEMALE","userType":"INDIVIDUAL","programU'
            'serId":"d97ce0519b2d","language":"en-US","countryOfBirth":"US","co'
            'untryOfNationality":"US"}', UserBase.from_dictionary)

        # Perform the API call through the SDK function
        result = self.controller.create_user(x_my_pay_quicker_version, body)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

        # Test headers
        expected_headers = {}
        expected_headers['content-type'] = 'application/json'

        self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers))

        
        # Test whether the captured response is as we expected
        self.assertIsNotNone(result)
        expected_body = APIHelper.json_deserialize('{"firstName":"Jane","lastName":"Smith","dateOfBirth":"1977-12-14",'
            '"phoneNumber":"760-350-0324","phoneNumberCountry":"US","mobileNumb'
            'er":"213-446-5755","mobileNumberCountry":"US","addressLine1":"290 '
            'Carriage Court","city":"Los Angeles","region":"CA","country":"US",'
            '"postalCode":"90017","addressType":"RESIDENTIAL","email":"jsmith@p'
            'ayquicker.com","gender":"FEMALE","userType":"INDIVIDUAL","programU'
            'serId":"d97ce0519b2d","language":"en-US","countryOfBirth":"US","co'
            'untryOfNationality":"US","token":"user-f012bc86-4d42-415b-a8b2-be5'
            'e0b90e59a","status":"PRE_ACTIVATED","createdOn":"2020-02-24T22:00:'
            '00Z","links":[{"params":{"rel":"self"},"href":"https://platform.my'
            'payquicker.com/api/v2/users/user-f012bc86-4d42-415b-a8b2-be5e0b90e'
            '59a"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Create a new user. Payload contains both required and optional fields for user- and company-based users, allowing for the creation of a corporate/partnership/dba (i.e., Grubhub model) user along with a standard end user (i.e., <i>Payee</i>). The type of the user (<i>Business</i> vs. <i>User</i>) and type of business (<i>Corporation</i> vs. <i>Partnership</i>) provide context that impacts KYC etc.
    def test_create_user_1(self):
        # Parameters for the API call
        x_my_pay_quicker_version = '2020.02.24'
        body = APIHelper.json_deserialize('{"firstName":"Jane","lastName":"Smith","dateOfBirth":"1977-12-14",'
            '"phoneNumber":"760-350-0324","phoneNumberCountry":"US","mobileNumb'
            'er":"213-446-5755","mobileNumberCountry":"US","addressLine1":"290 '
            'Carriage Court","city":"Los Angeles","region":"CA","country":"US",'
            '"postalCode":"90017","addressType":"RESIDENTIAL","email":"jsmith@p'
            'ayquicker.com","gender":"FEMALE","userType":"INDIVIDUAL","programU'
            'serId":"d97ce0519b2d","language":"en-US","countryOfBirth":"US","co'
            'untryOfNationality":"US"}', UserBase.from_dictionary)

        # Perform the API call through the SDK function
        result = self.controller.create_user(x_my_pay_quicker_version, body)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 201)

        # Test headers
        expected_headers = {}
        expected_headers['content-type'] = 'application/json'

        self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers))

        
        # Test whether the captured response is as we expected
        self.assertIsNotNone(result)
        expected_body = APIHelper.json_deserialize('{"firstName":"Jane","lastName":"Smith","dateOfBirth":"1977-12-14",'
            '"phoneNumber":"760-350-0324","phoneNumberCountry":"US","mobileNumb'
            'er":"213-446-5755","mobileNumberCountry":"US","addressLine1":"290 '
            'Carriage Court","city":"Los Angeles","region":"CA","country":"US",'
            '"postalCode":"90017","addressType":"RESIDENTIAL","email":"jsmith@p'
            'ayquicker.com","gender":"FEMALE","userType":"INDIVIDUAL","programU'
            'serId":"d97ce0519b2d","language":"en-US","countryOfBirth":"US","co'
            'untryOfNationality":"US","token":"user-f012bc86-4d42-415b-a8b2-be5'
            'e0b90e59a","status":"PRE_ACTIVATED","createdOn":"2020-02-24T22:00:'
            '00Z","links":[{"params":{"rel":"self"},"href":"https://platform.my'
            'payquicker.com/api/v2/users/user-f012bc86-4d42-415b-a8b2-be5e0b90e'
            '59a"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve a list of IDV checks by user token that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_user_idv_checks(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        result = self.controller.list_user_idv_checks(user_token, x_my_pay_quicker_version)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

        # Test headers
        expected_headers = {}
        expected_headers['content-type'] = 'application/json'

        self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers))

        
        # Test whether the captured response is as we expected
        self.assertIsNotNone(result)
        expected_body = APIHelper.json_deserialize('{"payload":[{"idvProviderReference":"yPV0h4o1Yw3QzdLAvA7a","idvRes'
            'ult":"PASS","idvSubResult":"HARD","idvProvider":"IDOLOGY","created'
            'On":"2020-02-21T22:00:00Z","raw":"<RAW IDV processor output, for i'
            'nformational /debugging purposes only>","idvCheckType":"NON_DOCUME'
            'NTARY","idvDisposition":"FINAL","token":"idvc-7e7567e0-c2db-485d-8'
            '96d-45901a10baa9","links":[{"params":{"rel":"self"},"href":"https:'
            '//platform.mypayquicker.com/api/v2/users/user-f012bc86-4d42-415b-a'
            '8b2-be5e0b90e59a/idv-checks/idvc-7e7567e0-c2db-485d-896d-45901a10b'
            'aa9"}]}],"links":[{"params":{"rel":"self"},"href":"https://platfor'
            'm.mypayquicker.com/api/v2/users/user-f012bc86-4d42-415b-a8b2-be5e0'
            'b90e59a/idv-checks"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve a list of all IDV check by IDVC token that supports filtering, sorting, and pagination through existing mechanisms.
    def test_retrieve_user_idv_check(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        idvc_token = 'idvc-7e7567e0-c2db-485d-896d-45901a10baa9'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        result = self.controller.retrieve_user_idv_check(user_token, idvc_token, x_my_pay_quicker_version)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

        # Test headers
        expected_headers = {}
        expected_headers['content-type'] = 'application/json'

        self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers))

        
        # Test whether the captured response is as we expected
        self.assertIsNotNone(result)
        expected_body = APIHelper.json_deserialize('{"idvProviderReference":"yPV0h4o1Yw3QzdLAvA7a","idvResult":"PASS",'
            '"idvSubResult":"HARD","idvProvider":"IDOLOGY","createdOn":"2020-02'
            '-21T22:00:00Z","raw":"<RAW IDV processor output, for informational'
            '/debugging purposes only>","idvCheckType":"NON_DOCUMENTARY","idvDi'
            'spostion":"FINAL","token":"idvc-7e7567e0-c2db-485d-896d-45901a10ba'
            'a9","links":[{"params":{"rel":"self"},"href":"https://platform.myp'
            'ayquicker.com/api/v2/users/user-f012bc86-4d42-415b-a8b2-be5e0b90e5'
            '9a/idv-checks/idvc-7e7567e0-c2db-485d-896d-45901a10baa9"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve a list of all user events that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_user_events(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'

        # Perform the API call through the SDK function
        self.controller.list_user_events(user_token)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

    # Retrieve a single user event
    def test_retrieve_user_event(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        evnt_token = 'evnt-28491de2-5b22-4e30-028a-45901a10baa9'

        # Perform the API call through the SDK function
        self.controller.retrieve_user_event(user_token, evnt_token)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

    # Accept a single program agreement
    def test_accept_program_agreement(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        agmt_token = 'agmt-45901a10-5b22-4e30-028a-45901a10baa9'

        # Perform the API call through the SDK function
        self.controller.accept_program_agreement(user_token, agmt_token)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

    # Retrieve a list of all accepted program agreements that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_accepted_program_agreements(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'

        # Perform the API call through the SDK function
        self.controller.list_accepted_program_agreements(user_token)

        # Test response code
        self.assertEquals(self.response_catcher.response.status_code, 200)

