Skip to content

Commit 70867bb

Browse files
committed
refactorin on the readme file for better underestanding
1 parent 83ca160 commit 70867bb

File tree

1 file changed

+76
-78
lines changed

1 file changed

+76
-78
lines changed

README.md

Lines changed: 76 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ string requestBody = @"{""name"":""amin"",""requestId"":""10001000"",""amount"":
7474
string requestUri = "api/test";
7575
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
7676
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
77-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
77+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
7878

7979
using var httpClient = new HttpClient();
8080
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -96,16 +96,14 @@ httpClient.GenerateCurlInConsole(
9696
string requestBody = @"{""name"":""justin"",""requestId"":10001026,""amount"":26000}";
9797
string requestUri = "api/test";
9898
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
99-
httpRequestMessage.Content = new FormUrlEncodedContent(new[]
99+
httpRequestMessage.Content = new FormUrlEncodedContent(new[]
100100
{
101101
new KeyValuePair<string, string>("session", "703438f3-16ad-4ba5-b923-8f72cd0f2db9"),
102102
new KeyValuePair<string, string>("payload", requestBody),
103103
});
104-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
105-
104+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid
106105
using var httpClient = new HttpClient();
107-
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
108-
106+
httpClient.BaseAddress = new Uri("http://localhost:1213/v1
109107
httpClient.GenerateCurlInConsole(
110108
httpRequestMessage,
111109
config =>
@@ -131,7 +129,7 @@ string requestBody = @"<?xml version = ""1.0"" encoding = ""UTF-8""?>
131129
132130
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "api/test");
133131
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
134-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
132+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
135133
136134
using var httpClient = new HttpClient();
137135
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -148,44 +146,37 @@ httpClient.GenerateCurlInConsole(
148146
// Call PostAsync => await client.PostAsync(requestUri, httpRequestMessage.Content);
149147
```
150148
151-
### **Post Method** sample code (it will be written in the **file**):
152-
153-
If the path variable is null or empty, then the file is created in the **root project**.
154-
155-
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
149+
### **Get Method** sample code (it will be written in the **console**):
156150
157151
```cs
158-
string path = string.Empty;
159-
string filename = "PostMethodResult" ;
160-
string requestBody = @"{""name"":""sara"",""requestId"":""10001001"",""amount"":20000}";
161152
string requestUri = "api/test";
162-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
163-
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
164-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
153+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
154+
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
155+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
165156
166157
using var httpClient = new HttpClient();
167158
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
168159
169-
httpClient.GenerateCurlInFile(
160+
httpClient.GenerateCurlInConsole(
170161
httpRequestMessage,
171162
config =>
172163
{
173-
config.Filename = filename;
174-
config.Path = path;
175164
config.TurnOn = true;
176165
config.NeedAddDefaultHeaders = true;
166+
config.EnableCodeBeautification = false;
177167
});
178168
179-
// Call PostAsync => await client.PostAsync(requestUri, httpRequestMessage.Content);
169+
// Call GetAsync => await client.GetAsync(requestUri);
180170
```
181171
182-
### **Get Method** sample code (it will be written in the **console**):
172+
### **Put Method** sample code (it will be written in the **console**):
183173
184174
```cs
175+
string requestBody = @"{""name"":""jadi"",""requestId"":""10001003"",""amount"":30000}";
185176
string requestUri = "api/test";
186-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
187-
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
188-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
177+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
178+
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
179+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
189180
190181
using var httpClient = new HttpClient();
191182
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -199,47 +190,41 @@ httpClient.GenerateCurlInConsole(
199190
config.EnableCodeBeautification = false;
200191
});
201192
202-
// Call GetAsync => await client.GetAsync(requestUri);
193+
// Call PutAsync => await client.PutAsync(requestUri, httpRequestMessage.Content);
203194
```
204195
205-
### **Get Method** sample code (it will be written in the **file**):
206-
207-
If the path variable is null or empty, then the file is created in the **root project**.
208-
209-
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
196+
### **Patch Method** sample code (it will be written in the **console**):
210197
211198
```cs
212-
string path = string.Empty;
213-
string filename = "GetMethodResult";
199+
string requestBody = @"{""name"":""hamed"",""requestId"":""10001005"",""amount"":50000}";
214200
string requestUri = "api/test";
215-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
216-
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
217-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
201+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
202+
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
203+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
218204
219205
using var httpClient = new HttpClient();
220206
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
221207
222-
httpClient.GenerateCurlInFile(
208+
httpClient.GenerateCurlInConsole(
223209
httpRequestMessage,
224210
config =>
225211
{
226-
config.Filename = filename;
227-
config.Path = path;
228212
config.TurnOn = true;
229213
config.NeedAddDefaultHeaders = true;
214+
config.EnableCodeBeautification = false;
230215
});
231216
232-
// Call GetAsync => await client.GetAsync(requestUri);
217+
// Call PatchAsync => await client.PatchAsync(requestUri, httpRequestMessage.Content);
233218
```
234219
235-
### **Put Method** sample code (it will be written in the **console**):
220+
### **Delete Method** sample code (it will be written in the **console**):
236221
237222
```cs
238-
string requestBody = @"{""name"":""jadi"",""requestId"":""10001003"",""amount"":30000}";
239-
string requestUri = "api/test";
240-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
241-
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
242-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
223+
int id = 12;
224+
string requestUri = $"api/test/{id}";
225+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, requestUri);
226+
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
227+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
243228
244229
using var httpClient = new HttpClient();
245230
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -253,23 +238,23 @@ httpClient.GenerateCurlInConsole(
253238
config.EnableCodeBeautification = false;
254239
});
255240
256-
// Call PutAsync => await client.PutAsync(requestUri, httpRequestMessage.Content);
241+
// Call DeleteAsync => await client.DeleteAsync(requestUri);
257242
```
258243
259-
### **Put Method** sample code (it will be written in the **file**):
244+
### **Post Method** sample code (it will be written in the **file**):
260245
261246
If the path variable is null or empty, then the file is created in the **root project**.
262247
263248
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
264249
265250
```cs
266251
string path = string.Empty;
267-
string filename = "PutMethodResult" ;
268-
string requestBody = @"{ ""name"" : ""reza"",""requestId"" : ""10001004"",""amount"":40000 }";
252+
string filename = "PostMethodResult" ;
253+
string requestBody = @"{""name"":""sara"",""requestId"":""10001001"",""amount"":20000}";
269254
string requestUri = "api/test";
270-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
255+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
271256
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
272-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
257+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
273258
274259
using var httpClient = new HttpClient();
275260
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -284,47 +269,53 @@ httpClient.GenerateCurlInFile(
284269
config.NeedAddDefaultHeaders = true;
285270
});
286271
287-
// Call PutAsync => await client.PutAsync(requestUri, httpRequestMessage.Content);
272+
// Call PostAsync => await client.PostAsync(requestUri, httpRequestMessage.Content);
288273
```
289274
290-
### **Patch Method** sample code (it will be written in the **console**):
275+
### **Get Method** sample code (it will be written in the **file**):
276+
277+
If the path variable is null or empty, then the file is created in the **root project**.
278+
279+
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
291280
292281
```cs
293-
string requestBody = @"{""name"":""hamed"",""requestId"":""10001005"",""amount"":50000}";
282+
string path = string.Empty;
283+
string filename = "GetMethodResult";
294284
string requestUri = "api/test";
295-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
296-
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
297-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
285+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
286+
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
287+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
298288
299289
using var httpClient = new HttpClient();
300290
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
301291
302-
httpClient.GenerateCurlInConsole(
292+
httpClient.GenerateCurlInFile(
303293
httpRequestMessage,
304294
config =>
305295
{
296+
config.Filename = filename;
297+
config.Path = path;
306298
config.TurnOn = true;
307299
config.NeedAddDefaultHeaders = true;
308-
config.EnableCodeBeautification = false;
309300
});
310301
311-
// Call PatchAsync => await client.PatchAsync(requestUri, httpRequestMessage.Content);
302+
// Call GetAsync => await client.GetAsync(requestUri);
312303
```
313304
314-
### **Patch Method** sample code (it will be written in the **file**):
305+
### **Put Method** sample code (it will be written in the **file**):
315306
316307
If the path variable is null or empty, then the file is created in the **root project**.
317308
318309
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
319310
320311
```cs
321312
string path = string.Empty;
322-
string filename = "PatchMethodResult" ;
323-
string requestBody = @"{ ""name"" : ""zara"",""requestId"" : ""10001006"",""amount"":60000 }";
313+
string filename = "PutMethodResult" ;
314+
string requestBody = @"{ ""name"" : ""reza"",""requestId"" : ""10001004"",""amount"":40000 }";
324315
string requestUri = "api/test";
325-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
316+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
326317
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
327-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
318+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
328319
329320
using var httpClient = new HttpClient();
330321
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -339,31 +330,38 @@ httpClient.GenerateCurlInFile(
339330
config.NeedAddDefaultHeaders = true;
340331
});
341332
342-
// Call PatchAsync => await client.PatchAsync(requestUri, httpRequestMessage.Content);
333+
// Call PutAsync => await client.PutAsync(requestUri, httpRequestMessage.Content);
343334
```
344335
345-
### **Delete Method** sample code (it will be written in the **console**):
336+
### **Patch Method** sample code (it will be written in the **file**):
337+
338+
If the path variable is null or empty, then the file is created in the **root project**.
339+
340+
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
346341
347342
```cs
348-
int id = 12;
349-
string requestUri = $"api/test/{id}";
350-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, requestUri);
351-
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
352-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
343+
string path = string.Empty;
344+
string filename = "PatchMethodResult" ;
345+
string requestBody = @"{ ""name"" : ""zara"",""requestId"" : ""10001006"",""amount"":60000 }";
346+
string requestUri = "api/test";
347+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
348+
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
349+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
353350
354351
using var httpClient = new HttpClient();
355352
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
356353
357-
httpClient.GenerateCurlInConsole(
354+
httpClient.GenerateCurlInFile(
358355
httpRequestMessage,
359356
config =>
360357
{
358+
config.Filename = filename;
359+
config.Path = path;
361360
config.TurnOn = true;
362361
config.NeedAddDefaultHeaders = true;
363-
config.EnableCodeBeautification = false;
364362
});
365363
366-
// Call DeleteAsync => await client.DeleteAsync(requestUri);
364+
// Call PatchAsync => await client.PatchAsync(requestUri, httpRequestMessage.Content);
367365
```
368366
369367
### **Delete Method** sample code (it will be written in the **file**):
@@ -379,7 +377,7 @@ int id = 12;
379377
string requestUri = $"api/test/{id}";
380378
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, requestUri);
381379
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
382-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
380+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
383381
384382
using var httpClient = new HttpClient();
385383
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");

0 commit comments

Comments
 (0)