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: 8 additions & 4 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ module.exports = {
var qs = options;
qs.auth_token = this.auth_token;

this.last_uri_called = ["api", this.api_version, "datasets", code.source, code.table].join("/");
var config = {
uri: ["api", this.api_version, "datasets", code.source, code.table].join("/"),
uri: this.last_uri_called,
format: format,
qs: qs,
proxy: this.proxy
Expand Down Expand Up @@ -57,8 +58,9 @@ module.exports = {
return combined_code;
}).join(",");

this.last_uri_called = ["api", this.api_version, "multisets"].join("/");
var config = {
uri: ["api", this.api_version, "multisets"].join("/"),
uri: this.last_uri_called,
format: format,
qs: qs,
proxy: this.proxy
Expand All @@ -79,8 +81,9 @@ module.exports = {
var qs = options;
qs.auth_token = this.auth_token;

this.last_uri_called = ["api", this.api_version, "current_user", "collections", "datasets", "favourites"].join("/");
var config = {
uri: ["api", this.api_version, "current_user", "collections", "datasets", "favourites"].join("/"),
uri: this.last_uri_called,
format: format,
qs: qs,
proxy: this.proxy
Expand All @@ -102,8 +105,9 @@ module.exports = {
qs.auth_token = this.auth_token;
qs.query = terms.replace(" ", "+");

this.last_uri_called = ["api", this.api_version, "datasets"].join("/");
var config = {
uri: ["api", this.api_version, "datasets"].join("/"),
uri: this.last_uri_called,
format: format,
qs: qs,
proxy: this.proxy
Expand Down
1 change: 1 addition & 0 deletions quandl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var api = require([__dirname, "lib", "api"].join("/"));

function Quandl(config){
this.configure(config || {});
this.last_uri_called = ""; // contains the string value of the last uri called for debugging and testing, empty if no calls made
}

Quandl.prototype.configure = function(config){
Expand Down
25 changes: 24 additions & 1 deletion test/quandl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("quandl", function(){
});

it("default config parameters are set correctly", function(){
assert.equal(quandl.api_version, "v1");
assert.equal(quandl.api_version, "v3");
assert.equal(quandl.auth_token, undefined);
});

Expand All @@ -41,4 +41,27 @@ describe("quandl", function(){
});

});


describe("contains last_uri_call", function(){
it("contains an empty string value", function() {
assert.equal(quandl.last_uri_called, "");
});

it("has correct api call for v3", function() {
quandl.configure({
api_version: 3,
auth_token: "dsahFHUiewjjd"
});

quandl.dataset(
{source: 'CBOE/VXEEM', format: 'json'},
function(){});

assert.equal(
quandl.last_uri_called,
"api/v1/datasets/CBOE/VXEEM.json");
});
});

});