/**
         * 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 "createDatabase":
                Database database0 = GetJSONProcessor().DeserializeObject <Database>(request.GetParameters()[0]);
                IDatabaseResultCallback callback0 = new DatabaseResultCallbackImpl(request.GetAsyncId());
                this.CreateDatabase(database0, callback0);
                break;

            case "createTable":
                Database      database1                = GetJSONProcessor().DeserializeObject <Database>(request.GetParameters()[0]);
                DatabaseTable databaseTable1           = GetJSONProcessor().DeserializeObject <DatabaseTable>(request.GetParameters()[1]);
                IDatabaseTableResultCallback callback1 = new DatabaseTableResultCallbackImpl(request.GetAsyncId());
                this.CreateTable(database1, databaseTable1, callback1);
                break;

            case "deleteDatabase":
                Database database2 = GetJSONProcessor().DeserializeObject <Database>(request.GetParameters()[0]);
                IDatabaseResultCallback callback2 = new DatabaseResultCallbackImpl(request.GetAsyncId());
                this.DeleteDatabase(database2, callback2);
                break;

            case "deleteTable":
                Database      database3                = GetJSONProcessor().DeserializeObject <Database>(request.GetParameters()[0]);
                DatabaseTable databaseTable3           = GetJSONProcessor().DeserializeObject <DatabaseTable>(request.GetParameters()[1]);
                IDatabaseTableResultCallback callback3 = new DatabaseTableResultCallbackImpl(request.GetAsyncId());
                this.DeleteTable(database3, databaseTable3, callback3);
                break;

            case "executeSqlStatement":
                Database database4     = GetJSONProcessor().DeserializeObject <Database>(request.GetParameters()[0]);
                string   statement4    = GetJSONProcessor().DeserializeObject <string>(request.GetParameters()[1]);
                string[] replacements4 = GetJSONProcessor().DeserializeObject <string[]>(request.GetParameters()[2]);
                IDatabaseTableResultCallback callback4 = new DatabaseTableResultCallbackImpl(request.GetAsyncId());
                this.ExecuteSqlStatement(database4, statement4, replacements4, callback4);
                break;

            case "executeSqlTransactions":
                Database database5     = GetJSONProcessor().DeserializeObject <Database>(request.GetParameters()[0]);
                string[] statements5   = GetJSONProcessor().DeserializeObject <string[]>(request.GetParameters()[1]);
                bool     rollbackFlag5 = GetJSONProcessor().DeserializeObject <bool>(request.GetParameters()[2]);
                IDatabaseTableResultCallback callback5 = new DatabaseTableResultCallbackImpl(request.GetAsyncId());
                this.ExecuteSqlTransactions(database5, statements5, rollbackFlag5, callback5);
                break;

            case "existsDatabase":
                Database database6 = GetJSONProcessor().DeserializeObject <Database>(request.GetParameters()[0]);
                bool     response6 = this.ExistsDatabase(database6);
                responseJSON = GetJSONProcessor().SerializeObject(response6);
                break;

            case "existsTable":
                Database      database7      = GetJSONProcessor().DeserializeObject <Database>(request.GetParameters()[0]);
                DatabaseTable databaseTable7 = GetJSONProcessor().DeserializeObject <DatabaseTable>(request.GetParameters()[1]);
                bool          response7      = this.ExistsTable(database7, databaseTable7);
                responseJSON = GetJSONProcessor().SerializeObject(response7);
                break;

            default:
                // 404 - response null.
                responseCode    = 404;
                responseMessage = "DatabaseBridge 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);
        }
        /**
         * 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);
        }