Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "meteosapi", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "nodejs wrapper over the Aemet public API", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -43,2 +43,58 @@ # METEOSAPI | ||
### getSimpleForecast(provinceId) | ||
Ask for the simplified weather forecast in a given province for the next 3 days. The province code can be obtained from [here](http://www.ine.es/jaxi/menu.do?type=pcaxis&path=/t20/e245/codmun&file=inebase) | ||
or from [here](https://iagolast.github.io/pselect/) | ||
#### Example Response | ||
`getSimpleForecast` returns a data object with the following fields: | ||
- `name`: Name of the municipe of the predicion | ||
- `province`: Names of the required province. | ||
- `today`: Simplified forecast for the current day | ||
- `tomorrow`: Simplified forecast for the next today | ||
- `next2`: Simplified forecast for the day after tomorrow | ||
A `simplified forecast` has the following fields: | ||
- `value`: The wheater forecast value. | ||
- `description`: User readable weather forecast description. | ||
- `tmp`: The temperature values for the day | ||
- `min`: The expected min temperature | ||
- `max`: The expected max temperature | ||
Example response: | ||
```javascript | ||
{ | ||
name: 'Pontevedra', | ||
province: 'Pontevedra', | ||
today: { | ||
value: '13', | ||
descripcion: 'Intervalos nubosos', | ||
tmp: { | ||
min: 6, | ||
max: 13 | ||
} | ||
}, | ||
tomorrow: { | ||
value: '13', | ||
descripcion: 'Intervalos nubosos', | ||
tmp: { | ||
min: 5, | ||
max: 16 | ||
} | ||
}, | ||
next2: { | ||
value: '25', | ||
descripcion: 'Muy nuboso con lluvia', | ||
tmp: { | ||
min: 7, | ||
max: 13 | ||
} | ||
}, | ||
} | ||
```` | ||
### getForecast(provinceId) | ||
@@ -45,0 +101,0 @@ Ask for the weather forecast in a given province, the province code can be obtained from [here](http://www.ine.es/jaxi/menu.do?type=pcaxis&path=/t20/e245/codmun&file=inebase) |
@@ -12,2 +12,12 @@ const rp = require('request-promise'); | ||
.then(response => Prediction(response))); | ||
}, | ||
getSimpleForecast: function(id) { | ||
let options = Options(id, apiKey); | ||
return rp(options) | ||
.then(response => rp({url: JSON.parse(response).datos, encoding: null}) | ||
.then(response => { | ||
let prediction = Prediction(response); | ||
delete prediction.forecast; | ||
return prediction; | ||
})); | ||
} | ||
@@ -14,0 +24,0 @@ } |
@@ -15,7 +15,17 @@ const Meteosapi = require('../src/index.js'); | ||
assert.notEqual(data.today, undefined, 'Data.today should be defined'); | ||
assert.notEqual(data.tomorrow, undefined, 'Data.province should be defined'); | ||
assert.notEqual(data.next2, undefined, 'Data.province should be defined'); | ||
assert.notEqual(data.forecast, undefined, 'Data.province should be defined'); | ||
assert.notEqual(data.tomorrow, undefined, 'Data.tomorrow should be defined'); | ||
assert.notEqual(data.next2, undefined, 'Data.next2 should be defined'); | ||
assert.notEqual(data.forecast, undefined, 'Data. forecast be defined'); | ||
}); | ||
}); | ||
it('should return the simplified wheather', () => { | ||
return meteosapi.getSimpleForecast(proviceKey).then(data => { | ||
assert.equal(data.name, 'Pontevedra', 'Data.name should be "Pontevedra"'); | ||
assert.equal(data.province, 'Pontevedra', 'Data.province should be "Pontevedra"'); | ||
assert.notEqual(data.today, undefined, 'Data.today should be defined'); | ||
assert.notEqual(data.tomorrow, undefined, 'Data.tomorrow should be defined'); | ||
assert.notEqual(data.next2, undefined, 'Data.next2 should be defined'); | ||
assert.equal(data.forecast, undefined, 'Data.forecast should be defined'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10442
88
220