diff --git a/lib/wundergroundnode.js b/lib/wundergroundnode.js index 5b939e1..6ba178a 100644 --- a/lib/wundergroundnode.js +++ b/lib/wundergroundnode.js @@ -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/"); @@ -68,6 +69,11 @@ var Wunderground = function(apikey) { return this; }; + that.settings = function(settings) { + this.requestSettings = settings; + return this; + }; + /** * Historical request, cannot be chained. * @@ -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 diff --git a/test/testWundergroundnode.js b/test/testWundergroundnode.js index 2249527..469a809 100644 --- a/test/testWundergroundnode.js +++ b/test/testWundergroundnode.js @@ -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){