2013-05-17 03:54:33 +00:00
|
|
|
(function(context,$) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Javascript wrappers for the REST API
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
context.JK = context.JK || {};
|
2013-06-24 21:40:04 +00:00
|
|
|
context.JK.Rest = function() {
|
2013-05-17 03:54:33 +00:00
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
var logger = context.JK.logger;
|
|
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
function createJoinRequest(joinRequest) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/join_requests',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false,
|
|
|
|
|
data: JSON.stringify(joinRequest)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateJoinRequest(joinRequestId, isApproved) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "PUT",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/join_requests/' + joinRequestId,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false,
|
|
|
|
|
data: JSON.stringify({"approved": isApproved})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-06 21:17:26 +00:00
|
|
|
function legacyCreateSession(options) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/sessions/legacy",
|
|
|
|
|
processData:false,
|
2014-05-18 04:09:21 +00:00
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
});
|
2014-05-06 21:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-06 22:50:41 +00:00
|
|
|
function legacyJoinSession(options) {
|
|
|
|
|
var sessionId = options["session_id"];
|
|
|
|
|
delete options["session_id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/sessions/" + sessionId + "/participants/legacy",
|
|
|
|
|
data: JSON.stringify(options),
|
|
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-20 13:26:32 +00:00
|
|
|
function joinSession(options) {
|
|
|
|
|
var sessionId = options["session_id"];
|
|
|
|
|
delete options["session_id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/sessions/" + sessionId + "/participants",
|
2014-05-21 16:24:40 +00:00
|
|
|
data: JSON.stringify(options),
|
2014-05-20 13:26:32 +00:00
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-09 18:04:56 +00:00
|
|
|
function findSessions(query) {
|
2014-03-07 20:20:34 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
2014-03-09 18:04:56 +00:00
|
|
|
url: "/api/sessions?" + $.param(query)
|
2014-03-07 20:20:34 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-01 18:45:17 +00:00
|
|
|
function findScheduledSessions(query) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: "/api/sessions/scheduled?" + $.param(query)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-09 18:04:56 +00:00
|
|
|
function findScoredSessions(clientId, query) {
|
2014-03-07 20:20:34 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
2014-03-09 18:04:56 +00:00
|
|
|
url: "/api/sessions/nindex/" + clientId + "?" + $.param(query)
|
2014-03-07 20:20:34 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-05 23:18:53 +00:00
|
|
|
function updateSession(id, newSession) {
|
2013-06-10 02:12:43 +00:00
|
|
|
return $.ajax('/api/sessions/' + id, {
|
|
|
|
|
type: "PUT",
|
|
|
|
|
data : newSession,
|
2014-03-05 23:18:53 +00:00
|
|
|
dataType : 'json'
|
2013-06-10 02:12:43 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 23:14:47 +00:00
|
|
|
function getSessionHistory(id) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/sessions/' + id + '/history',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 03:52:59 +00:00
|
|
|
function addSessionInfoComment(sessionId, comment) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/sessions/' + sessionId + "/details/comments",
|
|
|
|
|
type: "POST",
|
|
|
|
|
data : JSON.stringify({"comment": comment}),
|
|
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-28 07:35:35 +00:00
|
|
|
function addSessionComment(sessionId, userId, comment) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/sessions/' + sessionId + "/comments",
|
|
|
|
|
type: "POST",
|
|
|
|
|
data : JSON.stringify({"comment": comment, "user_id": userId}),
|
|
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addSessionLike(sessionId, userId) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/sessions/' + sessionId + "/likes",
|
|
|
|
|
type: "POST",
|
|
|
|
|
data : JSON.stringify({"user_id": userId}),
|
|
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 06:33:37 +00:00
|
|
|
function getRsvpRequests(sessionId) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/rsvp_requests?session_id=' + sessionId,
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 03:43:57 +00:00
|
|
|
function submitRsvpRequest(sessionId, slotIds) {
|
2014-05-28 05:14:14 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/rsvp_requests',
|
|
|
|
|
type: "POST",
|
2014-05-29 03:43:57 +00:00
|
|
|
data : JSON.stringify({"session_id": sessionId, "rsvp_slots": slotIds}),
|
2014-05-28 05:14:14 +00:00
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 06:33:37 +00:00
|
|
|
function cancelRsvpRequest(sessionId, rsvpRequestId, cancelAll) {
|
|
|
|
|
var cancel = "yes";
|
|
|
|
|
if (cancelAll) {
|
|
|
|
|
cancel = "all";
|
|
|
|
|
}
|
|
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/rsvp_requests/' + rsvpRequestId,
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
data : JSON.stringify({"session_id": sessionId, "cancelled": cancel}),
|
2014-05-28 05:14:14 +00:00
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getOpenSessionSlots(sessionId, openOnly) {
|
|
|
|
|
var url = '/api/rsvp_slots?session_id=' + sessionId;
|
|
|
|
|
|
|
|
|
|
if (openOnly) {
|
|
|
|
|
url += '&open_only=true';
|
|
|
|
|
}
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-28 07:35:35 +00:00
|
|
|
function addRecordingComment(recordingId, userId, comment) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/recordings/' + recordingId + "/comments",
|
|
|
|
|
type: "POST",
|
|
|
|
|
data : JSON.stringify({"comment": comment, "user_id": userId}),
|
|
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-20 20:54:35 +00:00
|
|
|
function addRecordingLike(recordingId, claimedRecordingId, userId) {
|
2014-01-28 07:35:35 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/recordings/' + recordingId + "/likes",
|
|
|
|
|
type: "POST",
|
2014-02-20 20:59:50 +00:00
|
|
|
data : JSON.stringify({"user_id": userId, claimed_recording_id: claimedRecordingId}),
|
2014-01-28 07:35:35 +00:00
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-07 07:35:10 +00:00
|
|
|
function addPlayablePlay(playableId, playableType, claimedRecordingId, userId) {
|
2014-03-09 01:16:39 +00:00
|
|
|
if (playableType == 'JamRuby::Recording') {
|
|
|
|
|
context.JK.GA.trackRecordingPlay();
|
2014-05-06 13:34:38 +00:00
|
|
|
} else if (playableType == 'JamRuby::MusicSession') {
|
2014-03-09 01:16:39 +00:00
|
|
|
context.JK.GA.trackSessionPlay();
|
|
|
|
|
}
|
2014-01-28 07:35:35 +00:00
|
|
|
return $.ajax({
|
2014-03-07 06:46:07 +00:00
|
|
|
url: '/api/users/' + playableId + "/plays",
|
2014-01-28 07:35:35 +00:00
|
|
|
type: "POST",
|
2014-03-07 07:35:10 +00:00
|
|
|
data : JSON.stringify({user_id: userId, claimed_recording_id: claimedRecordingId, playable_type: playableType}),
|
2014-01-28 07:35:35 +00:00
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-20 22:23:44 +00:00
|
|
|
function updateFavorite(claimedRecordingId, favorite) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
url: '/api/favorites/' + claimedRecordingId,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data : JSON.stringify({favorite: favorite}),
|
|
|
|
|
dataType : 'json',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-19 22:56:13 +00:00
|
|
|
function validateBand(band) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/bands/validate',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false,
|
|
|
|
|
data: JSON.stringify(band)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-01 20:09:44 +00:00
|
|
|
function getBand(bandId) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/bands/' + bandId,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-21 06:24:40 +00:00
|
|
|
function createBand(band) {
|
2014-01-30 21:51:05 +00:00
|
|
|
var deferred = $.ajax({
|
2013-11-21 06:24:40 +00:00
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/bands',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false,
|
|
|
|
|
data: JSON.stringify(band)
|
|
|
|
|
});
|
|
|
|
|
|
2014-01-30 21:51:05 +00:00
|
|
|
deferred.done(function() {
|
|
|
|
|
context.JK.GA.trackBand(context.JK.GA.BandActions.create);
|
|
|
|
|
context.JK.GA.trackBand(context.JK.GA.BandActions.join);
|
2013-12-01 20:09:44 +00:00
|
|
|
});
|
2014-01-30 21:51:05 +00:00
|
|
|
|
|
|
|
|
return deferred;
|
2013-12-01 20:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-21 06:24:40 +00:00
|
|
|
function updateBand(band) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/bands/' + band.id,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false,
|
|
|
|
|
data: JSON.stringify(band)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-23 20:06:42 +00:00
|
|
|
function createBandInvitation(bandId, userId) {
|
|
|
|
|
var bandInvitation = {
|
|
|
|
|
band_id: bandId,
|
|
|
|
|
user_id: userId
|
|
|
|
|
};
|
2014-01-07 23:30:23 +00:00
|
|
|
|
2013-11-23 20:06:42 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/bands/' + bandId + "/invitations",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false,
|
|
|
|
|
data: JSON.stringify(bandInvitation)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-26 07:47:56 +00:00
|
|
|
function updateBandInvitation(bandId, invitationId, isAccepted) {
|
2014-01-30 21:51:05 +00:00
|
|
|
var deferred = $.ajax({
|
2013-11-23 20:06:42 +00:00
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
2013-11-26 07:47:56 +00:00
|
|
|
url: '/api/bands/' + bandId + "/invitations/" + invitationId,
|
2013-11-23 20:06:42 +00:00
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false,
|
2013-11-26 07:47:56 +00:00
|
|
|
data: JSON.stringify({"accepted": isAccepted})
|
2014-01-30 21:51:05 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if(isAccepted) {
|
|
|
|
|
deferred.done(function() {
|
|
|
|
|
context.JK.GA.trackBand(context.JK.GA.BandActions.join);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return deferred;
|
2013-11-23 20:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-08 01:45:24 +00:00
|
|
|
function removeBandMember(bandId, userId) {
|
|
|
|
|
var url = "/api/bands/" + bandId + "/musicians/" + userId;
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-05 03:12:44 +00:00
|
|
|
function getBandMembers(bandId, hasPendingInvitation) {
|
|
|
|
|
var url = "/api/bands/" + bandId + "/musicians";
|
|
|
|
|
|
|
|
|
|
if (hasPendingInvitation) {
|
|
|
|
|
url += "?pending=true";
|
|
|
|
|
}
|
2014-03-05 03:32:04 +00:00
|
|
|
|
2014-03-05 03:12:44 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-03 07:16:27 +00:00
|
|
|
function getSession(id) {
|
|
|
|
|
var url = "/api/sessions/" + id;
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-06-10 02:12:43 +00:00
|
|
|
|
2014-02-04 02:45:52 +00:00
|
|
|
function login(options) {
|
|
|
|
|
var url = '/api/auths/login';
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
processData: false,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-17 03:54:33 +00:00
|
|
|
function getUserDetail(options) {
|
2013-05-31 02:07:33 +00:00
|
|
|
var id = getId(options);
|
2013-05-17 03:54:33 +00:00
|
|
|
|
|
|
|
|
var url = "/api/users/" + id;
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-01 22:53:24 +00:00
|
|
|
function getCities(options) {
|
2013-05-17 03:54:33 +00:00
|
|
|
var country = options['country']
|
|
|
|
|
var region = options['region']
|
|
|
|
|
|
|
|
|
|
return $.ajax('/api/cities', {
|
|
|
|
|
data : { country: country, region: region },
|
|
|
|
|
dataType : 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getRegions(options) {
|
|
|
|
|
var country = options["country"]
|
|
|
|
|
|
|
|
|
|
return $.ajax('/api/regions', {
|
|
|
|
|
data : { country: country},
|
|
|
|
|
dataType : 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-09 03:05:05 +00:00
|
|
|
function getCountries() {
|
|
|
|
|
return $.ajax('/api/countries', {
|
|
|
|
|
dataType : 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-18 03:20:41 +00:00
|
|
|
function getCountriesx() {
|
|
|
|
|
return $.ajax('/api/countriesx', {
|
|
|
|
|
dataType : 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-17 03:54:33 +00:00
|
|
|
function getIsps(options) {
|
|
|
|
|
var country = options["country"]
|
|
|
|
|
|
|
|
|
|
return $.ajax('/api/isps', {
|
|
|
|
|
data : { country: country},
|
|
|
|
|
dataType : 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-09 03:31:49 +00:00
|
|
|
function getResolvedLocation() {
|
|
|
|
|
return $.ajax('/api/resolved_location', {
|
|
|
|
|
dataType: 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-17 03:54:33 +00:00
|
|
|
function getInstruments(options) {
|
2013-05-18 18:04:04 +00:00
|
|
|
return $.ajax('/api/instruments', {
|
2013-05-17 03:54:33 +00:00
|
|
|
data : { },
|
|
|
|
|
dataType : 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-23 20:06:42 +00:00
|
|
|
function getGenres(options) {
|
|
|
|
|
return $.ajax('/api/genres', {
|
|
|
|
|
data: { },
|
|
|
|
|
dataType: 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-31 02:07:33 +00:00
|
|
|
function updateAvatar(options) {
|
|
|
|
|
var id = getId(options);
|
2013-05-23 13:53:37 +00:00
|
|
|
|
2013-05-31 02:07:33 +00:00
|
|
|
var original_fpfile = options['original_fpfile'];
|
|
|
|
|
var cropped_fpfile = options['cropped_fpfile'];
|
2014-02-06 16:31:52 +00:00
|
|
|
var cropped_large_fpfile = options['cropped_large_fpfile'];
|
2013-05-31 02:07:33 +00:00
|
|
|
var crop_selection = options['crop_selection'];
|
|
|
|
|
|
2013-12-16 03:53:16 +00:00
|
|
|
logger.debug(JSON.stringify({
|
|
|
|
|
original_fpfile : original_fpfile,
|
|
|
|
|
cropped_fpfile : cropped_fpfile,
|
2014-02-06 16:31:52 +00:00
|
|
|
cropped_large_fpfile : cropped_large_fpfile,
|
2013-12-16 03:53:16 +00:00
|
|
|
crop_selection : crop_selection
|
|
|
|
|
}));
|
|
|
|
|
|
2013-05-31 02:07:33 +00:00
|
|
|
var url = "/api/users/" + id + "/avatar";
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData:false,
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
original_fpfile : original_fpfile,
|
|
|
|
|
cropped_fpfile : cropped_fpfile,
|
2014-02-06 16:31:52 +00:00
|
|
|
cropped_large_fpfile : cropped_large_fpfile,
|
2013-05-31 02:07:33 +00:00
|
|
|
crop_selection : crop_selection
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-05-23 13:53:37 +00:00
|
|
|
|
2013-05-31 02:07:33 +00:00
|
|
|
function deleteAvatar(options) {
|
|
|
|
|
var id = getId(options);
|
2013-05-23 13:53:37 +00:00
|
|
|
|
2013-05-31 02:07:33 +00:00
|
|
|
var url = "/api/users/" + id + "/avatar";
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getFilepickerPolicy(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
var handle = options && options["handle"];
|
|
|
|
|
var convert = options && options["convert"]
|
|
|
|
|
|
|
|
|
|
var url = "/api/users/" + id + "/filepicker_policy";
|
|
|
|
|
|
|
|
|
|
return $.ajax(url, {
|
|
|
|
|
data : { handle : handle, convert: convert },
|
2013-05-23 13:53:37 +00:00
|
|
|
dataType : 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 21:27:11 +00:00
|
|
|
function updateBandPhoto(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
|
|
|
|
|
var original_fpfile = options['original_fpfile'];
|
|
|
|
|
var cropped_fpfile = options['cropped_fpfile'];
|
2014-02-06 16:31:52 +00:00
|
|
|
var cropped_large_fpfile = options['cropped_large_fpfile'];
|
2013-12-15 21:27:11 +00:00
|
|
|
var crop_selection = options['crop_selection'];
|
|
|
|
|
|
2013-12-16 03:53:16 +00:00
|
|
|
logger.debug(JSON.stringify({
|
|
|
|
|
original_fpfile : original_fpfile,
|
|
|
|
|
cropped_fpfile : cropped_fpfile,
|
2014-02-06 16:31:52 +00:00
|
|
|
cropped_large_fpfile : cropped_large_fpfile,
|
2013-12-16 03:53:16 +00:00
|
|
|
crop_selection : crop_selection
|
|
|
|
|
}));
|
|
|
|
|
|
2013-12-15 21:27:11 +00:00
|
|
|
var url = "/api/bands/" + id + "/photo";
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData:false,
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
original_fpfile : original_fpfile,
|
|
|
|
|
cropped_fpfile : cropped_fpfile,
|
2014-02-06 16:31:52 +00:00
|
|
|
cropped_large_fpfile : cropped_large_fpfile,
|
2013-12-15 21:27:11 +00:00
|
|
|
crop_selection : crop_selection
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteBandPhoto(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
|
|
|
|
|
var url = "/api/bands/" + id + "/photo";
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: url,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getBandPhotoFilepickerPolicy(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
var handle = options && options["handle"];
|
|
|
|
|
var convert = options && options["convert"]
|
|
|
|
|
|
|
|
|
|
var url = "/api/bands/" + id + "/filepicker_policy";
|
|
|
|
|
|
|
|
|
|
return $.ajax(url, {
|
|
|
|
|
data : { handle : handle, convert: convert },
|
|
|
|
|
dataType : 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-05 04:11:57 +00:00
|
|
|
function getFriends(options) {
|
|
|
|
|
var id = getId(options);
|
2014-01-07 23:30:23 +00:00
|
|
|
return $.ajax({
|
2013-06-05 04:11:57 +00:00
|
|
|
type: "GET",
|
|
|
|
|
url: '/api/users/' + id + '/friends',
|
|
|
|
|
dataType: 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-07 23:30:23 +00:00
|
|
|
function removeFriend(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
var friendId = options["friend_id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: "/api/users/" + id + "/friends/" + friendId,
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 07:28:35 +00:00
|
|
|
/** NOTE: This is only for Musician, Fan, and Band Likes. Recording and
|
|
|
|
|
Session Likes have their own section below since unauthenticated users
|
|
|
|
|
are allowed to Like these entities.
|
|
|
|
|
*/
|
|
|
|
|
function addLike(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
2014-02-16 18:06:36 +00:00
|
|
|
url: "/api/users/" + id + "/likings",
|
2014-02-16 07:28:35 +00:00
|
|
|
data: JSON.stringify(options),
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-24 06:10:09 +00:00
|
|
|
function removeLike(likableId, options) {
|
2014-02-16 18:06:36 +00:00
|
|
|
var id = getId(options);
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/" + id + "/likings",
|
|
|
|
|
data: JSON.stringify(options),
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
2014-02-16 07:28:35 +00:00
|
|
|
}
|
|
|
|
|
|
2014-01-07 23:30:23 +00:00
|
|
|
function addFollowing(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/" + id + "/followings",
|
|
|
|
|
data: JSON.stringify(options),
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-24 06:10:09 +00:00
|
|
|
function removeFollowing(followableId, options) {
|
2014-01-07 23:30:23 +00:00
|
|
|
var id = getId(options);
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
2014-02-24 06:10:09 +00:00
|
|
|
url: "/api/users/" + id + "/followings/" + followableId,
|
2014-01-07 23:30:23 +00:00
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getFollowings(options) {
|
|
|
|
|
var userId = getId(options);
|
|
|
|
|
|
|
|
|
|
// FOLLOWINGS (USERS)
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: "/api/users/" + userId + "/followings",
|
|
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getFollowers(options) {
|
|
|
|
|
var userId = getId(options);
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: "/api/users/" + userId + "/followers",
|
|
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getBands(options) {
|
|
|
|
|
var userId = getId(options);
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: "/api/users/" + userId + "/bands",
|
|
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-11-05 03:53:44 +00:00
|
|
|
|
2014-03-05 03:12:44 +00:00
|
|
|
function getBandFollowers(bandId) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
2014-03-05 03:32:04 +00:00
|
|
|
url: "/api/bands/" + bandId + "/followers",
|
2014-03-05 03:12:44 +00:00
|
|
|
processData:false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 21:40:04 +00:00
|
|
|
function getClientDownloads(options) {
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: '/api/artifacts/clients',
|
|
|
|
|
dataType: 'json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-31 13:54:11 +00:00
|
|
|
/** check if the server is alive */
|
|
|
|
|
function serverHealthCheck(options) {
|
2014-03-20 11:53:26 +00:00
|
|
|
logger.debug("serverHealthCheck")
|
2013-08-31 13:54:11 +00:00
|
|
|
return $.ajax({
|
2013-09-01 16:28:03 +00:00
|
|
|
type: "GET",
|
|
|
|
|
url: "/api/versioncheck"
|
2013-08-31 13:54:11 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-31 02:07:33 +00:00
|
|
|
function getId(options) {
|
|
|
|
|
var id = options && options["id"]
|
|
|
|
|
|
|
|
|
|
if(!id) {
|
|
|
|
|
id = context.JK.currentUserId;
|
|
|
|
|
}
|
2014-01-07 23:30:23 +00:00
|
|
|
else {
|
|
|
|
|
delete options["id"];
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-31 02:07:33 +00:00
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 03:29:03 +00:00
|
|
|
function createEmailInvitations(emails, message) {
|
2013-07-31 02:10:36 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/invited_users',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData:false,
|
|
|
|
|
data: JSON.stringify({
|
2014-02-25 03:29:03 +00:00
|
|
|
emails : emails,
|
2013-07-31 02:10:36 +00:00
|
|
|
note: message
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-10 23:37:03 +00:00
|
|
|
function postFeedback(email, body) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/feedback',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData:false,
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
email : email,
|
|
|
|
|
body: body
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 06:09:44 +00:00
|
|
|
function getFeeds(options) {
|
|
|
|
|
if(!options) { options = {}; }
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: "/api/feeds?" + $.param(options),
|
|
|
|
|
processData:false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-16 07:28:35 +00:00
|
|
|
function sendFriendRequest(app, userId, callback) {
|
|
|
|
|
var url = "/api/users/" + context.JK.currentUserId + "/friend_requests";
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: url,
|
|
|
|
|
data: '{"friend_id":"' + userId + '"}',
|
|
|
|
|
processData: false,
|
|
|
|
|
success: function(response) {
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback(userId);
|
|
|
|
|
}
|
|
|
|
|
context.JK.GA.trackFriendConnect(context.JK.GA.FriendConnectTypes.request);
|
|
|
|
|
},
|
|
|
|
|
error: app.ajaxError
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-25 15:29:08 +00:00
|
|
|
function getFriendRequest(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
var friendRequestId = options["friend_request_id"];
|
|
|
|
|
|
|
|
|
|
var deferred = $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/" + id + "/friend_requests/" + friendRequestId,
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return deferred;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-27 21:39:51 +00:00
|
|
|
function acceptFriendRequest(options) {
|
|
|
|
|
var id = getId(options);
|
2014-03-25 15:29:08 +00:00
|
|
|
var friendRequestId = options["friend_request_id"];
|
2013-09-27 21:39:51 +00:00
|
|
|
var status = options["status"];
|
|
|
|
|
|
|
|
|
|
var friend_request = { status: status };
|
|
|
|
|
|
|
|
|
|
var deferred = $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
2014-03-25 15:29:08 +00:00
|
|
|
url: "/api/users/" + id + "/friend_requests/" + friendRequestId,
|
2013-09-27 21:39:51 +00:00
|
|
|
data: JSON.stringify(friend_request),
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
deferred.done(function() {
|
|
|
|
|
context.JK.GA.trackFriendConnect(context.JK.GA.FriendConnectTypes.accept);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return deferred;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-30 02:37:22 +00:00
|
|
|
function userDownloadedClient(options) {
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/progression/downloaded_client",
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function userCertifiedGear(options) {
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/progression/certified_gear",
|
|
|
|
|
processData: false,
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
success: options.success,
|
|
|
|
|
reason: options.reason
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function userSocialPromoted(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/progression/social_promoted",
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-26 17:33:28 +00:00
|
|
|
function signout() {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/signout',
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-21 22:13:53 +00:00
|
|
|
function updateUser(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
|
|
|
|
|
delete options['id'];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/" + id,
|
|
|
|
|
data: JSON.stringify(options),
|
|
|
|
|
processData: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 20:55:55 +00:00
|
|
|
function startRecording(options) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/recordings/start",
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stopRecording(options) {
|
|
|
|
|
var recordingId = options["id"]
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/recordings/" + recordingId + "/stop",
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getRecording(options) {
|
|
|
|
|
var recordingId = options["id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/recordings/" + recordingId
|
2014-01-05 03:47:23 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getClaimedRecordings(options) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/claimed_recordings",
|
|
|
|
|
data: options
|
|
|
|
|
});
|
2013-11-03 20:55:55 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-02 23:14:47 +00:00
|
|
|
function getClaimedRecording(id) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/claimed_recordings/" + id
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-30 18:34:15 +00:00
|
|
|
function claimRecording(options) {
|
|
|
|
|
var recordingId = options["id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/recordings/" + recordingId + "/claim",
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-05 03:47:23 +00:00
|
|
|
function startPlayClaimedRecording(options) {
|
|
|
|
|
var musicSessionId = options["id"];
|
|
|
|
|
var claimedRecordingId = options["claimed_recording_id"];
|
|
|
|
|
delete options["id"];
|
|
|
|
|
delete options["claimed_recording_id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/sessions/" + musicSessionId + "/claimed_recording/" + claimedRecordingId + "/start",
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stopPlayClaimedRecording(options) {
|
|
|
|
|
var musicSessionId = options["id"];
|
|
|
|
|
var claimedRecordingId = options["claimed_recording_id"];
|
|
|
|
|
delete options["id"];
|
|
|
|
|
delete options["claimed_recording_id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/sessions/" + musicSessionId + "/claimed_recording/" + claimedRecordingId + "/stop",
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-30 18:34:15 +00:00
|
|
|
function discardRecording(options) {
|
|
|
|
|
var recordingId = options["id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/recordings/" + recordingId + "/discard",
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-16 04:35:40 +00:00
|
|
|
function putTrackSyncChange(options) {
|
|
|
|
|
var musicSessionId = options["id"]
|
|
|
|
|
delete options["id"];
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "PUT",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
url: '/api/sessions/' + musicSessionId + '/tracks',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
processData: false,
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-06 16:31:52 +00:00
|
|
|
function getShareSession(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
var provider = options['provider'];
|
|
|
|
|
delete options['provider']
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/" + id + "/share/session/" + provider,
|
|
|
|
|
data: options
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getShareRecording(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
var provider = options['provider'];
|
|
|
|
|
delete options['provider']
|
|
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/users/" + id + "/share/recording/" + provider,
|
|
|
|
|
data: options
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 14:07:08 +00:00
|
|
|
function tweet(options) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: "/api/twitter/tweet",
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 21:28:47 +00:00
|
|
|
function createFbInviteUrl() {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: '/api/invited_users/facebook',
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-20 11:53:26 +00:00
|
|
|
function createTextMessage(options) {
|
|
|
|
|
var id = getId(options);
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/api/users/' + id + '/notifications',
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
data: JSON.stringify(options)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getNotifications(options) {
|
2014-03-26 17:09:48 +00:00
|
|
|
if(!options) options = {};
|
2014-03-20 11:53:26 +00:00
|
|
|
var id = getId(options);
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: '/api/users/' + id + '/notifications?' + $.param(options),
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 16:30:56 +00:00
|
|
|
function createChatMessage(options) {
|
2014-04-23 12:27:49 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
2014-05-02 16:30:56 +00:00
|
|
|
url: '/api/chat?' + $.param(options),
|
2014-04-23 12:27:49 +00:00
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 16:30:56 +00:00
|
|
|
function getChatMessages(options) {
|
|
|
|
|
var musciSessionId = options["music_session"];
|
|
|
|
|
delete options["music_session"];
|
2014-04-23 12:27:49 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
2014-05-02 16:30:56 +00:00
|
|
|
url: '/api/sessions/' + musciSessionId + '/chats?' + $.param(options),
|
2014-04-23 12:27:49 +00:00
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json'
|
2014-05-05 15:50:47 +00:00
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-30 03:01:28 +00:00
|
|
|
function createDiagnostic(options) {
|
2014-05-14 20:12:42 +00:00
|
|
|
var data = null;
|
|
|
|
|
try {
|
|
|
|
|
data = JSON.stringify(options)
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
data = JSON.stringify({data_error: "unable to JSON.stringify debug data:" + e.toString()})
|
|
|
|
|
}
|
2014-04-30 03:01:28 +00:00
|
|
|
return $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/api/diagnostics',
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
2014-05-14 20:12:42 +00:00
|
|
|
data: data,
|
2014-04-23 12:27:49 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-22 16:26:56 +00:00
|
|
|
function getLatencyTester(options) {
|
|
|
|
|
return $.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: '/api/latency_testers',
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
2014-04-30 03:01:28 +00:00
|
|
|
data: JSON.stringify(options)
|
2014-04-23 12:27:49 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-17 03:54:33 +00:00
|
|
|
function initialize() {
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expose publics
|
|
|
|
|
this.initialize = initialize;
|
2014-05-06 21:17:26 +00:00
|
|
|
this.legacyCreateSession = legacyCreateSession;
|
2014-05-06 22:50:41 +00:00
|
|
|
this.legacyJoinSession = legacyJoinSession;
|
2014-05-20 13:26:32 +00:00
|
|
|
this.joinSession = joinSession;
|
2013-05-17 03:54:33 +00:00
|
|
|
this.getUserDetail = getUserDetail;
|
|
|
|
|
this.getCities = getCities;
|
|
|
|
|
this.getRegions = getRegions;
|
2013-07-09 03:05:05 +00:00
|
|
|
this.getCountries = getCountries;
|
2014-03-18 03:20:41 +00:00
|
|
|
this.getCountriesx = getCountriesx;
|
2013-05-17 03:54:33 +00:00
|
|
|
this.getIsps = getIsps;
|
2013-12-09 03:31:49 +00:00
|
|
|
this.getResolvedLocation = getResolvedLocation;
|
2013-05-31 02:07:33 +00:00
|
|
|
this.getInstruments = getInstruments;
|
2013-11-23 20:06:42 +00:00
|
|
|
this.getGenres = getGenres;
|
2013-05-31 02:07:33 +00:00
|
|
|
this.updateAvatar = updateAvatar;
|
|
|
|
|
this.deleteAvatar = deleteAvatar;
|
|
|
|
|
this.getFilepickerPolicy = getFilepickerPolicy;
|
2013-06-05 04:11:57 +00:00
|
|
|
this.getFriends = getFriends;
|
2014-01-07 23:30:23 +00:00
|
|
|
this.removeFriend = removeFriend;
|
2014-02-16 07:28:35 +00:00
|
|
|
this.addLike = addLike;
|
|
|
|
|
this.removeLike = removeLike;
|
2014-01-07 23:30:23 +00:00
|
|
|
this.addFollowing = addFollowing;
|
|
|
|
|
this.removeFollowing = removeFollowing;
|
|
|
|
|
this.getFollowings = getFollowings;
|
|
|
|
|
this.getFollowers = getFollowers;
|
|
|
|
|
this.getBands = getBands;
|
2014-03-05 03:12:44 +00:00
|
|
|
this.getBandFollowers = getBandFollowers;
|
2014-03-07 20:20:34 +00:00
|
|
|
this.findSessions = findSessions;
|
2014-06-01 18:45:17 +00:00
|
|
|
this.findScheduledSessions = findScheduledSessions;
|
2014-03-07 20:20:34 +00:00
|
|
|
this.findScoredSessions = findScoredSessions;
|
2013-06-10 02:12:43 +00:00
|
|
|
this.updateSession = updateSession;
|
2014-02-02 23:14:47 +00:00
|
|
|
this.getSessionHistory = getSessionHistory;
|
2014-01-28 07:35:35 +00:00
|
|
|
this.addSessionComment = addSessionComment;
|
2014-05-27 03:52:59 +00:00
|
|
|
this.addSessionInfoComment = addSessionInfoComment;
|
2014-01-28 07:35:35 +00:00
|
|
|
this.addSessionLike = addSessionLike;
|
2014-05-29 06:33:37 +00:00
|
|
|
this.getRsvpRequests = getRsvpRequests;
|
2014-05-28 05:14:14 +00:00
|
|
|
this.submitRsvpRequest = submitRsvpRequest;
|
2014-05-29 06:33:37 +00:00
|
|
|
this.cancelRsvpRequest = cancelRsvpRequest;
|
2014-05-28 05:14:14 +00:00
|
|
|
this.getOpenSessionSlots = getOpenSessionSlots;
|
2014-01-28 07:35:35 +00:00
|
|
|
this.addRecordingComment = addRecordingComment;
|
|
|
|
|
this.addRecordingLike = addRecordingLike;
|
2014-03-07 06:46:07 +00:00
|
|
|
this.addPlayablePlay = addPlayablePlay;
|
2013-10-03 07:16:27 +00:00
|
|
|
this.getSession = getSession;
|
2014-01-05 03:47:23 +00:00
|
|
|
this.getClientDownloads = getClientDownloads;
|
2014-02-25 03:29:03 +00:00
|
|
|
this.createEmailInvitations = createEmailInvitations;
|
2013-08-10 23:37:03 +00:00
|
|
|
this.postFeedback = postFeedback;
|
2014-03-11 06:09:44 +00:00
|
|
|
this.getFeeds = getFeeds;
|
2013-08-31 13:54:11 +00:00
|
|
|
this.serverHealthCheck = serverHealthCheck;
|
2014-02-16 07:28:35 +00:00
|
|
|
this.sendFriendRequest = sendFriendRequest;
|
2014-03-25 15:29:08 +00:00
|
|
|
this.getFriendRequest = getFriendRequest;
|
2013-09-27 21:39:51 +00:00
|
|
|
this.acceptFriendRequest = acceptFriendRequest;
|
2013-09-26 17:33:28 +00:00
|
|
|
this.signout = signout;
|
2013-09-30 02:37:22 +00:00
|
|
|
this.userDownloadedClient = userDownloadedClient;
|
|
|
|
|
this.userCertifiedGear = userCertifiedGear;
|
|
|
|
|
this.userSocialPromoted = userSocialPromoted;
|
2013-10-16 07:23:43 +00:00
|
|
|
this.createJoinRequest = createJoinRequest;
|
|
|
|
|
this.updateJoinRequest = updateJoinRequest;
|
2013-10-21 22:13:53 +00:00
|
|
|
this.updateUser = updateUser;
|
2013-11-03 20:55:55 +00:00
|
|
|
this.startRecording = startRecording;
|
|
|
|
|
this.stopRecording = stopRecording;
|
|
|
|
|
this.getRecording = getRecording;
|
2014-01-05 03:47:23 +00:00
|
|
|
this.getClaimedRecordings = getClaimedRecordings;
|
2014-02-02 23:14:47 +00:00
|
|
|
this.getClaimedRecording = getClaimedRecording;
|
2013-12-30 18:34:15 +00:00
|
|
|
this.claimRecording = claimRecording;
|
2014-01-05 03:47:23 +00:00
|
|
|
this.startPlayClaimedRecording = startPlayClaimedRecording;
|
|
|
|
|
this.stopPlayClaimedRecording = stopPlayClaimedRecording;
|
2013-12-30 18:34:15 +00:00
|
|
|
this.discardRecording = discardRecording;
|
2013-11-16 04:35:40 +00:00
|
|
|
this.putTrackSyncChange = putTrackSyncChange;
|
2013-11-23 20:06:42 +00:00
|
|
|
this.createBand = createBand;
|
|
|
|
|
this.updateBand = updateBand;
|
2013-12-15 21:27:11 +00:00
|
|
|
this.updateBandPhoto = updateBandPhoto;
|
|
|
|
|
this.deleteBandPhoto = deleteBandPhoto;
|
|
|
|
|
this.getBandPhotoFilepickerPolicy = getBandPhotoFilepickerPolicy;
|
2013-12-01 20:09:44 +00:00
|
|
|
this.getBand = getBand;
|
2014-02-19 22:56:13 +00:00
|
|
|
this.validateBand = validateBand;
|
2014-02-20 22:23:44 +00:00
|
|
|
this.updateFavorite = updateFavorite;
|
2013-11-23 20:06:42 +00:00
|
|
|
this.createBandInvitation = createBandInvitation;
|
|
|
|
|
this.updateBandInvitation = updateBandInvitation;
|
2013-12-08 01:45:24 +00:00
|
|
|
this.removeBandMember = removeBandMember;
|
2014-03-05 03:12:44 +00:00
|
|
|
this.getBandMembers = getBandMembers;
|
2014-02-04 02:45:52 +00:00
|
|
|
this.login = login;
|
2014-02-06 16:31:52 +00:00
|
|
|
this.getShareSession = getShareSession;
|
|
|
|
|
this.getShareRecording = getShareRecording;
|
2014-02-07 14:07:08 +00:00
|
|
|
this.tweet = tweet;
|
2014-02-07 21:28:47 +00:00
|
|
|
this.createFbInviteUrl = createFbInviteUrl;
|
2014-03-20 11:53:26 +00:00
|
|
|
this.createTextMessage = createTextMessage;
|
|
|
|
|
this.getNotifications = getNotifications;
|
2014-04-23 12:27:49 +00:00
|
|
|
this.createChatMessage = createChatMessage;
|
|
|
|
|
this.getChatMessages = getChatMessages;
|
2014-04-30 03:01:28 +00:00
|
|
|
this.createDiagnostic = createDiagnostic;
|
2014-05-22 16:26:56 +00:00
|
|
|
this.getLatencyTester = getLatencyTester;
|
2013-05-17 03:54:33 +00:00
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2013-06-10 02:12:43 +00:00
|
|
|
})(window,jQuery);
|