/* Copyright 2009 Palm, Inc.  All rights reserved. */

// act like a mojo service by taking callbacks and returning responses exactly as if the service had been invoked
// this differs from contacts-mock-service in that that one is dynamic and responds realistically, while this one
// uses static JSON responses pulled from the real service

var ContactsStaticAggregateMockService = Class.create({
    initialize: function(){
    
    },
    
    list: function(whoCares, filter, callback, offset, limit){
        var response = {};
        response.count = contactsListResponse.count;
        response.list = contactsListResponse.list.inject([], function(offset, limit, acc, c, index){
            if ((limit === 0 || acc.length < limit) && index >= offset) {
                acc.push(c);
            }
            return acc;
        }.curry(offset, limit));
        
        callback.delay(0.5, response);
    },
    
    details: function(id, callback){
        if (id == '4398046511108') {
            callback.delay(0.5, contactsDetailsResponse1);
        }
        else 
            if (id == '4398046511109') {
                callback.delay(0.5, contactsDetailsResponse2);
            }
            else {
                callback.delay(0.5, contactsDetailsResponse);
            }
    },
    
    detailPhoneNumbers: function(id, callback){
        if (id == '4398046511108') {
            callback.delay(0.5, contactsDetailPhoneNumbersResponse1);
        }
        else 
            if (id == '4398046511109') {
                callback.delay(0.5, contactsDetailPhoneNumbersResponse2);
            }
            else {
                callback.delay(0.5, contactsDetailPhoneNumbersResponse);
            }
    },
    
    detailEmails: function(id, callback){
        callback.delay(0.5, contactsDetailEmailsResponse);
    },
    
    detailIMNames: function(id, callback){
        callback.delay(0.5, contactsDetailIMNamesResponse);
    },
    
    detailAddresses: function(id, callback){
        callback.delay(0.5, contactsDetailAddressesResponse);
    },
    
    getLinkedContacts: function(id, callback){
        callback.delay(0.5, contactsGetLinkedContactsResponse);
    },
    
    markVIP: function(){
        // whatever
    },
    
    addToLauncher: function(){
        // whatever
    }
    
});
