# -*- 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


class ReceiptsControllerTests(ControllerTestBase):

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

    # Retrieve a list of all account(s) receipts that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_account_receipts(self):
        # Parameters for the API call
        acct_token = 'acct-b3f0570a-6586-4e00-8d6e-8a2bf93cfae4'
        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_account_receipts(acct_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":[{"amount":5000.01,"currency":"USD","sourceToken":"acct'
            '-04017f57-8526-4b0c-9152-5252975a86e4","destinationToken":"dest-04'
            '017f57-8526-4b0c-9152-5252975a86e4","createdOn":"2023-02-21T00:00:'
            '00Z"}],"meta":{"pageNo":"1","pageSize":"20","pageCount":"85","reco'
            'rdCount":"1685","timezone":"GMT"},"links":[{"params":{"rel":"self"'
            '},"href":"https://platform.mypayquicker.com/api/v2/accounts/acct-0'
            '4017f57-8526-4b0c-9152-5252975a86e4/receipts"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve a list all prepaid-card receipts that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_prepaid_card_receipts(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'
        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_card_receipts(user_token, dest_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['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":[{"amount":5000.05,"currency":"USD","sourceToken":"user'
            '-04017f57-8526-4b0c-9152-5252975a86e4","destinationToken":"dest-04'
            '017f57-8526-4b0c-9152-5252975a86e4","createdOn":"2023-02-21T00:00:'
            '00Z"}],"meta":{"pageNo":"1","pageSize":"20","pageCount":"85","reco'
            'rdCount":"1685","timezone":"GMT"},"links":[{"params":{"rel":"self"'
            '},"href":"https://platform.mypayquicker.com/api/v2/users/user-0401'
            '7f57-8526-4b0c-9152-5252975a86e4/prepaid-cards/dest-04017f57-8526-'
            '4b0c-9152-5252975a86e4/receipts"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

    # Retrieve a list all user receipts that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_user_receipts(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_user_receipts(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['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":[{"amount":5000.01,"currency":"USD","sourceToken":"user'
            '-04017f57-8526-4b0c-9152-5252975a86e4","destinationToken":"dest-04'
            '017f57-8526-4b0c-9152-5252975a86e4","createdOn":"2023-02-21T00:00:'
            '00Z"}],"meta":{"pageNo":"1","pageSize":"20","pageCount":"85","reco'
            'rdCount":"1685","timezone":"GMT"},"links":[{"params":{"rel":"self"'
            '},"href":"https://platform.mypayquicker.com/api/v2/users/user-0401'
            '7f57-8526-4b0c-9152-5252975a86e4/receipts"}]}')
        received_body = APIHelper.json_deserialize(self.response_catcher.response.text)
        self.assertTrue(TestHelper.match_body(expected_body, received_body))

