Comparing version 1.5.0 to 1.6.0
'use strict'; | ||
var warn = require('diagnostics')('artsy:api:partner'); | ||
/** | ||
@@ -49,3 +51,3 @@ * Partner endpoint | ||
/** | ||
* All available options for querying partner artists. | ||
* All available options for querying artists for a partner. | ||
* | ||
@@ -83,2 +85,70 @@ * @type {Array} | ||
/** | ||
* All available options for querying "partner artists" | ||
* for a partner. | ||
* | ||
* n.b. see the distinction in the data types below. | ||
* | ||
* @type {Array} | ||
* @private | ||
*/ | ||
Partner.partnerArtists = [ | ||
'artist_id', | ||
'published', | ||
'sort' | ||
]; | ||
/** | ||
* Get all "partner artists" for the partner user. | ||
* | ||
* The distinction here is that the cover photo for | ||
* the artist can be configured by the Partner in the | ||
* CMS, whereas the normal artists are the global cover | ||
* photos configured by Artsy only. | ||
* | ||
* @param {Object} options Optional options. | ||
* @param {function} fn The callback. | ||
* @returns {Assign} | ||
* @api public | ||
*/ | ||
Partner.prototype.partnerArtists = function (args) { | ||
args = this.api.args(arguments); | ||
var options = args.options || {}, | ||
partner = args.str || options.partner; | ||
return this.send( | ||
['partner', partner, 'partner_artists.json'], | ||
this.api.options(options, Partner.artists), | ||
function (err, pArtists) { | ||
if (err) { return args.fn(err); } | ||
// | ||
// If the partner specific `image_*` properties are not | ||
// available then fall back to the global ones. If those do | ||
// not exist then do not include this artist. | ||
// | ||
pArtists = pArtists.map(function (pArtist) { | ||
if (!pArtist.image_urls || !pArtist.image_versions) { | ||
warn('Fall back: no image_urls or image_versions', pArtist.sortable_id); | ||
if (!pArtist.artist || !pArtist.artist.image_urls) { | ||
warn('Fall back failure: no artist.image_urls %s', pArtist.sortable_id); | ||
return null; | ||
} | ||
pArtist.image_urls = pArtist.artist.image_urls; | ||
pArtist.image_versions = pArtist.artist.image_versions; | ||
pArtist.image_url = pArtist.artist.image_url; | ||
} | ||
return pArtist; | ||
}).filter(Boolean); | ||
args.fn(null, pArtists); | ||
} | ||
); | ||
}; | ||
/** | ||
* All available options for querying artworks. | ||
@@ -85,0 +155,0 @@ * |
@@ -60,3 +60,3 @@ 'use strict'; | ||
return this.send( | ||
['partner', options.partner, 'show', options.show], | ||
['partner', options.partner, 'show', options.show, 'artworks'], | ||
options, | ||
@@ -87,2 +87,22 @@ args.fn | ||
/** | ||
* Get Installation images for a partner show by ID | ||
* | ||
* @param {String} str show id | ||
* @param {Object} options Optional options. | ||
* @param {function} fn The callback. | ||
* @returns {Assign} | ||
* @api public | ||
*/ | ||
Show.prototype.documents = function (args) { | ||
args = this.api.args(arguments); | ||
var options = args.options || {}; | ||
return this.send( | ||
['partner', options.partner, 'show', options.show, 'documents'], | ||
options, | ||
args.fn | ||
); | ||
}; | ||
module.exports = Show; |
{ | ||
"name": "artsy", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "A Node.js client for the Artsy API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
var vows = require('vows'), | ||
assert = require('./assert'), | ||
Artsy = require('../'), | ||
macros = require('./macros'); | ||
macros = require('./macros'), | ||
debug = require('diagnostics')('artsy:test:artwork'); | ||
@@ -15,2 +16,3 @@ vows.describe('artsy/artist').addBatch({ | ||
// | ||
debug('artist.get', artist); | ||
} | ||
@@ -24,6 +26,7 @@ }), | ||
// | ||
debug('artist.artworks', artworks); | ||
} | ||
}) | ||
// | ||
// TODO (indexzero): Figure out if we should keep these methods | ||
// Remark (indexzero): these seem only accessible to Artsy admins | ||
// | ||
@@ -36,2 +39,2 @@ // 'artist.artworkAll': macros.call('faith-ringgold', { | ||
} | ||
}).export(module); | ||
}).export(module); |
var vows = require('vows'), | ||
assert = require('./assert'), | ||
Artsy = require('../'), | ||
macros = require('./macros'); | ||
macros = require('./macros'), | ||
debug = require('diagnostics')('artsy:test:artwork'); | ||
@@ -15,5 +16,6 @@ vows.describe('artsy/artwork').addBatch({ | ||
// | ||
debug('artwork.get', artwork); | ||
} | ||
}) | ||
} | ||
}).export(module); | ||
}).export(module); |
@@ -12,3 +12,3 @@ var vows = require('vows'), | ||
config = require('../dist/artsy-api'); | ||
if (!config.xapp) { | ||
if (!config.xapp && !config.token) { | ||
throw new Error('Please write an XAPP key to ./dist/artsy-api.json'); | ||
@@ -25,3 +25,3 @@ } | ||
// | ||
exports.client = new Artsy({ token: config.xapp }); | ||
exports.client = new Artsy(config); | ||
@@ -52,2 +52,2 @@ // | ||
return outer; | ||
}; | ||
}; |
var vows = require('vows'), | ||
assert = require('./assert'), | ||
Artsy = require('../'), | ||
macros = require('./macros'); | ||
macros = require('./macros'), | ||
debug = require('diagnostics')('artsy:test:partner'); | ||
@@ -14,5 +15,30 @@ vows.describe('artsy/partner').addBatch({ | ||
// | ||
debug('partner.shows', shows); | ||
} | ||
}), | ||
'partner.artists': macros.call('aca-galleries', { | ||
'should return a list of artists': function (artists) { | ||
assert.isArray(artists); | ||
// | ||
// TODO (indexzero): More asserts. | ||
// | ||
debug('partner.artists', artists); | ||
} | ||
}), | ||
'partner.partnerArtists': macros.call('aca-galleries', { | ||
'should return a list of "partner artists"': function (pArtists) { | ||
assert.isArray(pArtists); | ||
pArtists.forEach(function (pArtist) { | ||
assert.isObject(pArtist.artist); | ||
assert.isObject(pArtist.partner); | ||
assert.isArray(pArtist.image_versions); | ||
assert.isObject(pArtist.image_urls); | ||
}); | ||
// | ||
// TODO (indexzero): More asserts. | ||
// | ||
debug('partner.partnerArtists', pArtists); | ||
} | ||
}) | ||
} | ||
}).export(module); | ||
}).export(module); |
var vows = require('vows'), | ||
assert = require('./assert'), | ||
Artsy = require('../'), | ||
macros = require('./macros'); | ||
macros = require('./macros'), | ||
debug = require('diagnostics')('artsy:test:show'); | ||
vows.describe('artsy/show').addBatch({ | ||
'Using node-artsy': { | ||
'show.get': macros.call('aca-galleries-luis-jimenez', { | ||
'show.get': macros.call('aca-galleries-peter-blume', { | ||
'should return a show': function (show) { | ||
assert.isObject(show); | ||
// | ||
// TODO (indexzero): More asserts. | ||
// | ||
assert.isArray(show.artists); | ||
assert.isObject(show.partner); | ||
assert.isObject(show.location); | ||
debug('show.get', show); | ||
} | ||
@@ -19,9 +22,11 @@ }), | ||
partner: 'aca-galleries', | ||
show: 'aca-galleries-luis-jimenez' | ||
show: 'aca-galleries-peter-blume' | ||
}, { | ||
'should return a show': function (show) { | ||
assert.isObject(show); | ||
// | ||
// TODO (indexzero): More asserts. | ||
// | ||
assert.isArray(show.artists); | ||
assert.isObject(show.partner); | ||
assert.isObject(show.location); | ||
debug('show.get', show); | ||
} | ||
@@ -31,18 +36,36 @@ }), | ||
partner: 'aca-galleries', | ||
show: 'aca-galleries-luis-jimenez' | ||
show: 'aca-galleries-peter-blume' | ||
}, { | ||
'should return artworks from the show': function (artworks) { | ||
assert.isArray(artworks); | ||
assert.ok(artworks.length); | ||
// | ||
// TODO (indexzero): More asserts. | ||
// | ||
debug('show.artworks', artworks); | ||
} | ||
}), | ||
'show.documents': macros.call({ | ||
partner: 'aca-galleries', | ||
show: 'aca-galleries-peter-blume' | ||
}, { | ||
'should return documents from the show': function (documents) { | ||
assert.isArray(documents); | ||
assert.lengthOf(documents, 2); | ||
documents.forEach(function (document) { | ||
assert.ok(document.title.indexOf('Peter Blume') !== -1); | ||
}); | ||
debug('show.documents', documents); | ||
} | ||
}) | ||
}, | ||
'show.images': macros.call('aca-galleries-aca-galleries-at-miami-project-2014', { | ||
'show.images': macros.call('aca-galleries-peter-blume', { | ||
'should return images from the show': function (images) { | ||
assert.isArray(images); | ||
assert.ok(images.length); | ||
// | ||
// TODO (indexzero): More asserts. | ||
// | ||
debug('show.images', images); | ||
} | ||
@@ -49,0 +72,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47322
1180