Ejemplo n.º 1
0
        public void AddDataObjectToKeyTest()
        {
            var keydata = new AddDataObjectToKeyModel()
            {
                ProductId = 3941, Key = "FRQHQ-FSOSD-BWOPU-KJOWF"
            };
            var result = Data.AddDataObject(auth, keydata);

            if (result != null && result.Result == ResultType.Success)
            {
                if (result.Id == 0)
                {
                    Assert.Fail();
                }

                var removeObj = Data.RemoveDataObject(auth, new RemoveDataObjectModel {
                    Id = result.Id
                });

                if (removeObj == null || removeObj.Result == ResultType.Error)
                {
                    Assert.Fail();
                }
            }
            else
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="DataObject"/>.
        /// </summary>
        /// <param name="token">The access token. Read more at https://serialkeymanager.com/docs/api/v3/Auth </param>
        /// <param name="dataObject">The data object to add to the license key.</param>
        /// <remarks>Note: for more details, please see
        /// <a href="https://serialkeymanager.com/docs/api/v3/AddDataObject">https://serialkeymanager.com/docs/api/v3/AddDataObject</a> </remarks>
        /// <returns>Returns the id of the data object (and updates the <see cref="DataObjects"/>) if successful, or -1 otherwise.</returns>
        public long AddDataObject(string token, DataObject dataObject)
        {
            var parameters = new AddDataObjectToKeyModel
            {
                IntValue    = dataObject.IntValue,
                StringValue = dataObject.StringValue,
                Key         = this.Key,
                Name        = dataObject.Name,
                ProductId   = ProductId
            };

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

            if (result != null && result.Result == ResultType.Success)
            {
                dataObject.Id = result.Id;
                DataObjects.Add(dataObject);
                return(dataObject.Id);
            }
            return(-1);
        }
Ejemplo n.º 3
0
        public void AddDataObjectAndListToKey()
        {
            var keydata = new AddDataObjectToKeyModel {
                ProductId = 3349, Key = "LEPWV-FOTPG-MWBEO-FBFPS", Name = "test123"
            };

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

            Assert.IsTrue(result != null && result.Result == ResultType.Success);

            int id = (int)result.Id; // the new id.

            var result2 = Data.ListDataObjects(auth, new ListDataObjectsToKeyModel {
                Key = "LEPWV-FOTPG-MWBEO-FBFPS", ProductId = 3349, Contains = "test123"
            });

            Assert.IsTrue(result2 != null && result2.Result == ResultType.Success);

            Assert.IsTrue(result2.DataObjects.Count > 0);

            bool found = false;

            foreach (var item in result2.DataObjects)
            {
                if (item.Name == "test123")
                {
                    found = true;
                }
            }

            Assert.IsTrue(found);

            var result3 = Data.RemoveDataObject(auth, new RemoveDataObjectToKeyModel {
                Key = "LEPWV-FOTPG-MWBEO-FBFPS", ProductId = 3349, Id = id
            });

            Assert.IsTrue(result3 != null && result3.Result == ResultType.Success);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new <see cref="DataObject"/> for a key.
 /// </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/AddDataObject">https://app.cryptolens.io/docs/api/v3/AddDataObject</a> </remarks>
 /// <returns>Returns <see cref="DataObjectIdResult"/> or null.</returns>
 public static DataObjectIdResult AddDataObject(string token, AddDataObjectToKeyModel parameters)
 {
     return(HelperMethods.SendRequestToWebAPI3 <DataObjectIdResult>(parameters, "/data/adddataobjecttokey/", token));
 }