Uses Transloadit services based on the current configuration
Inheritance: ApiRequest
Ejemplo n.º 1
0
 /// <summary>
 /// Creates then tries to proceed the specified or a default request, then executes this and gets the response of it.
 /// </summary>
 /// <param name="request">Optional request which will be tried to be executed</param>
 /// <returns>Represents the whole result of the request.
 /// Response object will be created everytime, please use its properties to get the detailed result on the request</returns>
 public TransloaditResponse RequestAndExecute(TransloaditRequest request = null)
 {
     if (request == null)
     {
         request = Request();
     }
     return((TransloaditResponse)request.Execute());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Tries to delete an assembly by the specified assembly ID.
        /// </summary>
        /// <param name="assemblyID">ID of the assembly which will be tried to be deleted</param>
        /// <returns>Represents the whole result of the request.
        /// Response object will be created everytime, please use its properties to get the detailed result on the request</returns>
        public TransloaditResponse DeleteAssembly(string assemblyID)
        {
            TransloaditRequest request = Request();

            request.Host += "/" + assemblyID;
            TransloaditResponse response = request.Execute();

            if (response.Success)
            {
                Uri uri = new Uri((string)response.Data["assembly_url"]);
                TransloaditRequest deleteRequest = Request();
                deleteRequest.Method = ApiRequestMethods.RequestMethod.Delete;
                deleteRequest.Host   = uri.Host;
                deleteRequest.Path   = uri.AbsolutePath;
                TransloaditResponse deleteResponse = request.Execute();

                return(deleteResponse);
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Tries to create the specified assembly on Transloadit. Bored instance is requested at first. If there is one, then it will
        /// be used to proceed the request, which can be completed on a bored instance.
        /// </summary>
        /// <param name="assembly">Specified assembly which will be tried to be created.
        /// Please use TransloaditAssemblyBuilder to create a new assembly</param>
        /// <returns>Represents the whole result of the request.
        /// Response object will be created everytime, please use its properties to get the detailed result on the request</returns>
        public TransloaditResponse InvokeAssembly(IAssemblyBuilder assembly)
        {
            TransloaditRequest request = Request();

            assembly.SetAuthKey(Key);

            request.Method = ApiRequestMethods.RequestMethod.Get;
            request.Path   = TransloaditRequest.BoredInstancePath;

            TransloaditResponse boredInstance = (TransloaditResponse)RequestAndExecute(request);

            string host = request.Host;

            if (boredInstance.Success)
            {
                host = (string)boredInstance.Data["api2_host"];
            }

            TransloaditRequest invokeRequest = Request();

            invokeRequest.Host   = host;
            invokeRequest.Method = ApiRequestMethods.RequestMethod.Post;
            invokeRequest.Path   = TransloaditRequest.AssemblyRoot;

            DateTime expirationDateTime = DateTime.UtcNow;

            double expirationMinutes = 120;

            expirationDateTime = expirationDateTime.AddMinutes(expirationMinutes);
            assembly.SetAuthExpires(expirationDateTime);

            string paramValue     = (string)assembly.ToJsonString();
            string signatureValue = GetSignature(paramValue);

            invokeRequest.Data = assembly.ToApiData();
            invokeRequest.Data.Fields.Add("signature", signatureValue);

            return(invokeRequest.Execute());
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates then tries to proceed the specified or a default request, then executes this and gets the response of it.
 /// </summary>
 /// <param name="request">Optional request which will be tried to be executed</param>
 /// <returns>Represents the whole result of the request. 
 /// Response object will be created everytime, please use its properties to get the detailed result on the request</returns>
 public TransloaditResponse RequestAndExecute(TransloaditRequest request = null)
 {
     if (request == null)
     {
         request = Request();
     }
     return (TransloaditResponse)request.Execute();
 }