# WARNING: Do not edit by hand, this file was generated by Crank:
#
#   https://github.com/gocardless/crank
#

from . import base_service
from .. import resources
from ..paginator import Paginator
from .. import errors

class InstitutionsService(base_service.BaseService):
    """Service class that provides access to the institutions
    endpoints of the GoCardless Pro API.
    """

    RESOURCE_CLASS = resources.Institution
    RESOURCE_NAME = 'institutions'


    def list(self,params=None, headers=None):
        """List Institutions.

        Returns a list of supported institutions.
        
        <p class="deprecated-notice"><strong>Deprecated</strong>: This list
        institutions endpoint
        is no longer supported. We strongly recommend using the
        [List Institutions For Billing
        Request](#institutions-list-institutions-for-billing-request)
        instead.</p>

        Args:
              params (dict, optional): Query string parameters.

        Returns:
              ListResponse of Institution instances
        """
        path = '/institutions'
        

        response = self._perform_request('GET', path, params, headers,
                                         retry_failures=True)
        return self._resource_for(response)

    def all(self, params=None):
        if params is None:
            params = {}
        return Paginator(self, params)
    
  

    def list_for_billing_request(self,identity,params=None, headers=None):
        """List institutions for Billing Request.

        Returns all institutions valid for a Billing Request.
        
        This endpoint is currently supported only for FasterPayments.

        Args:
              identity (string): Unique identifier, beginning with "BRQ".
              params (dict, optional): Query string parameters.

        Returns:
              ListResponse of Institution instances
        """
        path = self._sub_url_params('/billing_requests/:identity/institutions', {
          
            'identity': identity,
          })
        
        response = self._perform_request('GET', path, params, headers,
                                         retry_failures=False)
        return self._resource_for(response)
  
