import { Contracts } from '../../contracts' ; import { IDeliveryClientConfig } from '../../config' ; import { IDeliveryNetworkResponse , ITaxonomyQueryConfig , Responses } from '../../models' ; import { QueryService } from '../../services' ; import { BaseQuery } from '../common/base-query.class' ; export class TaxonomyQuery extends BaseQuery < Responses . IViewTaxonomyResponse , ITaxonomyQueryConfig , Contracts . IViewTaxonomyGroupContract > { /**
     * Taxonomies endpoint URL action
     */ protected readonly taxonomiesEndpoint : string = 'taxonomies' ; constructor ( protected config , protected queryService , private taxonomyCodename ) { super ( config , queryService ) ; if ( ! taxonomyCodename ) { throw Error ( `Cannot create taxonomy query without codename of the taxonomy` ) ; } } toPromise ( ) { return this . queryService . getTaxonomy ( this . getUrl ( ) , this . _queryConfig ?? { } ) ; } getUrl ( ) { const action = '/' + this . taxonomiesEndpoint + '/' + this . taxonomyCodename ; return super . resolveUrlInternal ( action ) ; } map ( json ) { return this . queryService . mappingService . viewTaxonomyResponse ( json ) ; } }