/// <summary> /// Performs a RESTful request to the Nuxeo Server. /// </summary> /// <param name="type">The type of the request.</param> /// <param name="endpoint">The end point, following "api/v1/".</param> /// <param name="parameters">The query parameters to follow the url.</param> /// <param name="data">The JSON data to be send.</param> /// <param name="additionalHeaders">The additional request headers, besides those already specified in the client.</param> /// <param name="contentType">The type of the content to be sent.</param> /// <returns>Returns an <see cref="Entity"/> with the result from the request.</returns> public async Task <Entity> Request(RequestType type, string endpoint, QueryParams parameters = null, JToken data = null, Dictionary <string, string> additionalHeaders = null, string contentType = ContentType.JSON) { if (type == RequestType.GET) { return(await Get(UrlCombiner.Combine(RestPath, endpoint), parameters, additionalHeaders, contentType)); } else if (type == RequestType.POST) { return(await Post(UrlCombiner.Combine(RestPath, endpoint), parameters, data, additionalHeaders, contentType)); } else if (type == RequestType.PUT) { return(await Put(UrlCombiner.Combine(RestPath, endpoint), parameters, data, additionalHeaders, contentType)); } else if (type == RequestType.DELETE) { return(await Delete(UrlCombiner.Combine(RestPath, endpoint), parameters, additionalHeaders, contentType)); } else { throw new Exception("Invalid request type."); } }
/// <summary> /// Initializes a new instance of <see cref="Operation"/>. /// </summary> /// <param name="client">The client through which the operation will be executed.</param> /// <param name="id">The operation id.</param> public Operation(Client client, string id) { this.client = client; Id = id; Input = null; Parameters = null; Context = null; Endpoint = UrlCombiner.Combine(this.client.AutomationPath, Id); }