/**
         * Get all the details of a contact according to its id
         *
         * @param contact  id to search for
         * @param callback called for return
         * @since v2.0
         */
        public void GetContact(ContactUid contact, IContactResultCallback callback)
        {
            // Start logging elapsed time.
            long     tIn    = TimerUtil.CurrentTimeMillis();
            ILogging logger = AppRegistryBridge.GetInstance().GetLoggingBridge();

            if (logger != null)
            {
                logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "ContactBridge executing getContact...");
            }

            if (this._delegate != null)
            {
                this._delegate.GetContact(contact, callback);
                if (logger != null)
                {
                    logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "ContactBridge executed 'getContact' in " + (TimerUtil.CurrentTimeMillis() - tIn) + "ms.");
                }
            }
            else
            {
                if (logger != null)
                {
                    logger.Log(ILoggingLogLevel.Error, this.apiGroup.ToString(), "ContactBridge no delegate for 'getContact'.");
                }
            }
        }
        /**
         * Set the contact photo
         *
         * @param contact  id to assign the photo
         * @param pngImage photo as byte array
         * @return true if set is successful;false otherwise
         * @since v2.0
         */
        public bool SetContactPhoto(ContactUid contact, byte[] pngImage)
        {
            // Start logging elapsed time.
            long     tIn    = TimerUtil.CurrentTimeMillis();
            ILogging logger = AppRegistryBridge.GetInstance().GetLoggingBridge();

            if (logger != null)
            {
                logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "ContactBridge executing setContactPhoto...");
            }

            bool result = false;

            if (this._delegate != null)
            {
                result = this._delegate.SetContactPhoto(contact, pngImage);
                if (logger != null)
                {
                    logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "ContactBridge executed 'setContactPhoto' in " + (TimerUtil.CurrentTimeMillis() - tIn) + "ms.");
                }
            }
            else
            {
                if (logger != null)
                {
                    logger.Log(ILoggingLogLevel.Error, this.apiGroup.ToString(), "ContactBridge no delegate for 'setContactPhoto'.");
                }
            }
            return(result);
        }
        /**
         * Invokes the given method specified in the API request object.
         *
         * @param request APIRequest object containing method name and parameters.
         * @return APIResponse with status code, message and JSON response or a JSON null string for void functions. Status code 200 is OK, all others are HTTP standard error conditions.
         */
        public new APIResponse Invoke(APIRequest request)
        {
            APIResponse response        = new APIResponse();
            int         responseCode    = 200;
            String      responseMessage = "OK";
            String      responseJSON    = "null";

            switch (request.GetMethodName())
            {
            case "getContact":
                ContactUid             contact0  = GetJSONProcessor().DeserializeObject <ContactUid>(request.GetParameters()[0]);
                IContactResultCallback callback0 = new ContactResultCallbackImpl(request.GetAsyncId());
                this.GetContact(contact0, callback0);
                break;

            case "getContactPhoto":
                ContactUid contact1 = GetJSONProcessor().DeserializeObject <ContactUid>(request.GetParameters()[0]);
                IContactPhotoResultCallback callback1 = new ContactPhotoResultCallbackImpl(request.GetAsyncId());
                this.GetContactPhoto(contact1, callback1);
                break;

            case "getContacts":
                IContactResultCallback callback2 = new ContactResultCallbackImpl(request.GetAsyncId());
                this.GetContacts(callback2);
                break;

            case "getContactsForFields":
                IContactResultCallback callback3 = new ContactResultCallbackImpl(request.GetAsyncId());
                IContactFieldGroup[]   fields3   = GetJSONProcessor().DeserializeObject <IContactFieldGroup[]>(request.GetParameters()[1]);
                this.GetContactsForFields(callback3, fields3);
                break;

            case "getContactsWithFilter":
                IContactResultCallback callback4 = new ContactResultCallbackImpl(request.GetAsyncId());
                IContactFieldGroup[]   fields4   = GetJSONProcessor().DeserializeObject <IContactFieldGroup[]>(request.GetParameters()[1]);
                IContactFilter[]       filter4   = GetJSONProcessor().DeserializeObject <IContactFilter[]>(request.GetParameters()[2]);
                this.GetContactsWithFilter(callback4, fields4, filter4);
                break;

            case "searchContacts":
                string term5 = GetJSONProcessor().DeserializeObject <string>(request.GetParameters()[0]);
                IContactResultCallback callback5 = new ContactResultCallbackImpl(request.GetAsyncId());
                this.SearchContacts(term5, callback5);
                break;

            case "searchContactsWithFilter":
                string term6 = GetJSONProcessor().DeserializeObject <string>(request.GetParameters()[0]);
                IContactResultCallback callback6 = new ContactResultCallbackImpl(request.GetAsyncId());
                IContactFilter[]       filter6   = GetJSONProcessor().DeserializeObject <IContactFilter[]>(request.GetParameters()[2]);
                this.SearchContactsWithFilter(term6, callback6, filter6);
                break;

            case "setContactPhoto":
                ContactUid contact7  = GetJSONProcessor().DeserializeObject <ContactUid>(request.GetParameters()[0]);
                byte[]     pngImage7 = GetJSONProcessor().DeserializeObject <byte[]>(request.GetParameters()[1]);
                bool       response7 = this.SetContactPhoto(contact7, pngImage7);
                responseJSON = GetJSONProcessor().SerializeObject(response7);
                break;

            default:
                // 404 - response null.
                responseCode    = 404;
                responseMessage = "ContactBridge does not provide the function '" + request.GetMethodName() + "' Please check your client-side API version; should be API version >= v2.2.15.";
                break;
            }
            response.SetResponse(responseJSON);
            response.SetStatusCode(responseCode);
            response.SetStatusMessage(responseMessage);
            return(response);
        }