Exemplo n.º 1
0
 public async Task <TransformResult> CreateTransformAsync(CreateTransformParams parameters)
 {
     using (var response = await Api.CallAsync(HttpMethod.Post, Api.ApiUrlV.ResourceType("transformations").Add(parameters.Name).BuildUrl(), parameters.ToParamsDictionary(), null, null))
     {
         return(await TransformResult.Parse(response));
     }
 }
        public void TestDeleteTransform()
        {
            // should allow deleting named transformation
            string transformationName = GetUniqueTransformationName();

            m_cloudinary.DeleteTransform(transformationName);

            CreateTransformParams create = new CreateTransformParams()
            {
                Name      = transformationName,
                Transform = m_simpleTransformation
            };

            TransformResult createResult = m_cloudinary.CreateTransform(create);

            Assert.AreEqual("created", createResult.Message);

            m_cloudinary.DeleteTransform(transformationName);

            GetTransformResult getResult = m_cloudinary.GetTransform(
                new GetTransformParams()
            {
                Transformation = transformationName
            });

            Assert.AreEqual(HttpStatusCode.NotFound, getResult.StatusCode);
        }
Exemplo n.º 3
0
        public void TestCreateTransform()
        {
            // should allow creating named transformation

            CreateTransformParams create = new CreateTransformParams()
            {
                Name      = GetUniqueTransformationName(),
                Transform = m_simpleTransformation
            };

            m_cloudinary.CreateTransform(create);

            GetTransformParams get = new GetTransformParams()
            {
                Transformation = create.Name
            };

            GetTransformResult getResult = m_cloudinary.GetTransform(get);

            Assert.IsNotNull(getResult);
            Assert.AreEqual(true, getResult.Strict);
            Assert.AreEqual(false, getResult.Used);
            Assert.AreEqual(1, getResult.Info.Length);
            Assert.AreEqual(m_simpleTransformation.Generate(), new Transformation(getResult.Info[0]).Generate());
        }
Exemplo n.º 4
0
        public void TestDeleteTransform()
        {
            // should allow deleting named transformation

            m_cloudinary.DeleteTransform("api_test_transformation2");

            CreateTransformParams create = new CreateTransformParams()
            {
                Name      = "api_test_transformation2",
                Transform = new Transformation().Crop("scale").Width(103)
            };

            TransformResult createResult = m_cloudinary.CreateTransform(create);

            Assert.AreEqual("created", createResult.Message);

            m_cloudinary.DeleteTransform("api_test_transformation2");

            GetTransformResult getResult = m_cloudinary.GetTransform(
                new GetTransformParams()
            {
                Transformation = "api_test_transformation2"
            });

            Assert.AreEqual(HttpStatusCode.NotFound, getResult.StatusCode);
        }
Exemplo n.º 5
0
        public void TestCreateTransform()
        {
            // should allow creating named transformation

            Transformation t = new Transformation().Crop("scale").Width(102);

            CreateTransformParams create = new CreateTransformParams()
            {
                Name      = "api_test_transformation",
                Transform = t
            };

            m_cloudinary.CreateTransform(create);

            GetTransformParams get = new GetTransformParams()
            {
                Transformation = create.Name
            };

            GetTransformResult getResult = m_cloudinary.GetTransform(get);

            Assert.IsNotNull(getResult);
            Assert.AreEqual(true, getResult.Strict);
            Assert.AreEqual(false, getResult.Used);
            Assert.AreEqual(1, getResult.Info.Length);
            Assert.AreEqual(t.Generate(), new Transformation(getResult.Info[0]).Generate());
        }
        public void TestCreateTransformParamsCheck()
        {
            var p = new CreateTransformParams();

            Assert.Throws <ArgumentException>(p.Check, "Should require Name");
            p.Name = "some_name";
            Assert.Throws <ArgumentException>(p.Check, "Should require Transformation");
        }
Exemplo n.º 7
0
        public TransformResult CreateTransform(CreateTransformParams parameters)
        {
            UrlBuilder urlBuilder = new UrlBuilder(
                m_api.ApiUrlV.
                ResourceType("transformations").
                Add(parameters.Name).
                BuildUrl());

            urlBuilder.QueryString["transformation"] = parameters.Transform.Generate();

            using (HttpWebResponse response = m_api.Call(
                       HttpMethod.POST, urlBuilder.ToString(), null, null))
            {
                TransformResult result = TransformResult.Parse(response);
                return(result);
            }
        }
 public Task <TransformResult> CreateTransformAsync(CreateTransformParams parameters)
 {
     return(CallAsync(CreateTransform, parameters));
 }
 public static TransformResult CreateTransform(this Cloudinary cloudinary, CreateTransformParams parameters)
 {
     return(cloudinary.CreateTransformAsync(parameters).ExecSync());
 }