mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-10-31 08:06:33 +02:00 
			
		
		
		
	adapt to Friendly Public Transport Format, part 2
also added a user agent string
This commit is contained in:
		
							parent
							
								
									5abb2150fe
								
							
						
					
					
						commit
						44f6d3cd71
					
				
					 2 changed files with 8 additions and 7 deletions
				
			
		
							
								
								
									
										7
									
								
								index.js
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								index.js
									
										
									
									
									
								
							|  | @ -12,7 +12,7 @@ const defaults = { | |||
| 	onLocation: parse.location, | ||||
| 	onProduct:  parse.product, | ||||
| 	onRemark:   parse.remark, | ||||
| 	onAgency:   parse.agency | ||||
| 	onOperator: parse.operator | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -26,7 +26,8 @@ const request = (opt) => { | |||
| 			json: true, body: JSON.stringify(body), | ||||
| 			headers: { | ||||
| 				'Content-Type':    'application/json', | ||||
| 				'Accept-Encoding': 'gzip, deflate' | ||||
| 				'Accept-Encoding': 'gzip, deflate', | ||||
| 				'user-agent': 'https://github.com/derhuerst/hafas-client' | ||||
| 			} | ||||
| 		}) | ||||
| 
 | ||||
|  | @ -43,7 +44,7 @@ const request = (opt) => { | |||
| 			if (Array.isArray(c.locL)) d.locations = c.locL.map(opt.onLocation) | ||||
| 			if (Array.isArray(c.prodL)) d.products = c.prodL.map(opt.onProduct) | ||||
| 			if (Array.isArray(c.remL)) d.remarks = c.remL.map(opt.onRemark) | ||||
| 			if (Array.isArray(c.opL)) d.agencies = c.opL.map(opt.onAgency) | ||||
| 			if (Array.isArray(c.opL)) d.operators = c.opL.map(opt.onOperator) | ||||
| 			return d | ||||
| 		}).catch((err) => {throw err}) | ||||
| 	} | ||||
|  |  | |||
							
								
								
									
										8
									
								
								parse.js
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								parse.js
									
										
									
									
									
								
							|  | @ -127,10 +127,10 @@ const route = (tz, s, p, r) => (c) => { | |||
| 	const parts = c.secL.map(part(tz, s, p, r, c)) | ||||
| 	return { | ||||
| 		  parts | ||||
| 		, from:  parts[0].from | ||||
| 		, start: parts[0].start | ||||
| 		, to:    parts[parts.length - 1].to | ||||
| 		, end:   parts[parts.length - 1].end | ||||
| 		, origin: parts[0].origin | ||||
| 		, destination: parts[0].destination | ||||
| 		, departure: parts[parts.length - 1].departure | ||||
| 		, arrival: parts[parts.length - 1].arrival | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue