1
+ define ( [ "require" , "jquery" , "underscore" , "./util" , "./api" , "./mediaCollection" ] , function ( require ) {
2
+ var $ = require ( "jquery" ) , _ = require ( "underscore" ) , util = require ( "./util" ) , prop = util . getProperty , api = require ( "./api" ) , MediaCollection = require ( "./mediaCollection" ) ;
3
+ function ArtistInfo ( data ) {
4
+ this . _data = Object . freeze ( {
5
+ oaArtistId : prop ( data , "oa_artist_id" ) ,
6
+ name : prop ( data , "name" ) ,
7
+ bio : prop ( data , "bio.media.0.data.text" ) || prop ( data , "bio.text" ) ,
8
+ coverPhoto : new MediaCollection ( prop ( data , "cover_photo.0.media" ) ) ,
9
+ factCard : prop ( data , "fact_card.media.0.data" ) ,
10
+ profilePhoto : new MediaCollection ( prop ( data , "profile_photo.media" ) ) ,
11
+ styleTags : prop ( data , "tags.media.0.data.tags" )
12
+ } ) ;
13
+ }
14
+ return ArtistInfo . prototype = {
15
+ oaArtistId : function ( ) {
16
+ return this . _data . oaArtistId ;
17
+ } ,
18
+ name : function ( ) {
19
+ return this . _data
20
+ . name ;
21
+ } ,
22
+ bio : function ( ) {
23
+ return this . _data . bio ;
24
+ } ,
25
+ coverPhoto : function ( ) {
26
+ return this . _data . coverPhoto ;
27
+ } ,
28
+ factCard : function ( ) {
29
+ return this . _data . factCard ;
30
+ } ,
31
+ profilePhoto : function ( ) {
32
+ return this . _data . profilePhoto ;
33
+ } ,
34
+ styleTags : function ( ) {
35
+ return this . _data . styleTags ;
36
+ } ,
37
+ asObject : function ( ) {
38
+ return {
39
+ oaArtistId : this . oaArtistId ( ) ,
40
+ name : this . name ( ) ,
41
+ bio : this . bio ( ) ,
42
+ coverPhoto : this . coverPhoto ( ) ,
43
+ factCard : this . factCard ( ) ,
44
+ profilePhoto : this . profilePhoto ( ) ,
45
+ styleTags : this . styleTags ( )
46
+ } ;
47
+ }
48
+ } , ArtistInfo . api = function ( ) {
49
+ return api ;
50
+ } , ArtistInfo . fetchByOaArtistId = function ( id , cb ) {
51
+ return api . infoRequest ( "artists/" + id , {
52
+ id_type : "oa:artist_id"
53
+
54
+ } , function ( status , data ) {
55
+ cb ( new ArtistInfo ( data ) ) ;
56
+ } ) ;
57
+ } , ArtistInfo . fetchByMbGid = function ( id , cb ) {
58
+ return api . infoRequest ( "artists/" + id , {
59
+ id_type : "musicbrainz:gid"
60
+ } , function ( status , data ) {
61
+ cb ( new ArtistInfo ( data ) ) ;
62
+ } ) ;
63
+ } , ArtistInfo . fetchByAnchorId = function ( id , cb ) {
64
+ return api . infoRequest ( "artists/" + id , {
65
+ id_type : "oa:anchor_id"
66
+ } , function ( status , data ) {
67
+ cb ( new ArtistInfo ( data ) ) ;
68
+ } ) ;
69
+ } , ArtistInfo ;
70
+ } ) ; ;
0 commit comments