import type { AxiosInstance , AxiosResponse } from 'axios' ; import { PlaceDetailsCommand } from '../../../command' ; import type { PlaceDetailsQuery } from '../../../model' ; import type { GoogleMapsPlaceDetailsQueryInterface } from '../interface' ; import type { GoogleMapsLocationTransformer } from '../transformer' ; import { GoogleMapsLocationCommandMixin } from './mixin' ; link export class GoogleMapsPlaceDetailsCommand extends GoogleMapsLocationCommandMixin ( PlaceDetailsCommand ) < GoogleMapsPlaceDetailsQueryInterface > { constructor ( httpClient , private readonly apiKey ) { super ( httpClient , apiKey ) ; } static getUrl ( ) { return 'https://maps.googleapis.com/maps/api/place/details/json' ; } protected async buildQuery ( query ) { const providerQuery = { key : this . apiKey , placeid : query . placeId , language : query . language , sensor : false , see interface fields : 'address_component,formatted_address,geometry,place_id,type' , } ; if ( query . countryCode ) { providerQuery . region = `.${ query . countryCode . toLowerCase ( ) }` ; } return providerQuery ; } protected async parseResponse ( response ) { if ( ! response . data . result ) { return [ ] ; } return [ await this . parseOneResult ( response . data . result ) ] ; } }