mirror of
				https://github.com/gnh1201/welsonjs.git
				synced 2025-10-30 20:41:18 +00:00 
			
		
		
		
	Update aviation.js
This commit is contained in:
		
							parent
							
								
									a99f1c396f
								
							
						
					
					
						commit
						7903a38f61
					
				|  | @ -5,16 +5,10 @@ | |||
| // ***SECURITY NOTICE***
 | ||||
| // Aviation Data Integration requires an internet connection, and data may be transmitted externally. Users must adhere to the terms of use and privacy policy.
 | ||||
| // - AviationStack website: https://aviationstack.com/?utm_source=FirstPromoter&utm_medium=Affiliate&fpr=namhyeon71
 | ||||
| // - SearchApi website: https://www.searchapi.io/?via=namhyeon
 | ||||
| // 
 | ||||
| var HTTP = require("lib/http"); | ||||
| 
 | ||||
| var API_BASE_URL = "https://api.aviationstack.com/v1"; | ||||
| var API_ACCESS_KEY = ""; | ||||
| 
 | ||||
| function loadApiKey() { | ||||
|     var s = FILE.readFile("data/aviationstack-apikey.txt", FILE.CdoCharset.CdoUTF_8); | ||||
|     return s.trim(); | ||||
| } | ||||
| var APIKEY = require("lib/apikey"); | ||||
| 
 | ||||
| function getData(type, params, limit, offset) { | ||||
|     var params = params || {}; | ||||
|  | @ -25,17 +19,13 @@ function getData(type, params, limit, offset) { | |||
|         return n > -1 ? n : 0; | ||||
|     }(parseInt(limit)); | ||||
|      | ||||
|     if (API_ACCESS_KEY == "") { | ||||
|         API_ACCESS_KEY = loadApiKey(); | ||||
|     } | ||||
|      | ||||
|     params["limit"] = limit; | ||||
|     params["offset"] = offset; | ||||
|     params["access_key"] = API_ACCESS_KEY; | ||||
|     params["access_key"] = APIKEY.getApiKey("aviationstack"); | ||||
|      | ||||
|     var response = HTTP.create() | ||||
|         .setParameters(params) | ||||
|         .open("GET", API_BASE_URL + "/" + type) | ||||
|         .open("GET", "https://api.aviationstack.com/v1/" + type) | ||||
|         .send(); | ||||
| 
 | ||||
|     return response.responseBody; | ||||
|  | @ -77,6 +67,39 @@ function getFlightsFuture(params, limit, offset) { | |||
|     return getData("flightsFuture", params, limit, offset); | ||||
| } | ||||
| 
 | ||||
| function getRoundTrip(arrival_id, departure_id, outbound_date, return_date) { | ||||
|     var response = HTTP.create() | ||||
|         .setParameters({ | ||||
|             "api_key": APIKEY.getApiKey("searchapi"), | ||||
|             "arrival_id": arrival_id, | ||||
|             "departure_id": departure_id, | ||||
|             "engine": "google_flights", | ||||
|             "flight_type": "round_trip", | ||||
|             "outbound_date": outbound_date, | ||||
|             "return_date": return_date | ||||
|         }) | ||||
|         .open("GET", "https://www.searchapi.io/api/v1/search") | ||||
|         .send(); | ||||
| 
 | ||||
|     return response.responseBody; | ||||
| } | ||||
| 
 | ||||
| function getOneWay(arrival_id, departure_id, outbound_date) { | ||||
|     var response = HTTP.create() | ||||
|         .setParameters({ | ||||
|             "api_key": APIKEY.getApiKey("searchapi"), | ||||
|             "arrival_id": arrival_id, | ||||
|             "departure_id": departure_id, | ||||
|             "engine": "google_flights", | ||||
|             "flight_type": "one_way", | ||||
|             "outbound_date": outbound_date | ||||
|         }) | ||||
|         .open("GET", "https://www.searchapi.io/api/v1/search") | ||||
|         .send(); | ||||
| 
 | ||||
|     return response.responseBody; | ||||
| } | ||||
| 
 | ||||
| exports.getData = getData; | ||||
| exports.getFlights = getFlights; | ||||
| exports.getRoutes = getRoutes; | ||||
|  | @ -87,8 +110,10 @@ exports.getCities = getCities; | |||
| exports.getCountries = getCountries; | ||||
| exports.getFlightSchedules = getFlightSchedules; | ||||
| exports.getFlightsFuture = getFlightsFuture; | ||||
| exports.getRoundTrip = getRoundTrip; | ||||
| exports.getOneWay = getOneWay; | ||||
| 
 | ||||
| exports.VERSIONINFO = "Aviation Data Integration (aviation.js) version 0.1.1"; | ||||
| exports.VERSIONINFO = "Aviation Data Integration (aviation.js) version 0.1.2"; | ||||
| exports.AUTHOR = "abuse@catswords.net"; | ||||
| exports.global = global; | ||||
| exports.require = global.require; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 GitHub
							GitHub