@@ -47,53 +47,14 @@ public async Task<ApiResponse<T>> PatchAsync<T>(string endpoint, object payload)
4747 public async Task < ApiResponse < bool > > DeleteAsync ( string endpoint )
4848 => await SendRequestAsync < bool > ( HttpMethod . Delete , endpoint ) ;
4949
50- //private async Task<ApiResponse<T>> SendRequestAsync<T>(
51- // HttpMethod method,
52- // string endpoint,
53- // object content = null
54- //)
55- //{
56- // var request = new HttpRequestMessage(method, endpoint);
57-
58- // if (content != null)
59- // {
60- // var json = JsonConvert.SerializeObject(content, _jsonSettings);
61- // request.Content = new StringContent(json, Encoding.UTF8, "application/json");
62- // }
63-
64- // var response = await _httpClient.SendAsync(request);
65- // var responseContent = await response.Content.ReadAsStringAsync();
66-
67- // return response.IsSuccessStatusCode
68- // ? JsonConvert.DeserializeObject<ApiResponse<T>>(responseContent, _jsonSettings)
69- // : HandleFailureAsync<T>(responseContent);
70- //}
71-
72- //private ApiResponse<T> HandleFailureAsync<T>(string responseContent)
73- //{
74- // var failureResponse =
75- // JsonConvert.DeserializeObject<ApiResponse<List<ValidationFailure>>>(responseContent, _jsonSettings);
76-
77- // var failures = failureResponse.Data;
78-
79- // var friendlyErrorMessage = "";
80- // if (failures != null && failures.Count > 0)
81- // {
82- // friendlyErrorMessage = string.Join("; ",
83- // failures.Select(x => $"{x.PropertyName}: {x.ErrorMessage}"));
84- // }
85-
86- // return new ApiResponse<T>
87- // {
88- // Succeeded = false,
89- // HttpStatusCode = failureResponse.HttpStatusCode,
90- // Message = failureResponse.Message,
91- // Details = !string.IsNullOrEmpty(friendlyErrorMessage)
92- // ? friendlyErrorMessage
93- // : failureResponse.Details,
94- // Data = default
95- // };
96- //}
50+ public async Task < ApiResponse < T > > DeleteAsync < T > ( string endpoint , object payload )
51+ {
52+ // SendRequestAsync<T>(HttpMethod.Delete, endpoint, payload);
53+
54+ return await SendRequestAsync < T > ( HttpMethod . Delete , endpoint , payload ) ;
55+ }
56+
57+
9758 public async Task < ApiResponse < T > > SendRequestAsync < T > ( HttpMethod method , string endpoint , object content = null )
9859 {
9960 var request = new HttpRequestMessage ( method , endpoint ) ;
@@ -117,12 +78,15 @@ private ApiResponse<T> HandleFailureResponse<T>(string responseContent, int stat
11778 try
11879 {
11980 // First try to deserialize as a generic response
120- var failureResponse = JsonConvert . DeserializeObject < ApiResponse < object > > ( responseContent , _jsonSettings ) ;
81+ var failureResponse =
82+ JsonConvert . DeserializeObject < ApiResponse < object > > ( responseContent , _jsonSettings ) ;
12183
12284 // If status is 400, try to deserialize ValidationFailures
12385 if ( statusCode == 400 )
12486 {
125- var validationResponse = JsonConvert . DeserializeObject < ApiResponse < List < ValidationFailure > > > ( responseContent , _jsonSettings ) ;
87+ var validationResponse =
88+ JsonConvert . DeserializeObject < ApiResponse < List < ValidationFailure > > > ( responseContent ,
89+ _jsonSettings ) ;
12690 var failures = validationResponse ? . Data ;
12791
12892 var validationErrors = failures != null && failures . Count > 0
@@ -163,5 +127,4 @@ private ApiResponse<T> HandleFailureResponse<T>(string responseContent, int stat
163127 }
164128 }
165129 }
166- }
167-
130+ }
0 commit comments