Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/Proyecto26.RestClient/RestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,75 @@ public static void Put<T>(RequestHelper options, Action<RequestException, Respon
Request(options, callback);
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <param name="url">A string containing the URL to which the request is sent.</param>
/// <param name="body">A plain object that is sent to the server with the request.</param>
/// <param name="callback">A callback function that is executed when the request is finished.</param>
public static void Patch(string url, object body, Action<RequestException, ResponseHelper> callback)
{
Patch(new RequestHelper { Uri = url, Body = body }, callback);
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <param name="url">A string containing the URL to which the request is sent.</param>
/// <param name="bodyString">A string that is sent to the server with the request.</param>
/// <param name="callback">A callback function that is executed when the request is finished.</param>
public static void Patch(string url, string bodyString, Action<RequestException, ResponseHelper> callback)
{
Patch(new RequestHelper { Uri = url, BodyString = bodyString }, callback);
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <param name="options">The options of the request.</param>
/// <param name="callback">A callback function that is executed when the request is finished.</param>
public static void Patch(RequestHelper options, Action<RequestException, ResponseHelper> callback)
{
options.Method = "PATCH";
Request(options, callback);
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <param name="url">A string containing the URL to which the request is sent.</param>
/// <param name="body">A plain object that is sent to the server with the request.</param>
/// <param name="callback">A callback function that is executed when the request is finished.</param>
/// <typeparam name="T">The element type of the response.</typeparam>
public static void Patch<T>(string url, object body, Action<RequestException, ResponseHelper, T> callback)
{
Patch<T>(new RequestHelper { Uri = url, Body = body }, callback);
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <param name="url">A string containing the URL to which the request is sent.</param>
/// <param name="bodyString">A string that is sent to the server with the request.</param>
/// <param name="callback">A callback function that is executed when the request is finished.</param>
/// <typeparam name="T">The element type of the response.</typeparam>
public static void Patch<T>(string url, string bodyString, Action<RequestException, ResponseHelper, T> callback)
{
Patch<T>(new RequestHelper { Uri = url, BodyString = bodyString }, callback);
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <param name="options">The options of the request.</param>
/// <param name="callback">A callback function that is executed when the request is finished.</param>
/// <typeparam name="T">The element type of the response.</typeparam>
public static void Patch<T>(RequestHelper options, Action<RequestException, ResponseHelper, T> callback)
{
options.Method = "PATCH";
Request(options, callback);
}

/// <summary>
/// Delete the specified resource identified by the URI.
/// </summary>
Expand Down
71 changes: 71 additions & 0 deletions src/Proyecto26.RestClient/RestClientPromise.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,77 @@ public static IPromise<T> Put<T>(RequestHelper options)
return promise;
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <returns>Returns a promise for a value of type ResponseHelper.</returns>
/// <param name="url">A string containing the URL to which the request is sent.</param>
/// <param name="body">A plain object that is sent to the server with the request.</param>
public static IPromise<ResponseHelper> Patch(string url, object body)
{
return Patch(new RequestHelper { Uri = url, Body = body });
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <returns>Returns a promise for a value of type ResponseHelper.</returns>
/// <param name="url">A string containing the URL to which the request is sent.</param>
/// <param name="bodyString">A string that is sent to the server with the request.</param>
public static IPromise<ResponseHelper> Patch(string url, string bodyString)
{
return Patch(new RequestHelper { Uri = url, BodyString = bodyString });
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <returns>Returns a promise for a value of type ResponseHelper.</returns>
/// <param name="options">The options of the request.</param>
public static IPromise<ResponseHelper> Patch(RequestHelper options)
{
var promise = new Promise<ResponseHelper>();
Patch(options, promise.Promisify);
return promise;
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <returns>Returns a promise for a value of a specified type.</returns>
/// <param name="url">A string containing the URL to which the request is sent.</param>
/// <param name="body">A plain object that is sent to the server with the request.</param>
/// <typeparam name="T">The element type of the response.</typeparam>
public static IPromise<T> Patch<T>(string url, object body)
{
return Patch<T>(new RequestHelper { Uri = url, Body = body });
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <returns>Returns a promise for a value of a specified type.</returns>
/// <param name="url">A string containing the URL to which the request is sent.</param>
/// <param name="bodyString">A string that is sent to the server with the request.</param>
/// <typeparam name="T">The element type of the response.</typeparam>
public static IPromise<T> Patch<T>(string url, string bodyString)
{
return Patch<T>(new RequestHelper { Uri = url, BodyString = bodyString });
}

/// <summary>
/// Load data from the server using a HTTP PATCH request.
/// </summary>
/// <returns>Returns a promise for a value of a specified type.</returns>
/// <param name="options">The options of the request.</param>
/// <typeparam name="T">The element type of the response.</typeparam>
public static IPromise<T> Patch<T>(RequestHelper options)
{
var promise = new Promise<T>();
Patch<T>(options, promise.Promisify);
return promise;
}

/// <summary>
/// Delete the specified resource identified by the URI.
/// </summary>
Expand Down