code: def to_representation(self, instance):
          
          request = self.context['request']
          enterprise_customer = instance.enterprise_customer
  
          representation = super(EnterpriseCustomerCatalogDetailSerializer, self).to_representation(instance)
  
          # Retrieve the EnterpriseCustomerCatalog search results from the discovery service.
          paginated_content = instance.get_paginated_content(request.GET)
          count = paginated_content['count']
          search_results = paginated_content['results']
  
          for item in search_results:
              content_type = item['content_type']
              marketing_url = item.get('marketing_url')
              if marketing_url:
                  item['marketing_url'] = utils.update_query_parameters(
                      marketing_url, utils.get_enterprise_utm_context(enterprise_customer)
                  )
              # Add the Enterprise enrollment URL to each content item returned from the discovery service.
              if content_type == 'course':
                  item['enrollment_url'] = instance.get_course_enrollment_url(item['key'])
              if content_type == 'courserun':
                  item['enrollment_url'] = instance.get_course_run_enrollment_url(item['key'])
              if content_type == 'program':
                  item['enrollment_url'] = instance.get_program_enrollment_url(item['uuid'])
  
          # Build pagination URLs
          previous_url = None
          next_url = None
          page = int(request.GET.get('page', '1'))
          request_uri = request.build_absolute_uri()
          if paginated_content['previous']:
              previous_url = utils.update_query_parameters(request_uri, {'page': page - 1})
          if paginated_content['next']:
              next_url = utils.update_query_parameters(request_uri, {'page': page + 1})
  
          representation['count'] = count
          representation['previous'] = previous_url
          representation['next'] = next_url
          representation['results'] = search_results
  
          return representation
docs: Serialize the EnterpriseCustomerCatalog object.
  
          Arguments:
              instance (EnterpriseCustomerCatalog): The EnterpriseCustomerCatalog to serialize.
  
          Returns:
              dict: The EnterpriseCustomerCatalog converted to a dict.