dodge
Version:
An API client for Foursquare's Venues Service
183 lines (178 loc) • 7.1 kB
JavaScript
// Generated by CoffeeScript 1.7.1
(function() {
var omit, requireVenueId;
omit = require('underscore').omit;
requireVenueId = function(options) {
if (!options.venueId) {
throw new Error("Missing required venueId");
}
return {
venueId: options.venueId,
options: omit(options, 'venueId')
};
};
module.exports = function(client) {
return {
venues: {
categories: function(callback) {
return client.fetch('venues/categories', {}, function(err, data) {
var _ref;
return callback(err, data != null ? (_ref = data.response) != null ? _ref.categories : void 0 : void 0);
});
},
search: function(options, callback) {
var hasRequiredParameters;
if (options == null) {
options = {};
}
hasRequiredParameters = function() {
if (options.intent === 'browse') {
return ((options.ll != null) && (options.radius != null)) || ((options.ne != null) && (options.sw != null)) || ((options.near != null) && (options.radius != null));
} else {
return (options.ll != null) || (options.near != null);
}
};
if (!hasRequiredParameters()) {
throw new Error("Missing location parameters");
}
return client.fetch('venues/search', options, function(err, data) {
var _ref;
return callback(err, data != null ? (_ref = data.response) != null ? _ref.venues : void 0 : void 0);
});
},
suggestcompletion: function(options, callback) {
var hasRequiredParameters;
if (options == null) {
options = {};
}
hasRequiredParameters = function() {
return (options.query != null) && ((options.ll != null) || (options.near != null));
};
if (!hasRequiredParameters()) {
throw new Error("Missing required parameters ('query', one of: ['ll', 'near'])");
}
return client.fetch('venues/suggestcompletion', options, function(err, data) {
var _ref;
return callback(err, (_ref = data.response) != null ? _ref.minivenues : void 0);
});
},
detail: function(options, callback) {
var venueId;
if (options == null) {
options = {};
}
venueId = requireVenueId(options).venueId;
return client.fetch("venues/" + venueId, {}, function(err, data) {
var _ref;
return callback(err, data != null ? (_ref = data.response) != null ? _ref.venue : void 0 : void 0);
});
},
events: function(options, callback) {
var venueId;
if (options == null) {
options = {};
}
venueId = requireVenueId(options).venueId;
return client.fetch("venues/" + venueId + "/events", {}, function(err, data) {
var _ref;
return callback(err, data != null ? (_ref = data.response) != null ? _ref.events : void 0 : void 0);
});
},
hours: function(options, callback) {
var venueId;
if (options == null) {
options = {};
}
venueId = requireVenueId(options).venueId;
return client.fetch("venues/" + venueId + "/hours", {}, function(err, data) {
return callback(err, data != null ? data.response : void 0);
});
},
likes: function(options, callback) {
var venueId;
if (options == null) {
options = {};
}
venueId = requireVenueId(options).venueId;
return client.fetch("venues/" + venueId + "/likes", {}, function(err, data) {
var _ref;
return callback(err, data != null ? (_ref = data.response) != null ? _ref.likes : void 0 : void 0);
});
},
links: function(options, callback) {
var venueId;
if (options == null) {
options = {};
}
venueId = requireVenueId(options).venueId;
return client.fetch("venues/" + venueId + "/links", {}, function(err, data) {
var _ref;
return callback(err, data != null ? (_ref = data.response) != null ? _ref.links : void 0 : void 0);
});
},
listed: function(options, callback) {
var venueId, _ref;
if (options == null) {
options = {};
}
_ref = requireVenueId(options), venueId = _ref.venueId, options = _ref.options;
options.group = 'other';
return client.fetch("venues/" + venueId + "/listed", options, function(err, data) {
var _ref1;
return callback(err, data != null ? (_ref1 = data.response) != null ? _ref1.lists : void 0 : void 0);
});
},
menu: function(options, callback) {
var venueId;
if (options == null) {
options = {};
}
venueId = requireVenueId(options).venueId;
return client.fetch("venues/" + venueId + "/menu", {}, function(err, data) {
var _ref;
return callback(err, data != null ? (_ref = data.response) != null ? _ref.menu : void 0 : void 0);
});
},
nextvenues: function(options, callback) {
var venueId;
if (options == null) {
options = {};
}
venueId = requireVenueId(options).venueId;
return client.fetch("venues/" + venueId + "/nextvenues", {}, function(err, data) {
var _ref;
return callback(err, data != null ? (_ref = data.response) != null ? _ref.nextVenues : void 0 : void 0);
});
},
photos: function(options, callback) {
var hasValidParameters, venueId, _ref;
if (options == null) {
options = {};
}
hasValidParameters = function() {
return (options.group == null) || options.group === 'venue';
};
_ref = requireVenueId(options), venueId = _ref.venueId, options = _ref.options;
if (!hasValidParameters()) {
throw new Error("Unsupported group parameter");
}
return client.fetch("venues/" + venueId + "/photos", options, function(err, data) {
var _ref1;
return callback(err, data != null ? (_ref1 = data.response) != null ? _ref1.photos : void 0 : void 0);
});
},
tips: function(options, callback) {
var venueId, _ref;
if (options == null) {
options = {};
}
_ref = requireVenueId(options), venueId = _ref.venueId, options = _ref.options;
return client.fetch("venues/" + venueId + "/tips", options, function(err, data) {
var _ref1;
return callback(err, data != null ? (_ref1 = data.response) != null ? _ref1.tips : void 0 : void 0);
});
}
}
};
};
}).call(this);