├── LICENSE
├── README.md
├── lib
├── APIHelper.js
├── Controllers
│ ├── APIsController.js
│ └── BaseController.js
├── Exceptions
│ └── APIException.js
├── Http
│ ├── Client
│ │ ├── HttpContext.js
│ │ └── RequestClient.js
│ ├── Request
│ │ └── HttpRequest.js
│ └── Response
│ │ └── HttpResponse.js
├── ModelFactory.js
├── Models
│ ├── Astro.js
│ ├── Astronomy.js
│ ├── AstronomyJsonResponse.js
│ ├── BaseModel.js
│ ├── Condition.js
│ ├── Current.js
│ ├── CurrentJsonResponse.js
│ ├── Day.js
│ ├── Forecast.js
│ ├── Forecast1.js
│ ├── ForecastJsonResponse.js
│ ├── Forecastday.js
│ ├── Forecastday1.js
│ ├── HistoryJsonResponse.js
│ ├── Hour.js
│ ├── IpJsonResponse.js
│ ├── Location.js
│ ├── SearchJsonResponse.js
│ └── TimezoneJsonResponse.js
├── ObjectMapper.js
├── configuration.js
└── index.js
└── package.json
/LICENSE:
--------------------------------------------------------------------------------
1 | License:
2 | ========
3 | The MIT License (MIT)
4 | http://opensource.org/licenses/MIT
5 |
6 | Copyright (c) 2014 - 2016 APIMATIC Limited
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 |
26 | Trade Mark:
27 | ==========
28 | APIMATIC is a trade mark for APIMATIC Limited
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting started
2 |
3 |
4 | # Introduction
5 |
6 | WeatherAPI.com provides access to weather and geo data via a JSON/XML restful API. It allows developers to create desktop, web and mobile applications using this data very easy.
7 |
8 | We provide following data through our API:
9 |
10 | * Real-time weather
11 |
12 | * 10 day weather forecast
13 |
14 | * Astronomy
15 |
16 | * Time zone
17 |
18 | * Location data
19 |
20 | * Search or Autocomplete API
21 |
22 | * NEW: Historical weather
23 |
24 | # Getting Started
25 |
26 | You need to [signup](https://www.weatherapi.com/signup.aspx) and then you can find your API key under [your account](https://www.weatherapi.com/login.aspx), and start using API right away!
27 |
28 | If you find any features missing or have any suggestions, please [contact us](https://www.weatherapi.com/contact.aspx).
29 |
30 | # Authentication
31 |
32 | API access to the data is protected by an API key. If at anytime, you find the API key has become vulnerable, please regenerate the key using Regenerate button next to the API key.
33 |
34 | Authentication to the WeatherAPI.com API is provided by passing your API key as request parameter through an API .
35 |
36 | ## key parameter
37 | key=YOUR_API_KEY
38 |
39 |
40 | ## How to Build
41 |
42 | The generated SDK relies on [Node Package Manager](https://www.npmjs.com/) (NPM) being available to resolve dependencies. If you don't already have NPM installed, please go ahead and follow instructions to install NPM from [here](https://nodejs.org/en/download/).
43 | The SDK also requires Node to be installed. If Node isn't already installed, please install it from [here](https://nodejs.org/en/download/)
44 | > NPM is installed by default when Node is installed
45 |
46 | To check if node and npm have been successfully installed, write the following commands in command prompt:
47 |
48 | * `node --version`
49 | * `npm -version`
50 |
51 | 
52 |
53 | Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):
54 |
55 | ```bash
56 | npm install
57 | ```
58 |
59 | 
60 |
61 | 
62 |
63 | This will install all dependencies in the `node_modules` folder.
64 |
65 | Once dependencies are resolved, you will need to move the folder `WeatherAPILib ` in to your `node_modules` folder.
66 |
67 | ## How to Use
68 |
69 | The following section explains how to use the library in a new project.
70 |
71 | ### 1. Open Project Folder
72 | Open an IDE/Text Editor for JavaScript like Sublime Text. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
73 |
74 | Click on `File` and select `Open Folder`.
75 |
76 | 
77 |
78 | Select the folder of your SDK and click on `Select Folder` to open it up in Sublime Text. The folder will become visible in the bar on the left.
79 |
80 | 
81 |
82 | ### 2. Creating a Test File
83 |
84 | Now right click on the folder name and select the `New File` option to create a new test file. Save it as `index.js` Now import the generated NodeJS library using the following lines of code:
85 |
86 | ```js
87 | var lib = require('lib');
88 | ```
89 |
90 | Save changes.
91 |
92 | 
93 |
94 | 
95 |
96 | ### 3. Running The Test File
97 |
98 | To run the `index.js` file, open up the command prompt and navigate to the Path where the SDK folder resides. Type the following command to run the file:
99 |
100 | ```
101 | node index.js
102 | ```
103 |
104 | 
105 |
106 |
107 | ## How to Test
108 |
109 | These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run.
110 | Tests can be run in a number of ways:
111 |
112 | ### Method 1 (Run all tests)
113 |
114 | 1. Navigate to the root directory of the SDK folder from command prompt.
115 | 2. Type `mocha --recursive` to run all the tests.
116 |
117 | ### Method 2 (Run all tests)
118 |
119 | 1. Navigate to the `../test/Controllers/` directory from command prompt.
120 | 2. Type `mocha *` to run all the tests.
121 |
122 | ### Method 3 (Run specific controller's tests)
123 |
124 | 1. Navigate to the `../test/Controllers/` directory from command prompt.
125 | 2. Type `mocha Weather APIController` to run all the tests in that controller file.
126 |
127 | > To increase mocha's default timeout, you can change the `TEST_TIMEOUT` parameter's value in `TestBootstrap.js`.
128 |
129 | 
130 |
131 | ## Initialization
132 |
133 | ### Authentication
134 | In order to setup authentication in the API client, you need the following information.
135 |
136 | | Parameter | Description |
137 | |-----------|-------------|
138 | | key | TODO: add a description |
139 |
140 |
141 |
142 | API client can be initialized as following:
143 |
144 | ```JavaScript
145 | const lib = require('lib');
146 |
147 | // Configuration parameters and credentials
148 | lib.Configuration.key = "key";
149 |
150 | ```
151 |
152 |
153 |
154 | # Class Reference
155 |
156 | ## List of Controllers
157 |
158 | * [APIsController](#ap_is_controller)
159 |
160 | ##  APIsController
161 |
162 | ### Get singleton instance
163 |
164 | The singleton instance of the ``` APIsController ``` class can be accessed from the API Client.
165 |
166 | ```javascript
167 | var controller = lib.APIsController;
168 | ```
169 |
170 | ###  getRealtimeWeather
171 |
172 | > Current weather or realtime weather API method allows a user to get up to date current weather information in json and xml. The data is returned as a Current Object.Current object contains current or realtime weather information for a given city.
173 |
174 |
175 | ```javascript
176 | function getRealtimeWeather(q, lang, callback)
177 | ```
178 | #### Parameters
179 |
180 | | Parameter | Tags | Description |
181 | |-----------|------|-------------|
182 | | q | ``` Required ``` | Pass US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to learn more. |
183 | | lang | ``` Optional ``` | Returns 'condition:text' field in API in the desired language. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to check 'lang-code'. |
184 |
185 |
186 |
187 | #### Example Usage
188 |
189 | ```javascript
190 |
191 | var q = 'q';
192 | var lang = 'lang';
193 |
194 | controller.getRealtimeWeather(q, lang, function(error, response, context) {
195 |
196 |
197 | });
198 | ```
199 |
200 | #### Errors
201 |
202 | | Error Code | Error Description |
203 | |------------|-------------------|
204 | | 400 | Error code 1003: Parameter 'q' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter 'q'Error code 9999: Internal application error. |
205 | | 401 | Error code 1002: API key not provided.Error code 2006: API key provided is invalid |
206 | | 403 | Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled. |
207 |
208 |
209 |
210 |
211 | ###  getForecastWeather
212 |
213 | > Forecast weather API method returns upto next 10 day weather forecast and weather alert as json. The data is returned as a Forecast Object.
Forecast object contains astronomy data, day weather forecast and hourly interval weather information for a given city.
214 |
215 |
216 | ```javascript
217 | function getForecastWeather(q, days, dt, unixdt, hour, lang, callback)
218 | ```
219 | #### Parameters
220 |
221 | | Parameter | Tags | Description |
222 | |-----------|------|-------------|
223 | | q | ``` Required ``` | Pass US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to learn more. |
224 | | days | ``` Required ``` | Number of days of weather forecast. Value ranges from 1 to 10 |
225 | | dt | ``` Optional ``` | Date should be between today and next 10 day in yyyy-MM-dd format |
226 | | unixdt | ``` Optional ``` | Please either pass 'dt' or 'unixdt' and not both in same request.
unixdt should be between today and next 10 day in Unix format |
227 | | hour | ``` Optional ``` | Must be in 24 hour. For example 5 pm should be hour=17, 6 am as hour=6 |
228 | | lang | ``` Optional ``` | Returns 'condition:text' field in API in the desired language. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to check 'lang-code'. |
229 |
230 |
231 |
232 | #### Example Usage
233 |
234 | ```javascript
235 |
236 | var q = 'q';
237 | var days = 19;
238 | var dt = date("D M d, Y G:i");
239 | var unixdt = 19;
240 | var hour = 19;
241 | var lang = 'lang';
242 |
243 | controller.getForecastWeather(q, days, dt, unixdt, hour, lang, function(error, response, context) {
244 |
245 |
246 | });
247 | ```
248 |
249 | #### Errors
250 |
251 | | Error Code | Error Description |
252 | |------------|-------------------|
253 | | 400 | Error code 1003: Parameter 'q' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter 'q'Error code 9999: Internal application error. |
254 | | 401 | Error code 1002: API key not provided.Error code 2006: API key provided is invalid |
255 | | 403 | Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled. |
256 |
257 |
258 |
259 |
260 | ###  getHistoryWeather
261 |
262 | > History weather API method returns historical weather for a date on or after 1st Jan, 2015 as json. The data is returned as a Forecast Object.
263 |
264 |
265 | ```javascript
266 | function getHistoryWeather(q, dt, unixdt, endDt, unixendDt, hour, lang, callback)
267 | ```
268 | #### Parameters
269 |
270 | | Parameter | Tags | Description |
271 | |-----------|------|-------------|
272 | | q | ``` Required ``` | Pass US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to learn more. |
273 | | dt | ``` Required ``` | Date on or after 1st Jan, 2015 in yyyy-MM-dd format |
274 | | unixdt | ``` Optional ``` | Please either pass 'dt' or 'unixdt' and not both in same request.
unixdt should be on or after 1st Jan, 2015 in Unix format |
275 | | endDt | ``` Optional ``` | Date on or after 1st Jan, 2015 in yyyy-MM-dd format'end_dt' should be greater than 'dt' parameter and difference should not be more than 30 days between the two dates. |
276 | | unixendDt | ``` Optional ``` | Date on or after 1st Jan, 2015 in Unix Timestamp format
unixend_dt has same restriction as 'end_dt' parameter. Please either pass 'end_dt' or 'unixend_dt' and not both in same request. e.g.: unixend_dt=1490227200 |
277 | | hour | ``` Optional ``` | Must be in 24 hour. For example 5 pm should be hour=17, 6 am as hour=6 |
278 | | lang | ``` Optional ``` | Returns 'condition:text' field in API in the desired language. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to check 'lang-code'. |
279 |
280 |
281 |
282 | #### Example Usage
283 |
284 | ```javascript
285 |
286 | var q = 'q';
287 | var dt = date("D M d, Y G:i");
288 | var unixdt = 19;
289 | var endDt = date("D M d, Y G:i");
290 | var unixendDt = 19;
291 | var hour = 19;
292 | var lang = 'lang';
293 |
294 | controller.getHistoryWeather(q, dt, unixdt, endDt, unixendDt, hour, lang, function(error, response, context) {
295 |
296 |
297 | });
298 | ```
299 |
300 | #### Errors
301 |
302 | | Error Code | Error Description |
303 | |------------|-------------------|
304 | | 400 | Error code 1003: Parameter 'q' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter 'q'Error code 9999: Internal application error. |
305 | | 401 | Error code 1002: API key not provided.Error code 2006: API key provided is invalid |
306 | | 403 | Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled. |
307 |
308 |
309 |
310 |
311 | ###  searchAutocompleteWeather
312 |
313 | > WeatherAPI.com Search or Autocomplete API returns matching cities and towns as an array of Location object.
314 |
315 |
316 | ```javascript
317 | function searchAutocompleteWeather(q, callback)
318 | ```
319 | #### Parameters
320 |
321 | | Parameter | Tags | Description |
322 | |-----------|------|-------------|
323 | | q | ``` Required ``` | Pass US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to learn more. |
324 |
325 |
326 |
327 | #### Example Usage
328 |
329 | ```javascript
330 |
331 | var q = 'q';
332 |
333 | controller.searchAutocompleteWeather(q, function(error, response, context) {
334 |
335 |
336 | });
337 | ```
338 |
339 | #### Errors
340 |
341 | | Error Code | Error Description |
342 | |------------|-------------------|
343 | | 400 | Error code 1003: Parameter 'q' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter 'q'Error code 9999: Internal application error. |
344 | | 401 | Error code 1002: API key not provided.Error code 2006: API key provided is invalid |
345 | | 403 | Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled. |
346 |
347 |
348 |
349 |
350 | ###  getIpLookup
351 |
352 | > IP Lookup API method allows a user to get up to date information for an IP address.
353 |
354 |
355 | ```javascript
356 | function getIpLookup(q, callback)
357 | ```
358 | #### Parameters
359 |
360 | | Parameter | Tags | Description |
361 | |-----------|------|-------------|
362 | | q | ``` Required ``` | Pass IP address. |
363 |
364 |
365 |
366 | #### Example Usage
367 |
368 | ```javascript
369 |
370 | var q = 'q';
371 |
372 | controller.getIpLookup(q, function(error, response, context) {
373 |
374 |
375 | });
376 | ```
377 |
378 | #### Errors
379 |
380 | | Error Code | Error Description |
381 | |------------|-------------------|
382 | | 400 | Error code 1003: Parameter 'q' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter 'q'Error code 9999: Internal application error. |
383 | | 401 | Error code 1002: API key not provided.Error code 2006: API key provided is invalid |
384 | | 403 | Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled. |
385 |
386 |
387 |
388 |
389 | ###  getTimeZone
390 |
391 | > Return Location Object
392 |
393 |
394 | ```javascript
395 | function getTimeZone(q, callback)
396 | ```
397 | #### Parameters
398 |
399 | | Parameter | Tags | Description |
400 | |-----------|------|-------------|
401 | | q | ``` Required ``` | Pass US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to learn more. |
402 |
403 |
404 |
405 | #### Example Usage
406 |
407 | ```javascript
408 |
409 | var q = 'q';
410 |
411 | controller.getTimeZone(q, function(error, response, context) {
412 |
413 |
414 | });
415 | ```
416 |
417 | #### Errors
418 |
419 | | Error Code | Error Description |
420 | |------------|-------------------|
421 | | 400 | Error code 1003: Parameter 'q' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter 'q'Error code 9999: Internal application error. |
422 | | 401 | Error code 1002: API key not provided.Error code 2006: API key provided is invalid |
423 | | 403 | Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled. |
424 |
425 |
426 |
427 |
428 | ###  getAstronomy
429 |
430 | > Return Location and Astronomy Object
431 |
432 |
433 | ```javascript
434 | function getAstronomy(q, dt, callback)
435 | ```
436 | #### Parameters
437 |
438 | | Parameter | Tags | Description |
439 | |-----------|------|-------------|
440 | | q | ``` Required ``` | Pass US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to learn more. |
441 | | dt | ``` Required ``` | Date on or after 1st Jan, 2015 in yyyy-MM-dd format |
442 |
443 |
444 |
445 | #### Example Usage
446 |
447 | ```javascript
448 |
449 | var q = 'q';
450 | var dt = date("D M d, Y G:i");
451 |
452 | controller.getAstronomy(q, dt, function(error, response, context) {
453 |
454 |
455 | });
456 | ```
457 |
458 | #### Errors
459 |
460 | | Error Code | Error Description |
461 | |------------|-------------------|
462 | | 400 | Error code 1003: Parameter 'q' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter 'q'Error code 9999: Internal application error. |
463 | | 401 | Error code 1002: API key not provided.Error code 2006: API key provided is invalid |
464 | | 403 | Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled. |
465 |
466 |
467 |
468 |
469 | [Back to List of Controllers](#list_of_controllers)
470 |
471 |
472 |
473 |
--------------------------------------------------------------------------------
/lib/APIHelper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const stream = require('stream');
10 |
11 | class APIHelper {
12 |
13 | /**
14 | * Replaces template parameters in the given url
15 | * @param {String} queryBuilder The query string builder to replace the template parameters
16 | * @param {Array} parameters The parameters to replace in the queryBuilder
17 | * @returns {String} The query string with replaced template parameters
18 | */
19 | static appendUrlWithTemplateParameters(queryBuilder, parameters) {
20 | // perform parameter validation
21 | if (queryBuilder === null) {
22 | return null;
23 | }
24 | if (parameters === null) {
25 | return queryBuilder;
26 | }
27 |
28 | let queryString = queryBuilder;
29 | // iterate and replace parameters
30 | const keys = Object.keys(parameters);
31 | for (let iter = 0; iter < keys.length; iter += 1) {
32 | let replaceValue = '';
33 |
34 | // load parameter value
35 | const element = parameters[keys[iter]];
36 | if (element === null) {
37 | replaceValue = '';
38 | } else if (element instanceof Array) {
39 | replaceValue = element.map(el => encodeURIComponent(el));
40 | replaceValue = replaceValue.join('/');
41 | } else {
42 | replaceValue = encodeURIComponent(element.toString());
43 | }
44 | queryString = queryString.replace(`{${keys[iter]}}`, replaceValue);
45 | }
46 | return queryString;
47 | }
48 |
49 | /**
50 | * Appends the given set of parameters to the given query string
51 | * @param {String} queryBuilder The query url string to append the parameters
52 | * @param {Array} parameters The parameters to append
53 | * @returns {String} The query string appended with query parameters
54 | */
55 | static appendUrlWithQueryParameters(queryBuilder, parameters) {
56 | // perform parameter validation
57 | if (queryBuilder === null) {
58 | return null;
59 | }
60 | if (parameters === queryBuilder) {
61 | return queryBuilder;
62 | }
63 | const hasParams = queryBuilder.indexOf('?') > -1;
64 |
65 | // iterate and replace parameters
66 | const encoded = this.urlEncodeObject(parameters);
67 | const separator = (hasParams) ? '&' : '?';
68 | const queryString = queryBuilder + separator + encoded;
69 | return queryString;
70 | }
71 |
72 | /**
73 | * Validates and processes the given Url
74 | * @param {String} url The Url to process
75 | * @return {String} Processed url
76 | */
77 | static cleanUrl(url) {
78 | // ensure that the urls are absolute
79 | const re = /^https?:\/\/[^/]+/;
80 | const match = url.match(re);
81 | if (match === null) {
82 | return null;
83 | }
84 |
85 | // remove redundant forward slashes
86 | const protocol = match[0];
87 | let queryUrl = url.substring(protocol.length);
88 | queryUrl = queryUrl.replace(/\/\/+/, '/');
89 | const result = protocol + queryUrl;
90 | return result;
91 | }
92 |
93 | /**
94 | * JSON Serialization of a given object.
95 | * @param {Object} data The object to serialize into JSON
96 | * @return {Object} The serialized Json string representation of the given object
97 | */
98 | static jsonSerialize(data) {
99 | return JSON.stringify(data);
100 | }
101 |
102 | /**
103 | * Formats the template parameters in the string
104 | * @param {string} str The string containing the template
105 | * @return {string} The string with template parameters filled in.
106 | */
107 | static formatString(str) {
108 | let formattedStr = str;
109 | if (!formattedStr || arguments.length <= 1) return formattedStr;
110 | for (let iter = 1; iter < arguments.length; iter += 1) {
111 | const reg = new RegExp(`\\{${(iter - 1)}\\}`, 'gm');
112 | formattedStr = formattedStr.replace(reg, arguments[iter]);
113 | }
114 | return formattedStr;
115 | }
116 |
117 | /**
118 | * Cleans the object by removing null properties.
119 | * @param {object} input Object or dictionary.
120 | * @return {object} Returns the cleaned version of the object.
121 | */
122 | static cleanObject(input) {
123 | if (!input) {
124 | return input;
125 | }
126 | const cleanedObj = input;
127 | if (cleanedObj instanceof stream.Stream) {
128 | return cleanedObj;
129 | }
130 | const keys = Object.keys(cleanedObj);
131 | for (let iter = 0; iter < keys.length; iter += 1) {
132 | const value = cleanedObj[keys[iter]];
133 | if (value === null || value === undefined) {
134 | if (cleanedObj.constructor === Array) {
135 | cleanedObj.splice(keys[iter], 1);
136 | } else delete cleanedObj[keys[iter]];
137 | } else if (Object.prototype.toString.call(value) === '[object Object]') {
138 | this.cleanObject(value);
139 | } else if (value.constructor === Array) {
140 | this.cleanObject(value);
141 | }
142 | }
143 | return cleanedObj;
144 | }
145 |
146 |
147 | /**
148 | * Shallow merges the properties of two objects
149 | * @param {object} first The object to merge in to
150 | * @param {object} second The object to be added to first
151 | *
152 | * @return {object} The merged (modified) first object
153 | */
154 | static merge(first, second) {
155 | if (!first) {
156 | return first;
157 | }
158 | const merged = first;
159 | if (second !== undefined && second !== null) {
160 | const attrNamesSecond = Object.keys(second);
161 | for (let iter = 0; iter < attrNamesSecond.length; iter += 1) {
162 | merged[attrNamesSecond[iter]] = second[attrNamesSecond[iter]];
163 | }
164 | }
165 | return merged;
166 | }
167 |
168 | /**
169 | * Checks if the elements of the given array are all primitives
170 | * @param {array} value The array to be checked
171 | *
172 | * @return {bool} The result of primitive checking
173 | */
174 | static isPrimitiveArray(value) {
175 | if (value.constructor && value.constructor !== Array) {
176 | return false;
177 | }
178 | if (value.length === 0) return true;
179 | return value.every(obj =>
180 | (obj === null
181 | || obj === undefined)
182 | || (obj.constructor
183 | && [String, Number, Boolean].indexOf(obj.constructor) >= 0));
184 | }
185 |
186 | /**
187 | * Converts an object to formdata serialization.
188 | * @param {Object} obj The object to serialize
189 | * @param {array} keys The keys of the object
190 | * @return {array} Result of serialization
191 | */
192 | static formDataEncodeObject(obj, keys) {
193 | let value;
194 | let fullSubName;
195 | let subValue;
196 | let innerObj;
197 | let returnKeys = keys;
198 | if (!keys) {
199 | returnKeys = [];
200 | }
201 | if (!obj) {
202 | return null;
203 | }
204 | const keysOfObj = Object.keys(obj);
205 | for (let outerIter = 0; outerIter < keysOfObj.length; outerIter += 1) {
206 | value = obj[keysOfObj[outerIter]];
207 | if (value instanceof stream.Stream) {
208 | returnKeys.push({
209 | key: keysOfObj[outerIter],
210 | value,
211 | });
212 | } else if (value instanceof Array) {
213 | const arrayFormat = '{0}[{1}]';
214 | for (let iter = 0; iter < value.length; iter += 1) {
215 | subValue = value[iter];
216 | fullSubName = this.formatString(arrayFormat, keysOfObj[outerIter], iter);
217 | innerObj = {};
218 | innerObj[fullSubName] = subValue;
219 | this.formDataEncodeObject(innerObj, returnKeys);
220 | }
221 | } else if (value instanceof Object) {
222 | const subNameKeys = Object.keys(value);
223 | for (let iter = 0; iter < subNameKeys.length; iter += 1) {
224 | subValue = value[subNameKeys[iter]];
225 | fullSubName = `${keysOfObj[outerIter]}[${subNameKeys[iter]}]`;
226 | innerObj = {};
227 | innerObj[fullSubName] = subValue;
228 | this.formDataEncodeObject(innerObj, returnKeys);
229 | }
230 | } else if (value !== undefined && value !== null) {
231 | if (!(value instanceof Object)) {
232 | returnKeys.push({
233 | key: keysOfObj[outerIter],
234 | value,
235 | });
236 | }
237 | }
238 | }
239 | return returnKeys;
240 | }
241 |
242 | /**
243 | * Converts an object to x-www-form-urlencoded serialization.
244 | * @param {Object} obj The object to be serialized
245 | * @return {String} The result of serialization
246 | */
247 | static urlEncodeObject(obj) {
248 | if (!obj) {
249 | return null;
250 | }
251 | const params = this.formDataEncodeObject(obj);
252 | let query = '';
253 | const index = Object.keys(params);
254 | for (let iter = 0; iter < index.length; iter += 1) {
255 | const pair = params[index[iter]];
256 | const key = pair.key;
257 | const value = pair.value;
258 | query += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
259 | }
260 | return query.length ? query.substr(0, query.length - 1) : query;
261 | }
262 |
263 | /**
264 | * Returns Datetime string value for field
265 | * @param value {object} Datetime object
266 | * @param type {string} The Datetime format of the date object (value) passed in
267 | * @returns {string} Stringified Datetime object
268 | */
269 | static stringifyDateTime(value, type) {
270 | if (value === null || value === undefined) {
271 | return null;
272 | }
273 | switch (type) {
274 | case 'unixtimestamp':
275 | return value.getTime();
276 | case 'rfc1123':
277 | return value.toUTCString();
278 | case 'rfc3339':
279 | return value.format();
280 | case 'date':
281 | return value.format('YYYY-MM-DD');
282 | default:
283 | return value.format('YYYY-MM-DD');
284 | }
285 | }
286 | }
287 |
288 | module.exports = APIHelper;
289 |
--------------------------------------------------------------------------------
/lib/Controllers/APIsController.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const _request = require('../Http/Client/RequestClient');
10 | const _configuration = require('../configuration');
11 | const _apiHelper = require('../APIHelper');
12 | const _baseController = require('./BaseController');
13 |
14 | class APIsController {
15 | /**
16 | * Current weather or realtime weather API method allows a user to get up to date current
17 | * weather information in json and xml. The data is returned as a Current Object.Current
18 | * object contains current or realtime weather information for a given city.
19 | *
20 | * @param {string} q Pass US Zipcode, UK Postcode, Canada Postalcode, IP address,
21 | * Latitude/Longitude (decimal degree) or city name. Visit [request parameter
22 | * section](https://www.weatherapi.com/docs/#intro-request) to learn more.
23 | * @param {string} lang (optional) Returns 'condition:text' field in API in the desired
24 | * language. Visit [request parameter section](https://www.weatherapi.
25 | * com/docs/#intro-request) to check 'lang-code'.
26 | *
27 | * @callback The callback function that returns response from the API call
28 | *
29 | * @returns {Promise}
30 | */
31 | static getRealtimeWeather(q, lang, callback) {
32 | // create empty callback if absent
33 | const _callback = typeof callback === 'function' ? callback : () => undefined;
34 |
35 | // prepare query string for API call
36 | const _baseUri = _configuration.BASEURI;
37 |
38 | const _pathUrl = '/current.json';
39 | let _queryBuilder = `${_baseUri}${_pathUrl}`;
40 |
41 | // process query parameters
42 | _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
43 | q,
44 | lang,
45 | key: _configuration.key,
46 | });
47 |
48 | // validate and preprocess url
49 | const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
50 |
51 | // prepare headers
52 | const _headers = {
53 | accept: 'application/json',
54 | 'user-agent': 'APIMATIC 2.0',
55 | };
56 |
57 | // construct the request
58 | const _options = {
59 | queryUrl: _queryUrl,
60 | method: 'GET',
61 | headers: _headers,
62 | };
63 |
64 | // build the response processing.
65 | return new Promise((_fulfill, _reject) => {
66 | _request(_options, (_error, _response, _context) => {
67 | let errorResponse;
68 | if (_error) {
69 | errorResponse = _baseController.validateResponse(_context);
70 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
71 | _reject(errorResponse.error);
72 | } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
73 | let parsed = JSON.parse(_response.body);
74 | parsed = _baseController.getObjectMapper().mapObject(parsed, 'CurrentJsonResponse');
75 | _callback(null, parsed, _context);
76 | _fulfill(parsed);
77 | } else if (_response.statusCode === 400) {
78 | const _err = { errorMessage: 'Error code 1003: Parameter \'q\' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter \'q\'Error code 9999: Internal application error.',
79 | errorCode: 400,
80 | errorResponse: _response.body,
81 | };
82 | _callback(_err, null, _context);
83 | _reject(_err);
84 | } else if (_response.statusCode === 401) {
85 | const _err = { errorMessage: 'Error code 1002: API key not provided.Error code 2006: API key provided is invalid',
86 | errorCode: 401,
87 | errorResponse: _response.body,
88 | };
89 | _callback(_err, null, _context);
90 | _reject(_err);
91 | } else if (_response.statusCode === 403) {
92 | const _err = { errorMessage: 'Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled.',
93 | errorCode: 403,
94 | errorResponse: _response.body,
95 | };
96 | _callback(_err, null, _context);
97 | _reject(_err);
98 | } else {
99 | errorResponse = _baseController.validateResponse(_context);
100 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
101 | _reject(errorResponse.error);
102 | }
103 | });
104 | });
105 | }
106 | /**
107 | * Forecast weather API method returns upto next 10 day weather forecast and weather alert as
108 | * json. The data is returned as a Forecast Object.
Forecast object contains astronomy
109 | * data, day weather forecast and hourly interval weather information for a given city.
110 | *
111 | * @param {string} q Pass US Zipcode, UK Postcode, Canada Postalcode, IP address,
112 | * Latitude/Longitude (decimal degree) or city name. Visit [request parameter
113 | * section](https://www.weatherapi.com/docs/#intro-request) to learn more.
114 | * @param {int} days Number of days of weather forecast. Value ranges from 1 to 10
115 | * @param {date} dt (optional) Date should be between today and next 10 day in yyyy-MM-dd
116 | * format
117 | * @param {int} unixdt (optional) Please either pass 'dt' or 'unixdt' and not both in same
118 | * request.
unixdt should be between today and next 10 day in Unix
119 | * format
120 | * @param {int} hour (optional) Must be in 24 hour. For example 5 pm should be hour=17, 6 am as
121 | * hour=6
122 | * @param {string} lang (optional) Returns 'condition:text' field in API in the desired
123 | * language. Visit [request parameter section](https://www.weatherapi.
124 | * com/docs/#intro-request) to check 'lang-code'.
125 | *
126 | * @callback The callback function that returns response from the API call
127 | *
128 | * @returns {Promise}
129 | */
130 | static getForecastWeather(q, days, dt, unixdt, hour, lang, callback) {
131 | // create empty callback if absent
132 | const _callback = typeof callback === 'function' ? callback : () => undefined;
133 |
134 | // prepare query string for API call
135 | const _baseUri = _configuration.BASEURI;
136 |
137 | const _pathUrl = '/forecast.json';
138 | let _queryBuilder = `${_baseUri}${_pathUrl}`;
139 |
140 | // process query parameters
141 | _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
142 | q,
143 | days,
144 | dt: _apiHelper.stringifyDateTime(dt, 'date'),
145 | unixdt,
146 | hour,
147 | lang,
148 | key: _configuration.key,
149 | });
150 |
151 | // validate and preprocess url
152 | const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
153 |
154 | // prepare headers
155 | const _headers = {
156 | accept: 'application/json',
157 | 'user-agent': 'APIMATIC 2.0',
158 | };
159 |
160 | // construct the request
161 | const _options = {
162 | queryUrl: _queryUrl,
163 | method: 'GET',
164 | headers: _headers,
165 | };
166 |
167 | // build the response processing.
168 | return new Promise((_fulfill, _reject) => {
169 | _request(_options, (_error, _response, _context) => {
170 | let errorResponse;
171 | if (_error) {
172 | errorResponse = _baseController.validateResponse(_context);
173 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
174 | _reject(errorResponse.error);
175 | } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
176 | let parsed = JSON.parse(_response.body);
177 | parsed = _baseController.getObjectMapper().mapObject(parsed, 'ForecastJsonResponse');
178 | _callback(null, parsed, _context);
179 | _fulfill(parsed);
180 | } else if (_response.statusCode === 400) {
181 | const _err = { errorMessage: 'Error code 1003: Parameter \'q\' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter \'q\'Error code 9999: Internal application error.',
182 | errorCode: 400,
183 | errorResponse: _response.body,
184 | };
185 | _callback(_err, null, _context);
186 | _reject(_err);
187 | } else if (_response.statusCode === 401) {
188 | const _err = { errorMessage: 'Error code 1002: API key not provided.Error code 2006: API key provided is invalid',
189 | errorCode: 401,
190 | errorResponse: _response.body,
191 | };
192 | _callback(_err, null, _context);
193 | _reject(_err);
194 | } else if (_response.statusCode === 403) {
195 | const _err = { errorMessage: 'Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled.',
196 | errorCode: 403,
197 | errorResponse: _response.body,
198 | };
199 | _callback(_err, null, _context);
200 | _reject(_err);
201 | } else {
202 | errorResponse = _baseController.validateResponse(_context);
203 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
204 | _reject(errorResponse.error);
205 | }
206 | });
207 | });
208 | }
209 | /**
210 | * History weather API method returns historical weather for a date on or after 1st Jan, 2015
211 | * as json. The data is returned as a Forecast Object.
212 | *
213 | * @param {string} q Pass US Zipcode, UK Postcode, Canada Postalcode, IP address,
214 | * Latitude/Longitude (decimal degree) or city name. Visit [request parameter
215 | * section](https://www.weatherapi.com/docs/#intro-request) to learn more.
216 | * @param {date} dt Date on or after 1st Jan, 2015 in yyyy-MM-dd format
217 | * @param {int} unixdt (optional) Please either pass 'dt' or 'unixdt' and not both in same
218 | * request.
unixdt should be on or after 1st Jan, 2015 in Unix format
219 | * @param {date} endDt (optional) Date on or after 1st Jan, 2015 in yyyy-MM-dd format'end_dt'
220 | * should be greater than 'dt' parameter and difference should not be more
221 | * than 30 days between the two dates.
222 | * @param {int} unixendDt (optional) Date on or after 1st Jan, 2015 in Unix Timestamp format
unixend_dt has same restriction as 'end_dt' parameter. Please
224 | * either pass 'end_dt' or 'unixend_dt' and not both in same request. e.
225 | * g.: unixend_dt=1490227200
226 | * @param {int} hour (optional) Must be in 24 hour. For example 5 pm should be hour=17, 6 am as
227 | * hour=6
228 | * @param {string} lang (optional) Returns 'condition:text' field in API in the desired
229 | * language. Visit [request parameter section](https://www.weatherapi.
230 | * com/docs/#intro-request) to check 'lang-code'.
231 | *
232 | * @callback The callback function that returns response from the API call
233 | *
234 | * @returns {Promise}
235 | */
236 | static getHistoryWeather(q, dt, unixdt, endDt, unixendDt, hour, lang, callback) {
237 | // create empty callback if absent
238 | const _callback = typeof callback === 'function' ? callback : () => undefined;
239 |
240 | // prepare query string for API call
241 | const _baseUri = _configuration.BASEURI;
242 |
243 | const _pathUrl = '/history.json';
244 | let _queryBuilder = `${_baseUri}${_pathUrl}`;
245 |
246 | // process query parameters
247 | _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
248 | q,
249 | dt: _apiHelper.stringifyDateTime(dt, 'date'),
250 | unixdt,
251 | end_dt: _apiHelper.stringifyDateTime(endDt, 'date'),
252 | unixend_dt: unixendDt,
253 | hour,
254 | lang,
255 | key: _configuration.key,
256 | });
257 |
258 | // validate and preprocess url
259 | const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
260 |
261 | // prepare headers
262 | const _headers = {
263 | accept: 'application/json',
264 | 'user-agent': 'APIMATIC 2.0',
265 | };
266 |
267 | // construct the request
268 | const _options = {
269 | queryUrl: _queryUrl,
270 | method: 'GET',
271 | headers: _headers,
272 | };
273 |
274 | // build the response processing.
275 | return new Promise((_fulfill, _reject) => {
276 | _request(_options, (_error, _response, _context) => {
277 | let errorResponse;
278 | if (_error) {
279 | errorResponse = _baseController.validateResponse(_context);
280 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
281 | _reject(errorResponse.error);
282 | } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
283 | let parsed = JSON.parse(_response.body);
284 | parsed = _baseController.getObjectMapper().mapObject(parsed, 'HistoryJsonResponse');
285 | _callback(null, parsed, _context);
286 | _fulfill(parsed);
287 | } else if (_response.statusCode === 400) {
288 | const _err = { errorMessage: 'Error code 1003: Parameter \'q\' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter \'q\'Error code 9999: Internal application error.',
289 | errorCode: 400,
290 | errorResponse: _response.body,
291 | };
292 | _callback(_err, null, _context);
293 | _reject(_err);
294 | } else if (_response.statusCode === 401) {
295 | const _err = { errorMessage: 'Error code 1002: API key not provided.Error code 2006: API key provided is invalid',
296 | errorCode: 401,
297 | errorResponse: _response.body,
298 | };
299 | _callback(_err, null, _context);
300 | _reject(_err);
301 | } else if (_response.statusCode === 403) {
302 | const _err = { errorMessage: 'Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled.',
303 | errorCode: 403,
304 | errorResponse: _response.body,
305 | };
306 | _callback(_err, null, _context);
307 | _reject(_err);
308 | } else {
309 | errorResponse = _baseController.validateResponse(_context);
310 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
311 | _reject(errorResponse.error);
312 | }
313 | });
314 | });
315 | }
316 | /**
317 | * WeatherAPI.com Search or Autocomplete API returns matching cities and towns as an array of
318 | * Location object.
319 | *
320 | * @param {string} q Pass US Zipcode, UK Postcode, Canada Postalcode, IP address,
321 | * Latitude/Longitude (decimal degree) or city name. Visit [request parameter
322 | * section](https://www.weatherapi.com/docs/#intro-request) to learn more.
323 | *
324 | * @callback The callback function that returns response from the API call
325 | *
326 | * @returns {Promise}
327 | */
328 | static searchAutocompleteWeather(q, callback) {
329 | // create empty callback if absent
330 | const _callback = typeof callback === 'function' ? callback : () => undefined;
331 |
332 | // prepare query string for API call
333 | const _baseUri = _configuration.BASEURI;
334 |
335 | const _pathUrl = '/search.json';
336 | let _queryBuilder = `${_baseUri}${_pathUrl}`;
337 |
338 | // process query parameters
339 | _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
340 | q,
341 | key: _configuration.key,
342 | });
343 |
344 | // validate and preprocess url
345 | const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
346 |
347 | // prepare headers
348 | const _headers = {
349 | accept: 'application/json',
350 | 'user-agent': 'APIMATIC 2.0',
351 | };
352 |
353 | // construct the request
354 | const _options = {
355 | queryUrl: _queryUrl,
356 | method: 'GET',
357 | headers: _headers,
358 | };
359 |
360 | // build the response processing.
361 | return new Promise((_fulfill, _reject) => {
362 | _request(_options, (_error, _response, _context) => {
363 | let errorResponse;
364 | if (_error) {
365 | errorResponse = _baseController.validateResponse(_context);
366 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
367 | _reject(errorResponse.error);
368 | } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
369 | let parsed = JSON.parse(_response.body);
370 | parsed = parsed.map(model =>
371 | _baseController.getObjectMapper().mapObject(model, 'SearchJsonResponse'));
372 | _callback(null, parsed, _context);
373 | _fulfill(parsed);
374 | } else if (_response.statusCode === 400) {
375 | const _err = { errorMessage: 'Error code 1003: Parameter \'q\' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter \'q\'Error code 9999: Internal application error.',
376 | errorCode: 400,
377 | errorResponse: _response.body,
378 | };
379 | _callback(_err, null, _context);
380 | _reject(_err);
381 | } else if (_response.statusCode === 401) {
382 | const _err = { errorMessage: 'Error code 1002: API key not provided.Error code 2006: API key provided is invalid',
383 | errorCode: 401,
384 | errorResponse: _response.body,
385 | };
386 | _callback(_err, null, _context);
387 | _reject(_err);
388 | } else if (_response.statusCode === 403) {
389 | const _err = { errorMessage: 'Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled.',
390 | errorCode: 403,
391 | errorResponse: _response.body,
392 | };
393 | _callback(_err, null, _context);
394 | _reject(_err);
395 | } else {
396 | errorResponse = _baseController.validateResponse(_context);
397 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
398 | _reject(errorResponse.error);
399 | }
400 | });
401 | });
402 | }
403 | /**
404 | * IP Lookup API method allows a user to get up to date information for an IP address.
405 | *
406 | * @param {string} q Pass IP address.
407 | *
408 | * @callback The callback function that returns response from the API call
409 | *
410 | * @returns {Promise}
411 | */
412 | static getIpLookup(q, callback) {
413 | // create empty callback if absent
414 | const _callback = typeof callback === 'function' ? callback : () => undefined;
415 |
416 | // prepare query string for API call
417 | const _baseUri = _configuration.BASEURI;
418 |
419 | const _pathUrl = '/ip.json';
420 | let _queryBuilder = `${_baseUri}${_pathUrl}`;
421 |
422 | // process query parameters
423 | _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
424 | q,
425 | key: _configuration.key,
426 | });
427 |
428 | // validate and preprocess url
429 | const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
430 |
431 | // prepare headers
432 | const _headers = {
433 | accept: 'application/json',
434 | 'user-agent': 'APIMATIC 2.0',
435 | };
436 |
437 | // construct the request
438 | const _options = {
439 | queryUrl: _queryUrl,
440 | method: 'GET',
441 | headers: _headers,
442 | };
443 |
444 | // build the response processing.
445 | return new Promise((_fulfill, _reject) => {
446 | _request(_options, (_error, _response, _context) => {
447 | let errorResponse;
448 | if (_error) {
449 | errorResponse = _baseController.validateResponse(_context);
450 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
451 | _reject(errorResponse.error);
452 | } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
453 | let parsed = JSON.parse(_response.body);
454 | parsed = _baseController.getObjectMapper().mapObject(parsed, 'IpJsonResponse');
455 | _callback(null, parsed, _context);
456 | _fulfill(parsed);
457 | } else if (_response.statusCode === 400) {
458 | const _err = { errorMessage: 'Error code 1003: Parameter \'q\' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter \'q\'Error code 9999: Internal application error.',
459 | errorCode: 400,
460 | errorResponse: _response.body,
461 | };
462 | _callback(_err, null, _context);
463 | _reject(_err);
464 | } else if (_response.statusCode === 401) {
465 | const _err = { errorMessage: 'Error code 1002: API key not provided.Error code 2006: API key provided is invalid',
466 | errorCode: 401,
467 | errorResponse: _response.body,
468 | };
469 | _callback(_err, null, _context);
470 | _reject(_err);
471 | } else if (_response.statusCode === 403) {
472 | const _err = { errorMessage: 'Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled.',
473 | errorCode: 403,
474 | errorResponse: _response.body,
475 | };
476 | _callback(_err, null, _context);
477 | _reject(_err);
478 | } else {
479 | errorResponse = _baseController.validateResponse(_context);
480 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
481 | _reject(errorResponse.error);
482 | }
483 | });
484 | });
485 | }
486 | /**
487 | * Return Location Object
488 | *
489 | * @param {string} q Pass US Zipcode, UK Postcode, Canada Postalcode, IP address,
490 | * Latitude/Longitude (decimal degree) or city name. Visit [request parameter
491 | * section](https://www.weatherapi.com/docs/#intro-request) to learn more.
492 | *
493 | * @callback The callback function that returns response from the API call
494 | *
495 | * @returns {Promise}
496 | */
497 | static getTimeZone(q, callback) {
498 | // create empty callback if absent
499 | const _callback = typeof callback === 'function' ? callback : () => undefined;
500 |
501 | // prepare query string for API call
502 | const _baseUri = _configuration.BASEURI;
503 |
504 | const _pathUrl = '/timezone.json';
505 | let _queryBuilder = `${_baseUri}${_pathUrl}`;
506 |
507 | // process query parameters
508 | _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
509 | q,
510 | key: _configuration.key,
511 | });
512 |
513 | // validate and preprocess url
514 | const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
515 |
516 | // prepare headers
517 | const _headers = {
518 | accept: 'application/json',
519 | 'user-agent': 'APIMATIC 2.0',
520 | };
521 |
522 | // construct the request
523 | const _options = {
524 | queryUrl: _queryUrl,
525 | method: 'GET',
526 | headers: _headers,
527 | };
528 |
529 | // build the response processing.
530 | return new Promise((_fulfill, _reject) => {
531 | _request(_options, (_error, _response, _context) => {
532 | let errorResponse;
533 | if (_error) {
534 | errorResponse = _baseController.validateResponse(_context);
535 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
536 | _reject(errorResponse.error);
537 | } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
538 | let parsed = JSON.parse(_response.body);
539 | parsed = _baseController.getObjectMapper().mapObject(parsed, 'TimezoneJsonResponse');
540 | _callback(null, parsed, _context);
541 | _fulfill(parsed);
542 | } else if (_response.statusCode === 400) {
543 | const _err = { errorMessage: 'Error code 1003: Parameter \'q\' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter \'q\'Error code 9999: Internal application error.',
544 | errorCode: 400,
545 | errorResponse: _response.body,
546 | };
547 | _callback(_err, null, _context);
548 | _reject(_err);
549 | } else if (_response.statusCode === 401) {
550 | const _err = { errorMessage: 'Error code 1002: API key not provided.Error code 2006: API key provided is invalid',
551 | errorCode: 401,
552 | errorResponse: _response.body,
553 | };
554 | _callback(_err, null, _context);
555 | _reject(_err);
556 | } else if (_response.statusCode === 403) {
557 | const _err = { errorMessage: 'Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled.',
558 | errorCode: 403,
559 | errorResponse: _response.body,
560 | };
561 | _callback(_err, null, _context);
562 | _reject(_err);
563 | } else {
564 | errorResponse = _baseController.validateResponse(_context);
565 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
566 | _reject(errorResponse.error);
567 | }
568 | });
569 | });
570 | }
571 | /**
572 | * Return Location and Astronomy Object
573 | *
574 | * @param {string} q Pass US Zipcode, UK Postcode, Canada Postalcode, IP address,
575 | * Latitude/Longitude (decimal degree) or city name. Visit [request parameter
576 | * section](https://www.weatherapi.com/docs/#intro-request) to learn more.
577 | * @param {date} dt Date on or after 1st Jan, 2015 in yyyy-MM-dd format
578 | *
579 | * @callback The callback function that returns response from the API call
580 | *
581 | * @returns {Promise}
582 | */
583 | static getAstronomy(q, dt, callback) {
584 | // create empty callback if absent
585 | const _callback = typeof callback === 'function' ? callback : () => undefined;
586 |
587 | // prepare query string for API call
588 | const _baseUri = _configuration.BASEURI;
589 |
590 | const _pathUrl = '/astronomy.json';
591 | let _queryBuilder = `${_baseUri}${_pathUrl}`;
592 |
593 | // process query parameters
594 | _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
595 | q,
596 | dt: _apiHelper.stringifyDateTime(dt, 'date'),
597 | key: _configuration.key,
598 | });
599 |
600 | // validate and preprocess url
601 | const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
602 |
603 | // prepare headers
604 | const _headers = {
605 | accept: 'application/json',
606 | 'user-agent': 'APIMATIC 2.0',
607 | };
608 |
609 | // construct the request
610 | const _options = {
611 | queryUrl: _queryUrl,
612 | method: 'GET',
613 | headers: _headers,
614 | };
615 |
616 | // build the response processing.
617 | return new Promise((_fulfill, _reject) => {
618 | _request(_options, (_error, _response, _context) => {
619 | let errorResponse;
620 | if (_error) {
621 | errorResponse = _baseController.validateResponse(_context);
622 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
623 | _reject(errorResponse.error);
624 | } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
625 | let parsed = JSON.parse(_response.body);
626 | parsed = _baseController.getObjectMapper().mapObject(parsed, 'AstronomyJsonResponse');
627 | _callback(null, parsed, _context);
628 | _fulfill(parsed);
629 | } else if (_response.statusCode === 400) {
630 | const _err = { errorMessage: 'Error code 1003: Parameter \'q\' not provided.Error code 1005: API request url is invalid.Error code 1006: No location found matching parameter \'q\'Error code 9999: Internal application error.',
631 | errorCode: 400,
632 | errorResponse: _response.body,
633 | };
634 | _callback(_err, null, _context);
635 | _reject(_err);
636 | } else if (_response.statusCode === 401) {
637 | const _err = { errorMessage: 'Error code 1002: API key not provided.Error code 2006: API key provided is invalid',
638 | errorCode: 401,
639 | errorResponse: _response.body,
640 | };
641 | _callback(_err, null, _context);
642 | _reject(_err);
643 | } else if (_response.statusCode === 403) {
644 | const _err = { errorMessage: 'Error code 2007: API key has exceeded calls per month quota.
Error code 2008: API key has been disabled.',
645 | errorCode: 403,
646 | errorResponse: _response.body,
647 | };
648 | _callback(_err, null, _context);
649 | _reject(_err);
650 | } else {
651 | errorResponse = _baseController.validateResponse(_context);
652 | _callback(errorResponse.error, errorResponse.response, errorResponse.context);
653 | _reject(errorResponse.error);
654 | }
655 | });
656 | });
657 | }
658 | }
659 | module.exports = APIsController;
660 |
--------------------------------------------------------------------------------
/lib/Controllers/BaseController.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const _objectMapper = require('../ObjectMapper');
10 |
11 | const _objectMapperInstance = new _objectMapper();
12 |
13 | class BaseController {
14 | /**
15 | * Get ObjectMapper instance
16 | * @return {ObjectMapper} Shared instance
17 | */
18 | static getObjectMapper() {
19 | return _objectMapperInstance;
20 | }
21 |
22 | /**
23 | * Global error handling
24 | * @param {HttpContext} _context HttpContext containing request and response objects
25 | * @callback Callback function which returns error, response, context
26 | */
27 | static validateResponse(_context) {
28 | const errorObj = {
29 | errorMessage: '',
30 | errorCode: '',
31 | errorResponse: _context.response.body,
32 | };
33 | const returnObj = {
34 | error: errorObj,
35 | response: null,
36 | context: _context,
37 | };
38 |
39 | returnObj.error.errorMessage = 'HTTP Response Not OK';
40 | returnObj.error.errorCode = _context.response.statusCode;
41 |
42 | return returnObj;
43 | }
44 | }
45 |
46 | module.exports = BaseController;
47 |
--------------------------------------------------------------------------------
/lib/Exceptions/APIException.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | /**
10 | * Creates an instance of APIException
11 | */
12 | class APIException {
13 | /**
14 | * @constructor
15 | */
16 | constructor() {
17 | this.reason = '';
18 | this.context = '';
19 | }
20 |
21 | /**
22 | * Function containing information about the fields of this model
23 | * @return {array} Empty array
24 | */
25 | static mappingInfo() {
26 | return [];
27 | }
28 | }
29 |
30 | module.exports = APIException;
31 |
--------------------------------------------------------------------------------
/lib/Http/Client/HttpContext.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Creates an instance of HttpContext.
5 | */
6 | class HttpContext {
7 | constructor() {
8 | this.request = null;
9 | this.response = null;
10 | }
11 | }
12 |
13 | module.exports = HttpContext;
14 |
--------------------------------------------------------------------------------
/lib/Http/Client/RequestClient.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const HttpContext = require('./HttpContext');
10 | const HttpResponse = require('../Response/HttpResponse');
11 | const request = require('request');
12 | const APIHelper = require('../../APIHelper');
13 |
14 | // convert to request's version of http request
15 | const convertHttpRequest = function convertHttpRequest(req) {
16 | const options = {
17 | url: req.queryUrl,
18 | method: req.method,
19 | headers: req.headers,
20 | followAllRedirects: true,
21 | };
22 | if (req.username) {
23 | options.auth = { user: req.username, pass: req.password };
24 | }
25 | if (req.body) {
26 | options.body = req.body;
27 | }
28 | if (req.formData) {
29 | // need to add to request's formdata object directly
30 | // options.formData = APIHelper.formDataEncodeObject(req.formData);
31 | }
32 | if (req.form) {
33 | options.form = APIHelper.urlEncodeObject(req.form);
34 | options.headers['content-type'] = 'application/x-www-form-urlencoded';
35 | }
36 | return options;
37 | };
38 |
39 | const appendFormdata = function appendFormdata(form, data) {
40 | const dataArray = APIHelper.formDataEncodeObject(data);
41 | for (let index = 0; index < dataArray.length; index += 1) {
42 | if (Object.prototype.hasOwnProperty.call(dataArray, index)) {
43 | const key = dataArray[index].key;
44 | const value = dataArray[index].value;
45 | form.append(key, value);
46 | }
47 | }
48 | };
49 |
50 | const convertHttpResponse = function convertHttpResponse(resp) {
51 | const response = new HttpResponse();
52 | if (resp) {
53 | response.body = resp.body;
54 | response.headers = resp.headers;
55 | response.statusCode = resp.statusCode;
56 | }
57 |
58 | return response;
59 | };
60 |
61 | /**
62 | * Execute a given HttpRequest to get string response back
63 | * @param {HttpRequest | HttpBodyRequest} req The query string builder to replace the
64 | * template parameters
65 | * @param {function} callback Callback function to execute when request completes or fails
66 | * @param {Array} parameters The parameters to replace in the queryBuilder
67 | * @returns {void} Does not return anything
68 | */
69 | const executeRequest = function executeRequest(req, callback) {
70 | // convert abstracted request to request's http request
71 | const convertedRequest = convertHttpRequest(req);
72 | const context = new HttpContext();
73 | context.request = req;
74 |
75 | // make a temp callback
76 | const internalCallback = function cb(error, res) {
77 | const response = convertHttpResponse(res);
78 | context.response = response;
79 | callback(error, response, context);
80 | };
81 |
82 | // make the request
83 | const rq = request(convertedRequest, internalCallback);
84 | // add formdata directly.
85 | if (req.formData) {
86 | const form = rq.form();
87 | appendFormdata(form, req.formData);
88 | }
89 | };
90 | module.exports = executeRequest;
91 |
--------------------------------------------------------------------------------
/lib/Http/Request/HttpRequest.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Creates an instance of HttpRequest
5 | */
6 | class HttpRequest {
7 | constructor() {
8 | this.method = null;
9 | this.headers = {};
10 | this.queryUrl = null;
11 | this.formData = null;
12 | this.form = null;
13 | this.username = null;
14 | this.password = null;
15 | this.body = null;
16 | }
17 | }
18 |
19 | module.exports = HttpRequest;
20 |
--------------------------------------------------------------------------------
/lib/Http/Response/HttpResponse.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Creates an instance of HttpResponse
5 | */
6 | class HttpResponse {
7 | constructor() {
8 | this.statusCode = null;
9 | this.body = null;
10 | this.headers = null;
11 | }
12 | }
13 |
14 | module.exports = HttpResponse;
15 |
--------------------------------------------------------------------------------
/lib/ModelFactory.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const CurrentJsonResponse = require('../lib/Models/CurrentJsonResponse');
10 | const Location = require('../lib/Models/Location');
11 | const Current = require('../lib/Models/Current');
12 | const Condition = require('../lib/Models/Condition');
13 | const ForecastJsonResponse = require('../lib/Models/ForecastJsonResponse');
14 | const Forecast = require('../lib/Models/Forecast');
15 | const Forecastday = require('../lib/Models/Forecastday');
16 | const Day = require('../lib/Models/Day');
17 | const Astro = require('../lib/Models/Astro');
18 | const HistoryJsonResponse = require('../lib/Models/HistoryJsonResponse');
19 | const Forecast1 = require('../lib/Models/Forecast1');
20 | const Forecastday1 = require('../lib/Models/Forecastday1');
21 | const Hour = require('../lib/Models/Hour');
22 | const SearchJsonResponse = require('../lib/Models/SearchJsonResponse');
23 | const IpJsonResponse = require('../lib/Models/IpJsonResponse');
24 | const TimezoneJsonResponse = require('../lib/Models/TimezoneJsonResponse');
25 | const AstronomyJsonResponse = require('../lib/Models/AstronomyJsonResponse');
26 | const Astronomy = require('../lib/Models/Astronomy');
27 |
28 | const classMap = {
29 | CurrentJsonResponse,
30 | Location,
31 | Current,
32 | Condition,
33 | ForecastJsonResponse,
34 | Forecast,
35 | Forecastday,
36 | Day,
37 | Astro,
38 | HistoryJsonResponse,
39 | Forecast1,
40 | Forecastday1,
41 | Hour,
42 | SearchJsonResponse,
43 | IpJsonResponse,
44 | TimezoneJsonResponse,
45 | AstronomyJsonResponse,
46 | Astronomy,
47 | };
48 |
49 | /**
50 | * Factory class to create instances of models and exception classes
51 | */
52 | class ModelFactory {
53 | /**
54 | * Creates instance of a model class
55 | * @param modelName {string} Name of class to instantiate
56 | * @returns {object} Instance of the model class
57 | */
58 | static getInstance(modelName) {
59 | return new classMap[modelName]();
60 | }
61 | }
62 |
63 | module.exports = ModelFactory;
64 |
--------------------------------------------------------------------------------
/lib/Models/Astro.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Astro
13 | */
14 | class Astro extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.sunrise = this.constructor.getValue(obj.sunrise);
23 | this.sunset = this.constructor.getValue(obj.sunset);
24 | this.moonrise = this.constructor.getValue(obj.moonrise);
25 | this.moonset = this.constructor.getValue(obj.moonset);
26 | }
27 |
28 | /**
29 | * Function containing information about the fields of this model
30 | * @return {array} Array of objects containing information about the fields
31 | */
32 | static mappingInfo() {
33 | return super.mappingInfo().concat([
34 | { name: 'sunrise', realName: 'sunrise' },
35 | { name: 'sunset', realName: 'sunset' },
36 | { name: 'moonrise', realName: 'moonrise' },
37 | { name: 'moonset', realName: 'moonset' },
38 | ]);
39 | }
40 |
41 | /**
42 | * Function containing information about discriminator values
43 | * mapped with their corresponding model class names
44 | *
45 | * @return {object} Object containing Key-Value pairs mapping discriminator
46 | * values with their corresponding model classes
47 | */
48 | static discriminatorMap() {
49 | return {};
50 | }
51 | }
52 |
53 | module.exports = Astro;
54 |
--------------------------------------------------------------------------------
/lib/Models/Astronomy.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Astronomy
13 | */
14 | class Astronomy extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.astro = this.constructor.getValue(obj.astro);
23 | }
24 |
25 | /**
26 | * Function containing information about the fields of this model
27 | * @return {array} Array of objects containing information about the fields
28 | */
29 | static mappingInfo() {
30 | return super.mappingInfo().concat([
31 | { name: 'astro', realName: 'astro', type: 'Astro' },
32 | ]);
33 | }
34 |
35 | /**
36 | * Function containing information about discriminator values
37 | * mapped with their corresponding model class names
38 | *
39 | * @return {object} Object containing Key-Value pairs mapping discriminator
40 | * values with their corresponding model classes
41 | */
42 | static discriminatorMap() {
43 | return {};
44 | }
45 | }
46 |
47 | module.exports = Astronomy;
48 |
--------------------------------------------------------------------------------
/lib/Models/AstronomyJsonResponse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of AstronomyJsonResponse
13 | */
14 | class AstronomyJsonResponse extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.location = this.constructor.getValue(obj.location);
23 | this.astronomy = this.constructor.getValue(obj.astronomy);
24 | }
25 |
26 | /**
27 | * Function containing information about the fields of this model
28 | * @return {array} Array of objects containing information about the fields
29 | */
30 | static mappingInfo() {
31 | return super.mappingInfo().concat([
32 | { name: 'location', realName: 'location', type: 'Location' },
33 | { name: 'astronomy', realName: 'astronomy', type: 'Astronomy' },
34 | ]);
35 | }
36 |
37 | /**
38 | * Function containing information about discriminator values
39 | * mapped with their corresponding model class names
40 | *
41 | * @return {object} Object containing Key-Value pairs mapping discriminator
42 | * values with their corresponding model classes
43 | */
44 | static discriminatorMap() {
45 | return {};
46 | }
47 | }
48 |
49 | module.exports = AstronomyJsonResponse;
50 |
--------------------------------------------------------------------------------
/lib/Models/BaseModel.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const _apiHelper = require('../APIHelper');
10 | const moment = require('moment');
11 |
12 | /**
13 | * Creates an instance of BaseModel
14 | */
15 | class BaseModel {
16 | /**
17 | * Returns value for the object called
18 | * @param obj {string} The value to be assigned
19 | * @param defaultValue {string} The default value for the field
20 | * @returns The correct value for the field
21 | */
22 | static getValue(obj, defaultValue) {
23 | if (obj === undefined || obj === null) {
24 | return null;
25 | }
26 | let returnValue;
27 | if (obj !== undefined) {
28 | returnValue = obj;
29 | } else {
30 | returnValue = (defaultValue !== null || defaultValue !== undefined) ?
31 | defaultValue : null;
32 | }
33 | return returnValue;
34 | }
35 |
36 | /**
37 | * Helper function to check if value exists in the array of objects
38 | * @param val {string} The value to be checked in array
39 | * @returns If value doesn't exist in the array, returns null. Otherwise, returns the value
40 | */
41 | mappingInfoContains(val) {
42 | const mapInfo = this.constructor.mappingInfo();
43 | const keys = Object.keys(mapInfo);
44 | let returnValue = null;
45 | for (let iter = 0; iter < keys.length; iter += 1) {
46 | if (val === mapInfo[iter].name) {
47 | returnValue = mapInfo[iter].realName;
48 | break;
49 | }
50 | }
51 | return returnValue;
52 | }
53 |
54 | /**
55 | * Helper function to get the value (type) of datetime fields
56 | * @param name {string} The (actual) name of the field
57 | * @returns If field is not a date/datetime field, returns undefined.
58 | * Otherwise, returns the value (type)
59 | */
60 | getDateTimeValueForField(name) {
61 | if (name === undefined || name === null) {
62 | return null;
63 | }
64 | let value;
65 | const fieldsInfo = this.constructor.mappingInfo();
66 | fieldsInfo.forEach((field) => {
67 | if (field.realName === name && field.isDateTime && value === undefined) {
68 | value = (field.dateTimeValue !== undefined) ? field.dateTimeValue : 'date';
69 | }
70 | });
71 | return value;
72 | }
73 |
74 | /**
75 | * Helper Function to get Serialized Model
76 | * @returns {object} Dictionary of all model properties alongwith
77 | * additional properties (if any)
78 | */
79 | toJSON() {
80 | const newDict = {};
81 | const props = Object.keys(this);
82 | for (let iter = 0; iter < props.length; iter += 1) {
83 | if (typeof this[props[iter]] !== 'function') {
84 | // the properties that already exist in the models
85 | const propsThatExist = this.mappingInfoContains(props[iter]);
86 | const value = propsThatExist !== null ? propsThatExist : props[iter];
87 | if (this[props[iter]] instanceof Object &&
88 | this[props[iter]].constructor !== Array &&
89 | !(this[props[iter]] instanceof moment) &&
90 | !(this[props[iter]] instanceof Date)) {
91 | if (typeof this[props[iter]].toJSON === 'function') {
92 | newDict[value] = this[props[iter]].toJSON();
93 | } else {
94 | newDict[value] = this[props[iter]];
95 | }
96 | } else if (this[props[iter]] !== undefined &&
97 | this[props[iter]] !== null &&
98 | this[props[iter]].constructor === Array) {
99 | newDict[value] = [];
100 | this[props[iter]].forEach((item, index) => {
101 | if (item !== undefined) {
102 | if (typeof item.toJSON === 'function') {
103 | newDict[value][index] = item.toJSON();
104 | } else {
105 | newDict[value][index] = item;
106 | }
107 | }
108 | });
109 | } else {
110 | const dateTimeType = this.getDateTimeValueForField(value);
111 | if (dateTimeType !== null && dateTimeType !== undefined) {
112 | // this means it's date/datetime field
113 | newDict[value] =
114 | _apiHelper.stringifyDateTime(this[props[iter]], dateTimeType);
115 | } else {
116 | newDict[value] = this[props[iter]];
117 | }
118 | }
119 | }
120 | }
121 | return newDict;
122 | }
123 |
124 | /**
125 | * Function containing information about the fields of this model
126 | * @returns {array} Empty array
127 | */
128 | static mappingInfo() {
129 | return [];
130 | }
131 | }
132 |
133 | module.exports = BaseModel;
134 |
--------------------------------------------------------------------------------
/lib/Models/Condition.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Condition
13 | */
14 | class Condition extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.text = this.constructor.getValue(obj.text);
23 | this.icon = this.constructor.getValue(obj.icon);
24 | this.code = this.constructor.getValue(obj.code);
25 | }
26 |
27 | /**
28 | * Function containing information about the fields of this model
29 | * @return {array} Array of objects containing information about the fields
30 | */
31 | static mappingInfo() {
32 | return super.mappingInfo().concat([
33 | { name: 'text', realName: 'text' },
34 | { name: 'icon', realName: 'icon' },
35 | { name: 'code', realName: 'code' },
36 | ]);
37 | }
38 |
39 | /**
40 | * Function containing information about discriminator values
41 | * mapped with their corresponding model class names
42 | *
43 | * @return {object} Object containing Key-Value pairs mapping discriminator
44 | * values with their corresponding model classes
45 | */
46 | static discriminatorMap() {
47 | return {};
48 | }
49 | }
50 |
51 | module.exports = Condition;
52 |
--------------------------------------------------------------------------------
/lib/Models/Current.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Current
13 | */
14 | class Current extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.lastUpdatedEpoch =
23 | this.constructor.getValue(obj.lastUpdatedEpoch
24 | || obj.last_updated_epoch);
25 | this.lastUpdated = this.constructor.getValue(obj.lastUpdated || obj.last_updated);
26 | this.tempC = this.constructor.getValue(obj.tempC || obj.temp_c);
27 | this.tempF = this.constructor.getValue(obj.tempF || obj.temp_f);
28 | this.isDay = this.constructor.getValue(obj.isDay || obj.is_day);
29 | this.condition = this.constructor.getValue(obj.condition);
30 | this.windMph = this.constructor.getValue(obj.windMph || obj.wind_mph);
31 | this.windKph = this.constructor.getValue(obj.windKph || obj.wind_kph);
32 | this.windDegree = this.constructor.getValue(obj.windDegree || obj.wind_degree);
33 | this.windDir = this.constructor.getValue(obj.windDir || obj.wind_dir);
34 | this.pressureMb = this.constructor.getValue(obj.pressureMb || obj.pressure_mb);
35 | this.pressureIn = this.constructor.getValue(obj.pressureIn || obj.pressure_in);
36 | this.precipMm = this.constructor.getValue(obj.precipMm || obj.precip_mm);
37 | this.precipIn = this.constructor.getValue(obj.precipIn || obj.precip_in);
38 | this.humidity = this.constructor.getValue(obj.humidity);
39 | this.cloud = this.constructor.getValue(obj.cloud);
40 | this.feelslikeC = this.constructor.getValue(obj.feelslikeC || obj.feelslike_c);
41 | this.feelslikeF = this.constructor.getValue(obj.feelslikeF || obj.feelslike_f);
42 | this.visKm = this.constructor.getValue(obj.visKm || obj.vis_km);
43 | this.visMiles = this.constructor.getValue(obj.visMiles || obj.vis_miles);
44 | this.uv = this.constructor.getValue(obj.uv);
45 | this.gustMph = this.constructor.getValue(obj.gustMph || obj.gust_mph);
46 | this.gustKph = this.constructor.getValue(obj.gustKph || obj.gust_kph);
47 | }
48 |
49 | /**
50 | * Function containing information about the fields of this model
51 | * @return {array} Array of objects containing information about the fields
52 | */
53 | static mappingInfo() {
54 | return super.mappingInfo().concat([
55 | { name: 'lastUpdatedEpoch', realName: 'last_updated_epoch' },
56 | { name: 'lastUpdated', realName: 'last_updated' },
57 | { name: 'tempC', realName: 'temp_c' },
58 | { name: 'tempF', realName: 'temp_f' },
59 | { name: 'isDay', realName: 'is_day' },
60 | { name: 'condition', realName: 'condition', type: 'Condition' },
61 | { name: 'windMph', realName: 'wind_mph' },
62 | { name: 'windKph', realName: 'wind_kph' },
63 | { name: 'windDegree', realName: 'wind_degree' },
64 | { name: 'windDir', realName: 'wind_dir' },
65 | { name: 'pressureMb', realName: 'pressure_mb' },
66 | { name: 'pressureIn', realName: 'pressure_in' },
67 | { name: 'precipMm', realName: 'precip_mm' },
68 | { name: 'precipIn', realName: 'precip_in' },
69 | { name: 'humidity', realName: 'humidity' },
70 | { name: 'cloud', realName: 'cloud' },
71 | { name: 'feelslikeC', realName: 'feelslike_c' },
72 | { name: 'feelslikeF', realName: 'feelslike_f' },
73 | { name: 'visKm', realName: 'vis_km' },
74 | { name: 'visMiles', realName: 'vis_miles' },
75 | { name: 'uv', realName: 'uv' },
76 | { name: 'gustMph', realName: 'gust_mph' },
77 | { name: 'gustKph', realName: 'gust_kph' },
78 | ]);
79 | }
80 |
81 | /**
82 | * Function containing information about discriminator values
83 | * mapped with their corresponding model class names
84 | *
85 | * @return {object} Object containing Key-Value pairs mapping discriminator
86 | * values with their corresponding model classes
87 | */
88 | static discriminatorMap() {
89 | return {};
90 | }
91 | }
92 |
93 | module.exports = Current;
94 |
--------------------------------------------------------------------------------
/lib/Models/CurrentJsonResponse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of CurrentJsonResponse
13 | */
14 | class CurrentJsonResponse extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.location = this.constructor.getValue(obj.location);
23 | this.current = this.constructor.getValue(obj.current);
24 | }
25 |
26 | /**
27 | * Function containing information about the fields of this model
28 | * @return {array} Array of objects containing information about the fields
29 | */
30 | static mappingInfo() {
31 | return super.mappingInfo().concat([
32 | { name: 'location', realName: 'location', type: 'Location' },
33 | { name: 'current', realName: 'current', type: 'Current' },
34 | ]);
35 | }
36 |
37 | /**
38 | * Function containing information about discriminator values
39 | * mapped with their corresponding model class names
40 | *
41 | * @return {object} Object containing Key-Value pairs mapping discriminator
42 | * values with their corresponding model classes
43 | */
44 | static discriminatorMap() {
45 | return {};
46 | }
47 | }
48 |
49 | module.exports = CurrentJsonResponse;
50 |
--------------------------------------------------------------------------------
/lib/Models/Day.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Day
13 | */
14 | class Day extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.maxtempC = this.constructor.getValue(obj.maxtempC || obj.maxtemp_c);
23 | this.maxtempF = this.constructor.getValue(obj.maxtempF || obj.maxtemp_f);
24 | this.mintempC = this.constructor.getValue(obj.mintempC || obj.mintemp_c);
25 | this.mintempF = this.constructor.getValue(obj.mintempF || obj.mintemp_f);
26 | this.avgtempC = this.constructor.getValue(obj.avgtempC || obj.avgtemp_c);
27 | this.avgtempF = this.constructor.getValue(obj.avgtempF || obj.avgtemp_f);
28 | this.maxwindMph = this.constructor.getValue(obj.maxwindMph || obj.maxwind_mph);
29 | this.maxwindKph = this.constructor.getValue(obj.maxwindKph || obj.maxwind_kph);
30 | this.totalprecipMm = this.constructor.getValue(obj.totalprecipMm || obj.totalprecip_mm);
31 | this.totalprecipIn = this.constructor.getValue(obj.totalprecipIn || obj.totalprecip_in);
32 | this.avgvisKm = this.constructor.getValue(obj.avgvisKm || obj.avgvis_km);
33 | this.avgvisMiles = this.constructor.getValue(obj.avgvisMiles || obj.avgvis_miles);
34 | this.avghumidity = this.constructor.getValue(obj.avghumidity);
35 | this.condition = this.constructor.getValue(obj.condition);
36 | this.uv = this.constructor.getValue(obj.uv);
37 | }
38 |
39 | /**
40 | * Function containing information about the fields of this model
41 | * @return {array} Array of objects containing information about the fields
42 | */
43 | static mappingInfo() {
44 | return super.mappingInfo().concat([
45 | { name: 'maxtempC', realName: 'maxtemp_c' },
46 | { name: 'maxtempF', realName: 'maxtemp_f' },
47 | { name: 'mintempC', realName: 'mintemp_c' },
48 | { name: 'mintempF', realName: 'mintemp_f' },
49 | { name: 'avgtempC', realName: 'avgtemp_c' },
50 | { name: 'avgtempF', realName: 'avgtemp_f' },
51 | { name: 'maxwindMph', realName: 'maxwind_mph' },
52 | { name: 'maxwindKph', realName: 'maxwind_kph' },
53 | { name: 'totalprecipMm', realName: 'totalprecip_mm' },
54 | { name: 'totalprecipIn', realName: 'totalprecip_in' },
55 | { name: 'avgvisKm', realName: 'avgvis_km' },
56 | { name: 'avgvisMiles', realName: 'avgvis_miles' },
57 | { name: 'avghumidity', realName: 'avghumidity' },
58 | { name: 'condition', realName: 'condition', type: 'Condition' },
59 | { name: 'uv', realName: 'uv' },
60 | ]);
61 | }
62 |
63 | /**
64 | * Function containing information about discriminator values
65 | * mapped with their corresponding model class names
66 | *
67 | * @return {object} Object containing Key-Value pairs mapping discriminator
68 | * values with their corresponding model classes
69 | */
70 | static discriminatorMap() {
71 | return {};
72 | }
73 | }
74 |
75 | module.exports = Day;
76 |
--------------------------------------------------------------------------------
/lib/Models/Forecast.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Forecast
13 | */
14 | class Forecast extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.forecastday = this.constructor.getValue(obj.forecastday);
23 | }
24 |
25 | /**
26 | * Function containing information about the fields of this model
27 | * @return {array} Array of objects containing information about the fields
28 | */
29 | static mappingInfo() {
30 | return super.mappingInfo().concat([
31 | { name: 'forecastday', realName: 'forecastday', array: true, type: 'Forecastday' },
32 | ]);
33 | }
34 |
35 | /**
36 | * Function containing information about discriminator values
37 | * mapped with their corresponding model class names
38 | *
39 | * @return {object} Object containing Key-Value pairs mapping discriminator
40 | * values with their corresponding model classes
41 | */
42 | static discriminatorMap() {
43 | return {};
44 | }
45 | }
46 |
47 | module.exports = Forecast;
48 |
--------------------------------------------------------------------------------
/lib/Models/Forecast1.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Forecast1
13 | */
14 | class Forecast1 extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.forecastday = this.constructor.getValue(obj.forecastday);
23 | }
24 |
25 | /**
26 | * Function containing information about the fields of this model
27 | * @return {array} Array of objects containing information about the fields
28 | */
29 | static mappingInfo() {
30 | return super.mappingInfo().concat([
31 | { name: 'forecastday', realName: 'forecastday', array: true, type: 'Forecastday1' },
32 | ]);
33 | }
34 |
35 | /**
36 | * Function containing information about discriminator values
37 | * mapped with their corresponding model class names
38 | *
39 | * @return {object} Object containing Key-Value pairs mapping discriminator
40 | * values with their corresponding model classes
41 | */
42 | static discriminatorMap() {
43 | return {};
44 | }
45 | }
46 |
47 | module.exports = Forecast1;
48 |
--------------------------------------------------------------------------------
/lib/Models/ForecastJsonResponse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of ForecastJsonResponse
13 | */
14 | class ForecastJsonResponse extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.location = this.constructor.getValue(obj.location);
23 | this.current = this.constructor.getValue(obj.current);
24 | this.forecast = this.constructor.getValue(obj.forecast);
25 | }
26 |
27 | /**
28 | * Function containing information about the fields of this model
29 | * @return {array} Array of objects containing information about the fields
30 | */
31 | static mappingInfo() {
32 | return super.mappingInfo().concat([
33 | { name: 'location', realName: 'location', type: 'Location' },
34 | { name: 'current', realName: 'current', type: 'Current' },
35 | { name: 'forecast', realName: 'forecast', type: 'Forecast' },
36 | ]);
37 | }
38 |
39 | /**
40 | * Function containing information about discriminator values
41 | * mapped with their corresponding model class names
42 | *
43 | * @return {object} Object containing Key-Value pairs mapping discriminator
44 | * values with their corresponding model classes
45 | */
46 | static discriminatorMap() {
47 | return {};
48 | }
49 | }
50 |
51 | module.exports = ForecastJsonResponse;
52 |
--------------------------------------------------------------------------------
/lib/Models/Forecastday.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Forecastday
13 | */
14 | class Forecastday extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.date = this.constructor.getValue(obj.date);
23 | this.dateEpoch = this.constructor.getValue(obj.dateEpoch || obj.date_epoch);
24 | this.day = this.constructor.getValue(obj.day);
25 | this.astro = this.constructor.getValue(obj.astro);
26 | }
27 |
28 | /**
29 | * Function containing information about the fields of this model
30 | * @return {array} Array of objects containing information about the fields
31 | */
32 | static mappingInfo() {
33 | return super.mappingInfo().concat([
34 | { name: 'date', realName: 'date' },
35 | { name: 'dateEpoch', realName: 'date_epoch' },
36 | { name: 'day', realName: 'day', type: 'Day' },
37 | { name: 'astro', realName: 'astro', type: 'Astro' },
38 | ]);
39 | }
40 |
41 | /**
42 | * Function containing information about discriminator values
43 | * mapped with their corresponding model class names
44 | *
45 | * @return {object} Object containing Key-Value pairs mapping discriminator
46 | * values with their corresponding model classes
47 | */
48 | static discriminatorMap() {
49 | return {};
50 | }
51 | }
52 |
53 | module.exports = Forecastday;
54 |
--------------------------------------------------------------------------------
/lib/Models/Forecastday1.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Forecastday1
13 | */
14 | class Forecastday1 extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.date = this.constructor.getValue(obj.date);
23 | this.dateEpoch = this.constructor.getValue(obj.dateEpoch || obj.date_epoch);
24 | this.day = this.constructor.getValue(obj.day);
25 | this.astro = this.constructor.getValue(obj.astro);
26 | this.hour = this.constructor.getValue(obj.hour);
27 | }
28 |
29 | /**
30 | * Function containing information about the fields of this model
31 | * @return {array} Array of objects containing information about the fields
32 | */
33 | static mappingInfo() {
34 | return super.mappingInfo().concat([
35 | { name: 'date', realName: 'date' },
36 | { name: 'dateEpoch', realName: 'date_epoch' },
37 | { name: 'day', realName: 'day', type: 'Day' },
38 | { name: 'astro', realName: 'astro', type: 'Astro' },
39 | { name: 'hour', realName: 'hour', array: true, type: 'Hour' },
40 | ]);
41 | }
42 |
43 | /**
44 | * Function containing information about discriminator values
45 | * mapped with their corresponding model class names
46 | *
47 | * @return {object} Object containing Key-Value pairs mapping discriminator
48 | * values with their corresponding model classes
49 | */
50 | static discriminatorMap() {
51 | return {};
52 | }
53 | }
54 |
55 | module.exports = Forecastday1;
56 |
--------------------------------------------------------------------------------
/lib/Models/HistoryJsonResponse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of HistoryJsonResponse
13 | */
14 | class HistoryJsonResponse extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.location = this.constructor.getValue(obj.location);
23 | this.current = this.constructor.getValue(obj.current);
24 | this.forecast = this.constructor.getValue(obj.forecast);
25 | }
26 |
27 | /**
28 | * Function containing information about the fields of this model
29 | * @return {array} Array of objects containing information about the fields
30 | */
31 | static mappingInfo() {
32 | return super.mappingInfo().concat([
33 | { name: 'location', realName: 'location', type: 'Location' },
34 | { name: 'current', realName: 'current', type: 'Current' },
35 | { name: 'forecast', realName: 'forecast', type: 'Forecast1' },
36 | ]);
37 | }
38 |
39 | /**
40 | * Function containing information about discriminator values
41 | * mapped with their corresponding model class names
42 | *
43 | * @return {object} Object containing Key-Value pairs mapping discriminator
44 | * values with their corresponding model classes
45 | */
46 | static discriminatorMap() {
47 | return {};
48 | }
49 | }
50 |
51 | module.exports = HistoryJsonResponse;
52 |
--------------------------------------------------------------------------------
/lib/Models/Hour.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Hour
13 | */
14 | class Hour extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.timeEpoch = this.constructor.getValue(obj.timeEpoch || obj.time_epoch);
23 | this.time = this.constructor.getValue(obj.time);
24 | this.tempC = this.constructor.getValue(obj.tempC || obj.temp_c);
25 | this.tempF = this.constructor.getValue(obj.tempF || obj.temp_f);
26 | this.isDay = this.constructor.getValue(obj.isDay || obj.is_day);
27 | this.condition = this.constructor.getValue(obj.condition);
28 | this.windMph = this.constructor.getValue(obj.windMph || obj.wind_mph);
29 | this.windKph = this.constructor.getValue(obj.windKph || obj.wind_kph);
30 | this.windDegree = this.constructor.getValue(obj.windDegree || obj.wind_degree);
31 | this.windDir = this.constructor.getValue(obj.windDir || obj.wind_dir);
32 | this.pressureMb = this.constructor.getValue(obj.pressureMb || obj.pressure_mb);
33 | this.pressureIn = this.constructor.getValue(obj.pressureIn || obj.pressure_in);
34 | this.precipMm = this.constructor.getValue(obj.precipMm || obj.precip_mm);
35 | this.precipIn = this.constructor.getValue(obj.precipIn || obj.precip_in);
36 | this.humidity = this.constructor.getValue(obj.humidity);
37 | this.cloud = this.constructor.getValue(obj.cloud);
38 | this.feelslikeC = this.constructor.getValue(obj.feelslikeC || obj.feelslike_c);
39 | this.feelslikeF = this.constructor.getValue(obj.feelslikeF || obj.feelslike_f);
40 | this.visKm = this.constructor.getValue(obj.visKm || obj.vis_km);
41 | this.visMiles = this.constructor.getValue(obj.visMiles || obj.vis_miles);
42 | this.uv = this.constructor.getValue(obj.uv);
43 | this.gustMph = this.constructor.getValue(obj.gustMph || obj.gust_mph);
44 | this.gustKph = this.constructor.getValue(obj.gustKph || obj.gust_kph);
45 | }
46 |
47 | /**
48 | * Function containing information about the fields of this model
49 | * @return {array} Array of objects containing information about the fields
50 | */
51 | static mappingInfo() {
52 | return super.mappingInfo().concat([
53 | { name: 'timeEpoch', realName: 'time_epoch' },
54 | { name: 'time', realName: 'time' },
55 | { name: 'tempC', realName: 'temp_c' },
56 | { name: 'tempF', realName: 'temp_f' },
57 | { name: 'isDay', realName: 'is_day' },
58 | { name: 'condition', realName: 'condition', type: 'Condition' },
59 | { name: 'windMph', realName: 'wind_mph' },
60 | { name: 'windKph', realName: 'wind_kph' },
61 | { name: 'windDegree', realName: 'wind_degree' },
62 | { name: 'windDir', realName: 'wind_dir' },
63 | { name: 'pressureMb', realName: 'pressure_mb' },
64 | { name: 'pressureIn', realName: 'pressure_in' },
65 | { name: 'precipMm', realName: 'precip_mm' },
66 | { name: 'precipIn', realName: 'precip_in' },
67 | { name: 'humidity', realName: 'humidity' },
68 | { name: 'cloud', realName: 'cloud' },
69 | { name: 'feelslikeC', realName: 'feelslike_c' },
70 | { name: 'feelslikeF', realName: 'feelslike_f' },
71 | { name: 'visKm', realName: 'vis_km' },
72 | { name: 'visMiles', realName: 'vis_miles' },
73 | { name: 'uv', realName: 'uv' },
74 | { name: 'gustMph', realName: 'gust_mph' },
75 | { name: 'gustKph', realName: 'gust_kph' },
76 | ]);
77 | }
78 |
79 | /**
80 | * Function containing information about discriminator values
81 | * mapped with their corresponding model class names
82 | *
83 | * @return {object} Object containing Key-Value pairs mapping discriminator
84 | * values with their corresponding model classes
85 | */
86 | static discriminatorMap() {
87 | return {};
88 | }
89 | }
90 |
91 | module.exports = Hour;
92 |
--------------------------------------------------------------------------------
/lib/Models/IpJsonResponse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of IpJsonResponse
13 | */
14 | class IpJsonResponse extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.ip = this.constructor.getValue(obj.ip);
23 | this.type = this.constructor.getValue(obj.type);
24 | this.continentCode = this.constructor.getValue(obj.continentCode || obj.continent_code);
25 | this.continentName = this.constructor.getValue(obj.continentName || obj.continent_name);
26 | this.countryCode = this.constructor.getValue(obj.countryCode || obj.country_code);
27 | this.countryName = this.constructor.getValue(obj.countryName || obj.country_name);
28 | this.isEu = this.constructor.getValue(obj.isEu || obj.is_eu);
29 | this.geonameId = this.constructor.getValue(obj.geonameId || obj.geoname_id);
30 | this.city = this.constructor.getValue(obj.city);
31 | this.region = this.constructor.getValue(obj.region);
32 | this.lat = this.constructor.getValue(obj.lat);
33 | this.lon = this.constructor.getValue(obj.lon);
34 | this.tzId = this.constructor.getValue(obj.tzId || obj.tz_id);
35 | this.localtimeEpoch = this.constructor.getValue(obj.localtimeEpoch || obj.localtime_epoch);
36 | this.localtime = this.constructor.getValue(obj.localtime);
37 | }
38 |
39 | /**
40 | * Function containing information about the fields of this model
41 | * @return {array} Array of objects containing information about the fields
42 | */
43 | static mappingInfo() {
44 | return super.mappingInfo().concat([
45 | { name: 'ip', realName: 'ip' },
46 | { name: 'type', realName: 'type' },
47 | { name: 'continentCode', realName: 'continent_code' },
48 | { name: 'continentName', realName: 'continent_name' },
49 | { name: 'countryCode', realName: 'country_code' },
50 | { name: 'countryName', realName: 'country_name' },
51 | { name: 'isEu', realName: 'is_eu' },
52 | { name: 'geonameId', realName: 'geoname_id' },
53 | { name: 'city', realName: 'city' },
54 | { name: 'region', realName: 'region' },
55 | { name: 'lat', realName: 'lat' },
56 | { name: 'lon', realName: 'lon' },
57 | { name: 'tzId', realName: 'tz_id' },
58 | { name: 'localtimeEpoch', realName: 'localtime_epoch' },
59 | { name: 'localtime', realName: 'localtime' },
60 | ]);
61 | }
62 |
63 | /**
64 | * Function containing information about discriminator values
65 | * mapped with their corresponding model class names
66 | *
67 | * @return {object} Object containing Key-Value pairs mapping discriminator
68 | * values with their corresponding model classes
69 | */
70 | static discriminatorMap() {
71 | return {};
72 | }
73 | }
74 |
75 | module.exports = IpJsonResponse;
76 |
--------------------------------------------------------------------------------
/lib/Models/Location.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of Location
13 | */
14 | class Location extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.name = this.constructor.getValue(obj.name);
23 | this.region = this.constructor.getValue(obj.region);
24 | this.country = this.constructor.getValue(obj.country);
25 | this.lat = this.constructor.getValue(obj.lat);
26 | this.lon = this.constructor.getValue(obj.lon);
27 | this.tzId = this.constructor.getValue(obj.tzId || obj.tz_id);
28 | this.localtimeEpoch = this.constructor.getValue(obj.localtimeEpoch || obj.localtime_epoch);
29 | this.localtime = this.constructor.getValue(obj.localtime);
30 | }
31 |
32 | /**
33 | * Function containing information about the fields of this model
34 | * @return {array} Array of objects containing information about the fields
35 | */
36 | static mappingInfo() {
37 | return super.mappingInfo().concat([
38 | { name: 'name', realName: 'name' },
39 | { name: 'region', realName: 'region' },
40 | { name: 'country', realName: 'country' },
41 | { name: 'lat', realName: 'lat' },
42 | { name: 'lon', realName: 'lon' },
43 | { name: 'tzId', realName: 'tz_id' },
44 | { name: 'localtimeEpoch', realName: 'localtime_epoch' },
45 | { name: 'localtime', realName: 'localtime' },
46 | ]);
47 | }
48 |
49 | /**
50 | * Function containing information about discriminator values
51 | * mapped with their corresponding model class names
52 | *
53 | * @return {object} Object containing Key-Value pairs mapping discriminator
54 | * values with their corresponding model classes
55 | */
56 | static discriminatorMap() {
57 | return {};
58 | }
59 | }
60 |
61 | module.exports = Location;
62 |
--------------------------------------------------------------------------------
/lib/Models/SearchJsonResponse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of SearchJsonResponse
13 | */
14 | class SearchJsonResponse extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.id = this.constructor.getValue(obj.id);
23 | this.name = this.constructor.getValue(obj.name);
24 | this.region = this.constructor.getValue(obj.region);
25 | this.country = this.constructor.getValue(obj.country);
26 | this.lat = this.constructor.getValue(obj.lat);
27 | this.lon = this.constructor.getValue(obj.lon);
28 | this.url = this.constructor.getValue(obj.url);
29 | }
30 |
31 | /**
32 | * Function containing information about the fields of this model
33 | * @return {array} Array of objects containing information about the fields
34 | */
35 | static mappingInfo() {
36 | return super.mappingInfo().concat([
37 | { name: 'id', realName: 'id' },
38 | { name: 'name', realName: 'name' },
39 | { name: 'region', realName: 'region' },
40 | { name: 'country', realName: 'country' },
41 | { name: 'lat', realName: 'lat' },
42 | { name: 'lon', realName: 'lon' },
43 | { name: 'url', realName: 'url' },
44 | ]);
45 | }
46 |
47 | /**
48 | * Function containing information about discriminator values
49 | * mapped with their corresponding model class names
50 | *
51 | * @return {object} Object containing Key-Value pairs mapping discriminator
52 | * values with their corresponding model classes
53 | */
54 | static discriminatorMap() {
55 | return {};
56 | }
57 | }
58 |
59 | module.exports = SearchJsonResponse;
60 |
--------------------------------------------------------------------------------
/lib/Models/TimezoneJsonResponse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const BaseModel = require('./BaseModel');
10 |
11 | /**
12 | * Creates an instance of TimezoneJsonResponse
13 | */
14 | class TimezoneJsonResponse extends BaseModel {
15 | /**
16 | * @constructor
17 | * @param {Object} obj The object passed to constructor
18 | */
19 | constructor(obj) {
20 | super(obj);
21 | if (obj === undefined || obj === null) return;
22 | this.name = this.constructor.getValue(obj.name);
23 | this.region = this.constructor.getValue(obj.region);
24 | this.country = this.constructor.getValue(obj.country);
25 | this.lat = this.constructor.getValue(obj.lat);
26 | this.lon = this.constructor.getValue(obj.lon);
27 | this.tzId = this.constructor.getValue(obj.tzId || obj.tz_id);
28 | this.localtimeEpoch = this.constructor.getValue(obj.localtimeEpoch || obj.localtime_epoch);
29 | this.localtime = this.constructor.getValue(obj.localtime);
30 | }
31 |
32 | /**
33 | * Function containing information about the fields of this model
34 | * @return {array} Array of objects containing information about the fields
35 | */
36 | static mappingInfo() {
37 | return super.mappingInfo().concat([
38 | { name: 'name', realName: 'name' },
39 | { name: 'region', realName: 'region' },
40 | { name: 'country', realName: 'country' },
41 | { name: 'lat', realName: 'lat' },
42 | { name: 'lon', realName: 'lon' },
43 | { name: 'tzId', realName: 'tz_id' },
44 | { name: 'localtimeEpoch', realName: 'localtime_epoch' },
45 | { name: 'localtime', realName: 'localtime' },
46 | ]);
47 | }
48 |
49 | /**
50 | * Function containing information about discriminator values
51 | * mapped with their corresponding model class names
52 | *
53 | * @return {object} Object containing Key-Value pairs mapping discriminator
54 | * values with their corresponding model classes
55 | */
56 | static discriminatorMap() {
57 | return {};
58 | }
59 | }
60 |
61 | module.exports = TimezoneJsonResponse;
62 |
--------------------------------------------------------------------------------
/lib/ObjectMapper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 | const moment = require('moment');
10 | const modelFactory = require('./ModelFactory');
11 |
12 | /**
13 | * ObjectMapper is utility class that helps maps a POJO to a model or exception object.
14 | * Embedded models and dates are also instantiated to their correct types.
15 | */
16 | class ObjectMapper {
17 | /**
18 | * Returns Datetime parsed value for field
19 | * @param value {string} The value to be parsed
20 | * @param type {string} The Datetime format to be parsed into
21 | * @returns {object} Parsed Datetime object
22 | */
23 | static parseDateTime(value, type) {
24 | if (value === null || value === undefined) {
25 | return null;
26 | }
27 | switch (type) {
28 | case 'unixtimestamp':
29 | return new Date(value);
30 | case 'rfc1123':
31 | return new Date(value);
32 | case 'rfc3339':
33 | return moment(value).parseZone(value);
34 | case 'date':
35 | return moment(value, 'YYYY-MM-DD');
36 | default:
37 | return moment(value, 'YYYY-MM-DD');
38 | }
39 | }
40 |
41 | /**
42 | * Helper function to get the name of discriminator field
43 | *
44 | * @param fieldMap {array} The mapping information of the model's fields
45 | *
46 | * @returns {string} The name of the discriminator field.
47 | * Returns null if discriminator field is not present
48 | */
49 | static getDiscriminatorFieldName(fieldMap) {
50 | if (fieldMap === null || fieldMap === undefined) {
51 | return null;
52 | }
53 | let name = null;
54 | fieldMap.forEach((field) => {
55 | if (field.isDiscrim) {
56 | name = field.realName;
57 | }
58 | });
59 | return name;
60 | }
61 |
62 | /**
63 | * Helper function to get the value of discriminator
64 | * This helper function checks values inside nested objects and arrays of objects as well.
65 | *
66 | * @param json {object} Input object (API response)
67 | * @param discrimName {string} The name of the discriminator field
68 | *
69 | * @returns {string} The value of the discriminator field present in the input object
70 | * Returns null if no value is present in the input
71 | */
72 | static getDiscriminatorFieldValue(json, discrimName) {
73 | if (json === null ||
74 | json === undefined ||
75 | discrimName === null ||
76 | discrimName === undefined) {
77 | return null;
78 | }
79 | let value = null;
80 | if (json instanceof Object && json.constructor !== Array) {
81 | if (Object.prototype.hasOwnProperty.call(json, discrimName)) {
82 | value = json[discrimName];
83 | }
84 | }
85 | return value;
86 | }
87 |
88 | /**
89 | * Helper function to get the model name corresponding to the discriminator value
90 | *
91 | * @param fieldMap {object} The discriminator map stored in the model class
92 | * @param discrimValue {string} The value of the discriminator which maps
93 | * to a model class
94 | *
95 | * @returns {string} The name of the model class corresponding to the discriminator
96 | * value passed in.
97 | */
98 | static getDiscriminatorClass(fieldMap, discrimValue) {
99 | if (discrimValue === undefined ||
100 | discrimValue === null ||
101 | fieldMap === null ||
102 | fieldMap === undefined) {
103 | return null;
104 | }
105 | let className = null;
106 | if (Object.prototype.hasOwnProperty.call(fieldMap, discrimValue)) {
107 | className = fieldMap[discrimValue];
108 | }
109 | return className;
110 | }
111 |
112 | /**
113 | * Helper function to map input object with model fields
114 | * @param json {object} Input object to be mapped onto model fields
115 | * @param modelName {string} The name of model to instantiate
116 | * @returns {object} Object containing mapped fields of model
117 | */
118 | mapObject(json, modelName) {
119 | if (json === null || json === undefined) {
120 | return null;
121 | }
122 | let instance = modelName;
123 | const modelInstance = modelFactory.getInstance(modelName);
124 | const discrimName =
125 | ObjectMapper.getDiscriminatorFieldName(modelInstance.constructor.mappingInfo());
126 | const discrimValue =
127 | ObjectMapper.getDiscriminatorFieldValue(json, discrimName);
128 | if (discrimName !== null &&
129 | discrimName !== undefined &&
130 | discrimValue !== null &&
131 | discrimValue !== undefined) {
132 | instance =
133 | ObjectMapper.getDiscriminatorClass(modelInstance.constructor.discriminatorMap(),
134 | discrimValue);
135 | }
136 | return this.mapFields(json, modelFactory.getInstance(instance));
137 | }
138 |
139 | /**
140 | * Maps the instance's fields with the values in input object
141 | * The function helps in deserializing a model instance
142 | * @param json {object} Input object to be mapped onto model fields
143 | * @param instance {object} The instance of the model class
144 | * @returns {object} Mapped instance of model class
145 | */
146 | mapFields(json, instance) {
147 | const returnInstance = instance;
148 | const fieldsInfo = instance.constructor.mappingInfo();
149 | fieldsInfo.forEach((fieldInfo) => {
150 | if (fieldInfo.type) {
151 | if (fieldInfo.array) {
152 | if (json[fieldInfo.realName] !== null &&
153 | json[fieldInfo.realName] !== undefined) {
154 | returnInstance[fieldInfo.name] = json[fieldInfo.realName].map(obj =>
155 | this.mapObject(obj, fieldInfo.type));
156 | }
157 | } else {
158 | returnInstance[fieldInfo.name] =
159 | this.mapObject(json[fieldInfo.realName], fieldInfo.type);
160 | }
161 | } else if (fieldInfo.isDateTime) {
162 | returnInstance[fieldInfo.name] =
163 | json[fieldInfo.realName] === null || json[fieldInfo.realName] === undefined ?
164 | json[fieldInfo.realName] :
165 | ObjectMapper.parseDateTime(json[fieldInfo.realName],
166 | fieldInfo.dateTimeValue);
167 | } else {
168 | returnInstance[fieldInfo.name] =
169 | json[fieldInfo.realName] === null || json[fieldInfo.realName] === undefined ?
170 | (instance[fieldInfo.name] || null) :
171 | json[fieldInfo.realName];
172 | }
173 | });
174 | return returnInstance;
175 | }
176 | }
177 |
178 | module.exports = ObjectMapper;
179 |
--------------------------------------------------------------------------------
/lib/configuration.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WeatherAPILib
3 | *
4 | * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
5 | */
6 |
7 | 'use strict';
8 |
9 |
10 | const Configuration = {
11 | // The base Uri for API calls
12 | BASEURI: 'https://api.weatherapi.com/v1',
13 |
14 | key: '',
15 |
16 | };
17 |
18 | module.exports = Configuration;
19 |
--------------------------------------------------------------------------------
/lib/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @module WeatherAPILib
3 | *
4 | * # Introduction WeatherAPI.com provides access to weather and geo data via a JSON/XML restful
5 | * API. It allows developers to create desktop, web and mobile applications using this data very
6 | * easy. We provide following data through our API: * Real-time weather * 10 day weather
7 | * forecast * Astronomy * Time zone * Location data * Search or Autocomplete API *
8 | * NEW: Historical weather # Getting Started You need to [signup](https://www.weatherapi.
9 | * com/signup.aspx) and then you can find your API key under [your account](https://www.weatherapi.
10 | * com/login.aspx), and start using API right away! If you find any features missing or have any
11 | * suggestions, please [contact us](https://www.weatherapi.com/contact.aspx). # Authentication
12 | * API access to the data is protected by an API key. If at anytime, you find the API key has
13 | * become vulnerable, please regenerate the key using Regenerate button next to the API key.
14 | * Authentication to the WeatherAPI.com API is provided by passing your API key as request
15 | * parameter through an API . ## key parameter key=YOUR_API_KEY
16 | */
17 |
18 | 'use strict';
19 |
20 | const Configuration = require('./configuration');
21 | const APIsController = require('./Controllers/APIsController');
22 | const CurrentJsonResponse = require('./Models/CurrentJsonResponse');
23 | const Location = require('./Models/Location');
24 | const Current = require('./Models/Current');
25 | const Condition = require('./Models/Condition');
26 | const ForecastJsonResponse = require('./Models/ForecastJsonResponse');
27 | const Forecast = require('./Models/Forecast');
28 | const Forecastday = require('./Models/Forecastday');
29 | const Day = require('./Models/Day');
30 | const Astro = require('./Models/Astro');
31 | const HistoryJsonResponse = require('./Models/HistoryJsonResponse');
32 | const Forecast1 = require('./Models/Forecast1');
33 | const Forecastday1 = require('./Models/Forecastday1');
34 | const Hour = require('./Models/Hour');
35 | const SearchJsonResponse = require('./Models/SearchJsonResponse');
36 | const IpJsonResponse = require('./Models/IpJsonResponse');
37 | const TimezoneJsonResponse = require('./Models/TimezoneJsonResponse');
38 | const AstronomyJsonResponse = require('./Models/AstronomyJsonResponse');
39 | const Astronomy = require('./Models/Astronomy');
40 | const APIException = require('./Exceptions/APIException');
41 |
42 |
43 | const initializer = {
44 | // functional components of WeatherAPILib
45 | Configuration,
46 | // controllers of WeatherAPILib
47 | APIsController,
48 | // models of WeatherAPILib
49 | CurrentJsonResponse,
50 | Location,
51 | Current,
52 | Condition,
53 | ForecastJsonResponse,
54 | Forecast,
55 | Forecastday,
56 | Day,
57 | Astro,
58 | HistoryJsonResponse,
59 | Forecast1,
60 | Forecastday1,
61 | Hour,
62 | SearchJsonResponse,
63 | IpJsonResponse,
64 | TimezoneJsonResponse,
65 | AstronomyJsonResponse,
66 | Astronomy,
67 | // exceptions of WeatherAPILib
68 | APIException,
69 | };
70 |
71 | module.exports = initializer;
72 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "weatherapilib",
3 | "version": "1.0.0",
4 | "description": "# Introduction WeatherAPI.com provides access to weather and geo data via a JSON/XML restful API. It allows developers to create desktop, web and mobile applications using this data very easy. We provide following data through our API: * Real-time weather * 10 day weather forecast * Astronomy * Time zone * Location data * Search or Autocomplete API * NEW: Historical weather # Getting Started You need to [signup](https://www.weatherapi.com/signup.aspx) and then you can find your API key under [your account](https://www.weatherapi.com/login.aspx), and start using API right away! If you find any features missing or have any suggestions, please [contact us](https://www.weatherapi.com/contact.aspx). # Authentication API access to the data is protected by an API key. If at anytime, you find the API key has become vulnerable, please regenerate the key using Regenerate button next to the API key. Authentication to the WeatherAPI.com API is provided by passing your API key as request parameter through an API . ## key parameter key=YOUR_API_KEY",
5 | "main": "./lib/index.js",
6 | "repository": {
7 | "type": "git",
8 | "url": "git://github.com/username/repository.git"
9 | },
10 | "scripts": {
11 | "lint": "eslint lib"
12 | },
13 | "author": "APIMATIC SDK Generator",
14 | "bugs": {
15 | "email": "support@apimatic.io"
16 | },
17 | "license": "MIT",
18 | "devDependencies": {
19 | "eslint": "^3.18.0",
20 | "eslint-config-airbnb": "^14.1.0",
21 | "eslint-plugin-import": "^2.2.0",
22 | "eslint-plugin-jsx-a11y": "^4.0.0",
23 | "eslint-plugin-react": "^6.10.3"
24 | },
25 | "dependencies": {
26 | "moment": "^2.17.1",
27 | "request": "^2.55.0"
28 | },
29 | "eslintConfig": {
30 | "extends": "airbnb",
31 | "env": {
32 | "commonjs": true,
33 | "node": true,
34 | "mocha": true
35 | },
36 | "rules": {
37 | "indent": [
38 | "error",
39 | 4
40 | ],
41 | "no-underscore-dangle": 0,
42 | "strict": 0,
43 | "prefer-rest-params": 0
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------