mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 01:56:33 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
	
		
			686 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
	
		
			686 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import {getHeaders} from './header.js';
 | 
						|
 | 
						|
const formatNearbyReq = (ctx, location) => {
 | 
						|
	const {profile, opt} = ctx;
 | 
						|
	if (opt.distance > 10000) {
 | 
						|
		throw new Error('maximum supported distance by this endpoint is 10000');
 | 
						|
	}
 | 
						|
	// TODO location types
 | 
						|
	return {
 | 
						|
		endpoint: profile.nearbyEndpoint,
 | 
						|
		body: {
 | 
						|
			area: {
 | 
						|
				coordinates: {
 | 
						|
					longitude: location.longitude,
 | 
						|
					latitude: location.latitude,
 | 
						|
				},
 | 
						|
				radius: opt.distance || 10000,
 | 
						|
			},
 | 
						|
			maxResults: opt.results,
 | 
						|
			products: profile.formatProductsFilter(ctx, opt.products || {}, 'dbnav'),
 | 
						|
		},
 | 
						|
		headers: getHeaders('application/x.db.vendo.mob.location.v3+json'),
 | 
						|
		method: 'post',
 | 
						|
	};
 | 
						|
};
 | 
						|
 | 
						|
export {
 | 
						|
	formatNearbyReq,
 | 
						|
};
 |