/// <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> /// <param name="licenseKey">The license key we should associate with this data object.</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, LicenseKey licenseKey) { var parameters = new ChangeIntValueToKeyModel { ProductId = licenseKey.ProductId, Key = licenseKey.Key, Id = Id, IntValue = value }; var result = Data.SetIntValue(token, parameters); if (result != null && result.Result == ResultType.Success) { IntValue = value; return(true); } return(false); }
/// <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> /// <param name="licenseKey">The license key we should associate with this data object.</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, LicenseKey licenseKey, bool enableBound = false, int lowerBound = 0) { var parameters = new ChangeIntValueToKeyModel { ProductId = licenseKey.ProductId, Key = licenseKey.Key, 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); }
/// <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, ChangeIntValueToKeyModel parameters) { return(HelperMethods.SendRequestToWebAPI3 <BasicResult>(parameters, "/data/decrementintvaluetokey/", token)); }