Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.utilities.rest 2.5.0 #66

Merged
merged 8 commits into from
Jan 15, 2024
Prev Previous commit
Next Next commit
feature/ Clean up redundancies (#63)
# Description

Clean up redundant code in the Rest Library:

* Unnecessary #if UNITY statements (identical code)
* Remove Obsolete functions (actually caused duplicate signature issues)

---------

Co-authored-by: Stephen Hodgson <[email protected]>
  • Loading branch information
SimonDarksideJ and StephenHodgson authored Jan 15, 2024
commit b82d7cbd238df52b1a84790eee471e19fa1e9b58
24 changes: 0 additions & 24 deletions Utilities.Rest/Packages/com.utilities.rest/Runtime/Rest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ public static async Task<Response> PostAsync(
RestParameters parameters = null,
CancellationToken cancellationToken = default)
{
#if UNITY_2022_2_OR_NEWER
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#else
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#endif
return await webRequest.SendAsync(parameters, cancellationToken);
}

Expand Down Expand Up @@ -172,11 +168,7 @@ public static async Task<Response> PostAsync(
RestParameters parameters = null,
CancellationToken cancellationToken = default)
{
#if UNITY_2022_2_OR_NEWER
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#else
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#endif
var data = new UTF8Encoding().GetBytes(jsonData);
using var uploadHandler = new UploadHandlerRaw(data);
webRequest.uploadHandler = uploadHandler;
Expand All @@ -202,11 +194,7 @@ public static async Task<Response> PostAsync(
RestParameters parameters = null,
CancellationToken cancellationToken = default)
{
#if UNITY_2022_2_OR_NEWER
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#else
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#endif
var data = new UTF8Encoding().GetBytes(jsonData);
using var uploadHandler = new UploadHandlerRaw(data);
webRequest.uploadHandler = uploadHandler;
Expand Down Expand Up @@ -234,11 +222,7 @@ public static async Task<Response> PostAsync(
RestParameters parameters = null,
CancellationToken cancellationToken = default)
{
#if UNITY_2022_2_OR_NEWER
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#else
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#endif
var data = new UTF8Encoding().GetBytes(jsonData);
using var uploadHandler = new UploadHandlerRaw(data);
webRequest.uploadHandler = uploadHandler;
Expand Down Expand Up @@ -273,11 +257,7 @@ public static async Task<Response> PostAsync(
RestParameters parameters = null,
CancellationToken cancellationToken = default)
{
#if UNITY_2022_2_OR_NEWER
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#else
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#endif
using var uploadHandler = new UploadHandlerRaw(bodyData);
webRequest.uploadHandler = uploadHandler;
using var downloadHandler = new DownloadHandlerBuffer();
Expand All @@ -300,11 +280,7 @@ public static async Task<Response> PostAsync(
RestParameters parameters = null,
CancellationToken cancellationToken = default)
{
#if UNITY_2022_2_OR_NEWER
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#else
using var webRequest = new UnityWebRequest(query, UnityWebRequest.kHttpVerbPOST);
#endif
var boundary = UnityWebRequest.GenerateBoundary();
var formSections = UnityWebRequest.SerializeFormSections(form, boundary);
using var uploadHandler = new UploadHandlerRaw(formSections);
Expand Down