Esempio n. 1
0
        public void DecrementIntValueTest()
        {
            //first, let's obtain a random object. we record the old int value and the object id
            var objInt = Data.ListDataObjects(auth, new ListDataObjectsModel {
                ShowAll = true
            }).DataObjects[0];
            int  oldInt = objInt.IntValue;
            long Id     = objInt.Id;

            var keydata = new ChangeIntValueModel()
            {
                IntValue = 10, Id = Id
            };

            var result = Data.DecrementIntValue(auth, keydata);

            if (result != null && result.Result == ResultType.Success)
            {
                int objIntNew = Data.ListDataObjects(auth, new ListDataObjectsModel {
                    ShowAll = true
                }).DataObjects[0].IntValue;
                Assert.IsTrue(objIntNew == oldInt - 10);
            }
            else
            {
                Assert.Fail();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the <see cref="IntValue"/> to a new value (in SKM Platform).
        /// </summary>
        /// <param name="token">The access token. Read more at https://serialkeymanager.com/docs/api/v3/Auth </param>
        /// <param name="value">The new int value</param>
        /// <remarks>Note: for more details, please see
        /// <a href="https://serialkeymanager.com/docs/api/v3/SetIntValue">https://serialkeymanager.com/docs/api/v3/SetIntValue</a> <br/>
        /// Note also: Integer overflows are not allowed. If you attempt to assign an int value that is beyond the limits of an int32, zero will be assigned to the data object's IntValue.</remarks>
        /// <returns>Returns <see cref="ListOfDataObjectsResult"/> or null.</returns>
        public bool SetIntValue(string token, int value)
        {
            var parameters = new ChangeIntValueModel
            {
                Id       = Id,
                IntValue = value
            };

            var result = Data.SetIntValue(token, parameters);

            if (result != null && result.Result == ResultType.Success)
            {
                IntValue = value;
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Decrements the <see cref="IntValue"/> by a given amount. (in SKM Platform).
        /// </summary>
        /// <param name="token">The access token. Read more at https://serialkeymanager.com/docs/api/v3/Auth </param>
        /// <param name="decrementValue">The number we should decrement by.</param>
        /// <param name="enableBound">
        /// If set to true, it will be possible to specify an lower bound.
        /// (for Decrement Int Value) For example, if you set the <paramref name="lowerBound"/> parameter (below) to 0,
        /// you will be able to decrement the int value until you reach zero (inclusive).
        /// Once the lower bound is reached, an error will be thrown.
        /// </param>
        /// <param name="lowerBound">The upper bound. It only works if <paramref name="enableBound"/> is set to true.</param>
        /// <remarks>Note: for more details, please see
        /// <a href="https://serialkeymanager.com/docs/api/v3/IncrementIntValue">https://serialkeymanager.com/docs/api/v3/IncrementIntValue</a> <br/>
        /// </remarks>
        /// <returns>Returns true if successful or false otherwise.</returns>
        public bool DecrementIntValue(string token, int decrementValue, bool enableBound = false, int lowerBound = 0)
        {
            var parameters = new ChangeIntValueModel
            {
                Id          = Id,
                IntValue    = decrementValue,
                EnableBound = enableBound,
                Bound       = lowerBound
            };

            var result = Data.DecrementIntValue(token, parameters);

            if (result != null && result.Result == ResultType.Success)
            {
                IntValue -= decrementValue;
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
 /// <summary>
 /// This method will decrement the current int value by the one specified as an input parameter,
 /// i.e. <see cref="ChangeIntValueModel.IntValue"/>.
 /// </summary>
 /// <param name="token">The access token. Read more at https://app.cryptolens.io/docs/api/v3/Auth </param>
 /// <param name="parameters">The parameters that the method needs</param>
 /// <remarks>Note: for more details, please see
 /// <a href="https://app.cryptolens.io/docs/api/v3/DecrementIntValue">https://app.cryptolens.io/docs/api/v3/DecrementIntValue</a> <br/>
 /// </remarks>
 /// <returns>Returns <see cref="ListOfDataObjectsResult"/> or null.</returns>
 public static BasicResult DecrementIntValue(string token, ChangeIntValueModel parameters)
 {
     return(HelperMethods.SendRequestToWebAPI3 <BasicResult>(parameters, "/data/decrementintvalue/", token));
 }