Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/wundergroundnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ var Wunderground = function(apikey) {
"use strict";

var that = this;
var format = ".json";

that.chainedRequests = [];
var format = ".json";
that.requestSettings = null;

that.conditions = function() {
this.chainedRequests.push("conditions/");
Expand Down Expand Up @@ -68,6 +69,11 @@ var Wunderground = function(apikey) {
return this;
};

that.settings = function(settings) {
this.requestSettings = settings;
return this;
};

/**
* Historical request, cannot be chained.
*
Expand Down Expand Up @@ -130,7 +136,9 @@ var Wunderground = function(apikey) {
}

// Construct the url
var url = 'http://api.wunderground.com/api/' + apikey + '/' + that.chainedRequests.join('') + 'q/'+query + format;
var settings = that.requestSettings ? that.requestSettings + '/' : '';
var url = 'http://api.wunderground.com/api/' + apikey + '/' + that.chainedRequests.join('') + settings + 'q/'+query + format;

that.chainedRequests = [];

// Request the url
Expand Down
16 changes: 16 additions & 0 deletions test/testWundergroundnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ describe('Testing Weather Underground Node Client:', function(){

});


it('Adding settings to the request.', function(done){
getDevKey(function(key){
var wunderground = new Wunderground(key);
// test only that the request still works, lib does not provide way of cheking the sent url now
wunderground.hourlyForecast().hourlyTenDayForecast().forecast().almanac().yesterday().settings('lang:CZ').request('84111', function(err, response){
response.should.have.property('almanac');
response.should.have.property('hourly_forecast');
response.should.have.property('forecast');
response.should.have.property('history');
done();
});
});

});

it('Call without a resource', function(done){

getDevKey(function(key){
Expand Down