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

"""
pqapiv2

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

from pqapiv2.api_helper import APIHelper
from pqapiv2.configuration import Server
from pqapiv2.controllers.base_controller import BaseController


class ProgramController(BaseController):

    """A Controller to access Endpoints in the pqapiv2 API."""
    def __init__(self, config):
        super(ProgramController, self).__init__(config)

    def list_programs(self):
        """Does a GET request to /programs.

        Retrieve a list of all programs that supports filtering, sorting, and
        pagination through existing mechanisms.

        Returns:
            void: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/programs'
        _query_builder = self.config.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.config.http_client.get(_query_url)
        _response = self.execute_request(_request)
        self.validate_response(_response)

    def retrieve_program(self,
                         prog_token):
        """Does a GET request to /programs/{prog-token}.

        Retrieve a single program configuration

        Args:
            prog_token (string): Auto-generated unique identifier representing
                a program, prefixed with <i>prog-</i>.

        Returns:
            void: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/programs/{prog-token}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, {
            'prog-token': {'value': prog_token, 'encode': True}
        })
        _query_builder = self.config.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.config.http_client.get(_query_url)
        _response = self.execute_request(_request)
        self.validate_response(_response)

    def list_program_agreements(self,
                                prog_token):
        """Does a GET request to /programs/{prog-token}/agreements.

        Retrieve a list of all program agreements that supports filtering,
        sorting, and pagination through existing mechanisms.

        Args:
            prog_token (string): TODO: type description here.

        Returns:
            void: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/programs/{prog-token}/agreements'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, {
            'prog-token': {'value': prog_token, 'encode': True}
        })
        _query_builder = self.config.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.config.http_client.get(_query_url)
        _response = self.execute_request(_request)
        self.validate_response(_response)

    def retrieve_program_agreement(self,
                                   prog_token,
                                   agmt_token):
        """Does a GET request to /programs/{prog-token}/agreements/{agmt-token}.

        Retrieve a single program agreement

        Args:
            prog_token (string): Auto-generated unique identifier representing
                a program, prefixed with <i>prog-</i>.
            agmt_token (string): Auto-generated unique identifier representing
                a program agreement, prefixed with <i>agmt-</i>.

        Returns:
            void: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/programs/{prog-token}/agreements/{agmt-token}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, {
            'prog-token': {'value': prog_token, 'encode': True},
            'agmt-token': {'value': agmt_token, 'encode': True}
        })
        _query_builder = self.config.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.config.http_client.get(_query_url)
        _response = self.execute_request(_request)
        self.validate_response(_response)
