diff --git a/lib/class.instagram.media.coffee b/lib/class.instagram.media.coffee index d7bdf58..3f544ce 100644 --- a/lib/class.instagram.media.coffee +++ b/lib/class.instagram.media.coffee @@ -14,7 +14,11 @@ class InstagramMedia info: (params) -> credentials = @parent._credentials {} - params['path'] = "/#{@parent._api_version}/media/#{params['media_id']}?#{@parent._to_querystring(credentials)}" + if params['media_shortcode'] + path = "/media/shortcode/#{params['media_shortcode']}" + else + path = "/media/#{params['media_id']}" + params['path'] = "/#{@parent._api_version}#{path}?#{@parent._to_querystring(credentials)}" @parent._request params search: (params) -> diff --git a/lib/class.instagram.media.js b/lib/class.instagram.media.js index 9cc2144..9511a0c 100644 --- a/lib/class.instagram.media.js +++ b/lib/class.instagram.media.js @@ -1,17 +1,16 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.8.0 (function() { var InstagramMedia; InstagramMedia = (function() { - function InstagramMedia(parent) { this.parent = parent; } - /* - Basic Media - */ + /* + Basic Media + */ InstagramMedia.prototype.popular = function(params) { var credentials; @@ -21,9 +20,14 @@ }; InstagramMedia.prototype.info = function(params) { - var credentials; + var credentials, path; credentials = this.parent._credentials({}); - params['path'] = "/" + this.parent._api_version + "/media/" + params['media_id'] + "?" + (this.parent._to_querystring(credentials)); + if (params['media_shortcode']) { + path = "/media/shortcode/" + params['media_shortcode']; + } else { + path = "/media/" + params['media_id']; + } + params['path'] = "/" + this.parent._api_version + path + "?" + (this.parent._to_querystring(credentials)); return this.parent._request(params); }; @@ -33,10 +37,10 @@ return this.parent._request(params); }; - /* - Likes - */ + /* + Likes + */ InstagramMedia.prototype.likes = function(params) { var credentials; @@ -59,10 +63,10 @@ return this.parent._request(params); }; - /* - Comments - */ + /* + Comments + */ InstagramMedia.prototype.comments = function(params) { var credentials; @@ -88,10 +92,10 @@ return this.parent._request(params); }; - /* - Subscriptions - */ + /* + Subscriptions + */ InstagramMedia.prototype.subscribe = function(params) { params['object'] = 'geography'; diff --git a/package.json b/package.json index a7d45f2..7f7e209 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,11 @@ "directories": { "lib": "./lib" }, + "devDependencies": { + "express": "3.17.7", + "expresso": "*", + "should": "*" + }, "files": [ "" ], diff --git a/test/instagram.media.coffee b/test/instagram.media.coffee index 8264acf..184797f 100644 --- a/test/instagram.media.coffee +++ b/test/instagram.media.coffee @@ -35,6 +35,13 @@ module.exports = data.should.have.property 'created_time', '1279315783' test.output "data had the property 'created_time' equal to 1279315783" app.finish_test() + 'media#info for shortcode#33': -> + test.helper 'media#info for shortcode#33', Instagram, 'media', 'info', { media_shortcode: 33 }, (data) -> + data.should.have.property 'shortcode', '33' + test.output "data had the property 'shortcode' equal to 33" + data.should.have.property 'created_time', '1279315783' + test.output "data had the property 'created_time' equal to 1279315783" + app.finish_test() 'media#search for 48.858844300000001/2.2943506': -> test.helper 'media#search for 48.858844300000001/2.2943506', Instagram, 'media', 'search', { lat: 48.858844300000001, lng: 2.2943506 }, (data) -> data.length.should.be.above 0 diff --git a/test/instagram.media.js b/test/instagram.media.js index 74c4cf0..8f02a47 100644 --- a/test/instagram.media.js +++ b/test/instagram.media.js @@ -1,9 +1,8 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.8.0 /* Test Setup -*/ - + */ (function() { var Init, Instagram, app, assert, completed, should, test, to_do; @@ -26,10 +25,10 @@ Test Setup to_do = 0; + /* Tests - */ - + */ module.exports = { 'media#popular': function() { @@ -52,6 +51,17 @@ Test Setup return app.finish_test(); }); }, + 'media#info for shortcode#33': function() { + return test.helper('media#info for shortcode#33', Instagram, 'media', 'info', { + media_shortcode: 33 + }, function(data) { + data.should.have.property('shortcode', '33'); + test.output("data had the property 'shortcode' equal to 33"); + data.should.have.property('created_time', '1279315783'); + test.output("data had the property 'created_time' equal to 1279315783"); + return app.finish_test(); + }); + }, 'media#search for 48.858844300000001/2.2943506': function() { return test.helper('media#search for 48.858844300000001/2.2943506', Instagram, 'media', 'search', { lat: 48.858844300000001, @@ -165,6 +175,7 @@ Test Setup } }; + /* tested on Austin, Tx. { lat: 30.30, lng: -97.70, distance: 5000 }; weird, request with count 200 produces 54, request with count 50 produces 46, request with count 46 produces 42, request with count 42 produces 38... I think you see the pattern. :) @@ -173,8 +184,7 @@ Test Setup data.length.should.equal 42 test.output "data had length equal to 42", data.length app.finish_test() - */ - + */ app.start_tests(module.exports);