import type { AxiosResponse } from 'axios' ; import { GoogleMapsLocationTransformer } from '../../transformer' ; import type { AbstractCommand } from '../../../../command' ; import type { AbstractLocationTransformer } from '../../../../transformer' ; import type { Constructor } from '../../../../types' ; import type { GoogleMapsProvider } from '../../google-maps.provider' ; import { GoogleMapsCommonCommandMixin } from './google-maps-common-command.mixin' ; export function GoogleMapsLocationCommandMixin < TBase extends Constructor < AbstractCommand > > ( Base ) { abstract class GoogleMapsLocationCommand extends GoogleMapsCommonCommandMixin ( Base ) { protected async parseResponse ( response ) { if ( ! Array . isArray ( response . data . results ) || ! response . data . results . length ) { return [ ] ; } return Promise . all < AbstractLocationTransformer < GoogleMapsProvider > > ( response . data . results . map ( async ( raw ) : Promise < AbstractLocationTransformer < GoogleMapsProvider > > => this . parseOneResult ( raw ) ) ) ; } protected async parseOneResult ( raw ) { return new GoogleMapsLocationTransformer ( raw ) ; } } return GoogleMapsLocationCommand ; }