# -*- 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.prepaid_card_status import PrepaidCardStatus
from pqapiv2.models.prepaid_card_base import PrepaidCardBase


class PrepaidCardsControllerTests(ControllerTestBase):

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

    # Replace an existing Prepaid Card specifying the replacement reason and the card package for the replacement card.
    def test_replace_prepaid_card(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        dest_token = 'dest-4aed86e2-4929-45bf-814d-9030aef21e79'
        x_my_pay_quicker_version = '2020.02.24'
        body = None

        # Perform the API call through the SDK function
        result = self.controller.replace_prepaid_card(user_token, dest_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('{"token":"dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d","status":"QUE'
            'UED","createdOn":"2020-02-21T22:00:00Z","country":"US","currency":'
            '"USD","cardPersonalization":"PERSONALIZED","cardPackage":"blue_con'
            'sumer_10k","cardNetwork":"VISA","expires":"2023-02-21T00:00:00Z","'
            'cardNumber":"1234 56** **** 1234","cvv":"123","links":[{"params":{'
            '"rel":"self"},"href":"https://platform.mypayquicker.com/api/v2/use'
            'rs/xxx/prepaid-cards/dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d"}]}'
            '')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve Prepaid Card details by destination token.
    def test_retrieve_prepaid_card(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        dest_token = 'dest-4aed86e2-4929-45bf-814d-9030aef21e79'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        result = self.controller.retrieve_prepaid_card(user_token, dest_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('{"token":"dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d","status":"QUE'
            'UED","createdOn":"2020-02-21T22:00:00Z","country":"US","currency":'
            '"USD","cardPersonalization":"PERSONALIZED","cardPackage":"blue_con'
            'sumer_10k","cardNetwork":"VISA","expires":"2023-02-21T00:00:00Z","'
            'cardNumber":"1234 56** **** 1234","cvv":"123","links":[{"params":{'
            '"rel":"self"},"href":"https://platform.mypayquicker.com/api/v2/use'
            'rs/xxx/prepaid-cards/dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d"}]}'
            '')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Partial Prepaid Card update typically used when modifying card status. <i>*Does not require the entire object be passed in the request</i>
    def test_update_prepaid_card_partial(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        dest_token = 'dest-4aed86e2-4929-45bf-814d-9030aef21e79'
        x_my_pay_quicker_version = '2020.02.24'
        body = None

        # Perform the API call through the SDK function
        result = self.controller.update_prepaid_card_partial(user_token, dest_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('{"token":"dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d","status":"LOC'
            'KED","createdOn":"2020-02-21T22:00:00Z","country":"US","currency":'
            '"USD","cardPersonalization":"PERSONALIZED","cardPackage":"blue_con'
            'sumer_10k","cardNetwork":"VISA","expires":"2023-02-21T00:00:00Z","'
            'cardNumber":"1234 56** **** 1234","cvv":"123","links":[{"params":{'
            '"rel":"self"},"href":"https://platform.mypayquicker.com/api/v2/use'
            'rs/xxx/prepaid-cards/dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d"}]}'
            '')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve one part of a two-part token required to reveal or set a client side PIN. <i>*Not all programs support a reveal or set PIN operation.</i>
    def test_generate_pin_operation_token(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        dest_token = 'dest-4aed86e2-4929-45bf-814d-9030aef21e79'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        result = self.controller.generate_pin_operation_token(user_token, dest_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))


    # Retrieve a list of all pre-paid cards by user token that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_prepaid_cards(self):
        # Parameters for the API call
        user_token = 'user-f012bc86-4d42-415b-a8b2-be5e0b90e59a'
        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_prepaid_cards(user_token, 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['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":[{"token":"dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d","'
            'status":"QUEUED","createdOn":"2020-02-21T22:00:00Z","country":"US"'
            ',"currency":"USD","cardPersonalization":"PERSONALIZED","cardPackag'
            'e":"blue_consumer_10k","cardNetwork":"VISA","expires":"2023-02-21T'
            '00:00:00Z","cardNumber":"1234 56** **** 1234","cvv":"123","links":'
            '[{"params":{"rel":"self"},"href":"https://platform.mypayquicker.co'
            'm/api/v2/users/xxx/prepaid-cards/dest-37ba1fb7-6136-4216-bb13-f903'
            'af6b9f0d"}]}],"links":[{"params":{"rel":"self"},"href":"https://pl'
            'atform.mypayquicker.com/api/v2/users/xxx/prepaid-cards"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Order a pre-paid card for the user by specifying a cardPackage. <i>*A package defines the type of card, currency, artwork utilized, and often the method of delivery.</i>
    def test_order_prepaid_card(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.order_prepaid_card(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('{"token":"dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d","status":"QUE'
            'UED","createdOn":"2020-02-21T22:00:00Z","country":"US","currency":'
            '"USD","cardPersonalization":"PERSONALIZED","cardPackage":"blue_con'
            'sumer_10k","cardNetwork":"VISA","expires":"2023-02-21T00:00:00Z","'
            'cardNumber":"1234 56** **** 1234","cvv":"123","links":[{"params":{'
            '"rel":"self"},"href":"https://platform.mypayquicker.com/api/v2/use'
            'rs/xxx/prepaid-cards/dest-37ba1fb7-6136-4216-bb13-f903af6b9f0d"}]}'
            '')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

