You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,9 +39,10 @@ Given are the some of the examples on how you can make use of this utility
39
39
## GET Request example
40
40
41
41
```swift
42
+
let utility = HTTPUtility.shared// using the shared instance of the utility to make the API call
42
43
let requestUrl =URL(string: "http://demo0333988.mockable.io/Employees")
43
44
let request =HURequest(url: requestUrl!, method: .get)
44
-
let utility = HTTPUtility.shared
45
+
45
46
utility.request(huRequest: request, resultType: Employees.self) { (response) in
46
47
switch response
47
48
{
@@ -60,12 +61,14 @@ let requestUrl = URL(string: "http://demo0333988.mockable.io/Employees")
60
61
The httpUtility has an extra parameter "requestBody" where you should attach the data that you have to post to the server, in the given example the RegisterUserRequest is a struct inheriting from the [Encodable protocol](https://developer.apple.com/documentation/swift/encodable)
61
62
62
63
```swift
64
+
let utiltiy = HttpUtility.shared// using the shared instance of the utility to make the API call
65
+
63
66
let requestUrl =URL(string: "https://api-dev-scus-demo.azurewebsites.net/api/User/RegisterUser")
The HUNetworkError structure provides in detail description beneficial for debugging purpose, given are the following properties that will be populated incase an error occurs
185
188
186
-
1. ##### Status: ##### This will contain the HTTPStatus code for the request (200)
189
+
1. **Status:** This will contain the HTTPStatus code for the request (200)
187
190
188
-
2. ##### ServerResponse: ##### This will be the JSON string of the response you received from the server. (not to be confused with error parameter) on error if server returns the error JSON data that message will be decoded to human readable string.
191
+
2. **ServerResponse:** This will be the JSON string of the response you received from the server. (not to be confused with error parameter) on error if server returns the error JSON data that message will be decoded to human readable string.
189
192
190
-
3. ##### RequestUrl: ##### The request URL that you just called.
193
+
3. **RequestUrl:** The request URL that you just called.
191
194
192
-
4. ##### RequestBody: ##### If you get failure on POST request this property would contain a string representation of the HTTPBody that was sent to the server.
195
+
4. **RequestBody:** If you get failure on POST request this property would contain a string representation of the HTTPBody that was sent to the server.
193
196
194
-
5. ##### Reason: ##### This property would contain the debug description from the error closure parameter.
197
+
5. **Reason:** This property would contain the debug description from the error closure parameter.
195
198
196
199
This utility isfor performing basic tasks, and is currently evolving, but if you have any specific feature in mind then please feel free to drop a request and I will try my best to implement it
0 commit comments