function Model () {
}
Model.prototype = {
    request: function (method, onSuccess, onError) {
        $.ajax({
            url: this.endPoint,
            type: method,
            dataType: 'json',
            data: this.data,
            success: function success (data, textStatus) {
                if (data.error) {
                    if (onError) {
                        onError(data);
                    }
                } else {
                    if (onSuccess) {
                        onSuccess(data);
                    }
                }
            },
            error: function error () {
                if (onError) {
                    onError();
                }
            }
        });
    }
};
$.each({
    'get': 'GET',
    'create': 'PUT',
    'update': 'POST',
    'remove': 'DELETE'
}, function (k, v) {
    Model.prototype[k] = function (onSuccess, onError) {
        this.request(v, onSuccess, onError);
    };
});
Model.subclass = function (className, endPoint) {
    Model[className] = function (data) {
        this.endPoint = endPoint;
        this.data = data;
        this.data.accessToken = Session.accessToken;
    };
    Model[className].prototype = new Model;
    Model[className].newFromForm = function (form) {
        var data = Bleepie.serializeForm(form);
        var model = new Model[className](data);
        return model;
    };
};

Model.subclass('Review', '/review');
Model.subclass('IgnoredGame', '/ignored');
Model.subclass('GameListItem', '/lists');
Model.subclass('Comment', '/comments');
Model.subclass('SuggestedFriend', '/suggestedfriends');
Model.subclass('Follower', '/follower');
Model.subclass('Game', '/game');
