# -*- 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 TransfersControllerTests(ControllerTestBase):

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

    # Retrieve details of a specific transfer represented by a transfer token.
    def test_retrieve_transfer(self):
        # Parameters for the API call
        xfer_token = 'xfer-0fac4aa8-43ac-447e-95f9-827f908a82ff'
        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.retrieve_transfer(xfer_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))


    # Accept a transfer quote
    def test_accept_transfer_quote(self):
        # Parameters for the API call
        xfer_token = 'xfer-0fac4aa8-43ac-447e-95f9-827f908a82ff'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        self.controller.accept_transfer_quote(xfer_token, x_my_pay_quicker_version)

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

    # Optional cancellation that auto-cancels after a period organically expires or when account activity invalidates the quote.
    def test_cancel_transfer_quote(self):
        # Parameters for the API call
        xfer_token = 'xfer-0fac4aa8-43ac-447e-95f9-827f908a82ff'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        self.controller.cancel_transfer_quote(xfer_token, x_my_pay_quicker_version)

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

    # Retrieve a list of all transfers that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_transfers(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_transfers(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))


