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

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

    # Retrieve a single spendback quote using the spendback token.
    def test_retrieve_spendback(self):
        # Parameters for the API call
        spnd_token = 'spnd-c39437e1-dc80-4293-8211-c14b5a32f762'
        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
        self.controller.retrieve_spendback(spnd_token, x_my_pay_quicker_version, page, page_size, filter, sort, language)

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

    # Accept an open spendback quote.
    def test_accept_spendback_quote(self):
        # Parameters for the API call
        spnd_token = 'spnd-c39437e1-dc80-4293-8211-c14b5a32f762'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        self.controller.accept_spendback_quote(spnd_token, x_my_pay_quicker_version)

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

    # Cancel an open spendback quote.
    def test_cancel_spendback_quote(self):
        # Parameters for the API call
        spnd_token = 'spnd-c39437e1-dc80-4293-8211-c14b5a32f762'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        self.controller.cancel_spendback_quote(spnd_token, x_my_pay_quicker_version)

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

    # Perform a spendback refund for the full amount.
    def test_refund_spendback_full(self):
        # Parameters for the API call
        spnd_token = 'spnd-c39437e1-dc80-4293-8211-c14b5a32f762'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        self.controller.refund_spendback_full(spnd_token, x_my_pay_quicker_version)

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

    # Perform a spendback refund for a partial amount.
    def test_refund_spendback_partial(self):
        # Parameters for the API call
        spnd_token = 'spnd-c39437e1-dc80-4293-8211-c14b5a32f762'
        x_my_pay_quicker_version = '2020.02.24'

        # Perform the API call through the SDK function
        self.controller.refund_spendback_partial(spnd_token, x_my_pay_quicker_version)

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

    # Retrieve a list of all spendbacks that supports filtering, sorting, and pagination through existing mechanisms.
    def test_list_spend_backs(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
        self.controller.list_spend_backs(x_my_pay_quicker_version, page, page_size, filter, sort, language)

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

    # Create a spendback quote. <i>*Spendbacks can be automatically accepted by setting the `autoAcceptQuote` flag. If not automatically accepted, a POST is required to the spendback endpoint using the token returned in the response. Quotes can be accepted, cancelled, or allowed to expire.</i>
    def test_quote_spendback(self):
        # Parameters for the API call
        x_my_pay_quicker_version = '2020.02.24'
        body = None

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

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

