示例#1
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        /// <param name="serverUrl">The server url for this call.</param>
        public UpdateCollectionObjectRequest(UpdateCollectionObjectRequestDesc desc, string connectAccessToken, string serverUrl)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(desc.ObjectId, "ObjectId cannot be null.");
            ReleaseAssert.IsNotNull(desc.Value, "Value cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            Key                = desc.Key;
            ObjectId           = desc.ObjectId;
            Value              = desc.Value;
            WriteLock          = desc.WriteLock;
            ConnectAccessToken = connectAccessToken;

            Url = serverUrl + "/1.0/data/collection/object/update";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
示例#2
0
        /// <summary>
        /// Updates an object in the specified collection.
        /// </summary>
        ///
        /// <param name="desc">The request description.</param>
        /// <param name="successCallback">The delegate which is called if the request was successful.</param>
        /// <param name="errorCallback">The delegate which is called if the request was unsuccessful. Provides
        /// a container with information on what went wrong.</param>
        public void UpdateCollectionObject(UpdateCollectionObjectRequestDesc desc, Action <UpdateCollectionObjectRequest, UpdateCollectionObjectResponse> successCallback, Action <UpdateCollectionObjectRequest, UpdateCollectionObjectError> errorCallback)
        {
            m_logging.LogVerboseMessage("Sending Update Collection Object request.");

            var connectAccessToken = m_dataStore.GetString("UserAccessToken");
            var request            = new UpdateCollectionObjectRequest(desc, connectAccessToken);

            m_serverRequestSystem.SendImmediateRequest(request, (IImmediateServerRequest sentRequest, ServerResponse serverResponse) =>
            {
                ReleaseAssert.IsTrue(request == sentRequest, "Received request is not the same as the one sent!");

                if (serverResponse.Result == HttpResult.Success && serverResponse.HttpResponseCode == SuccessHttpResponseCode)
                {
                    NotifyUpdateCollectionObjectSuccess(serverResponse, request, successCallback);
                }
                else
                {
                    NotifyUpdateCollectionObjectError(serverResponse, request, errorCallback);
                }
            });
        }