Skip to content

Commit 8f8210a

Browse files
authored
Merge pull request #42 from Shahinmm69/refactor/HCG-41
refactoring on the readme file for better understanding
2 parents 185f374 + e013711 commit 8f8210a

File tree

1 file changed

+78
-80
lines changed

1 file changed

+78
-80
lines changed

README.md

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

7777
using var httpClient = new HttpClient();
7878
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -94,16 +94,14 @@ httpClient.GenerateCurlInConsole(
9494
string requestBody = @"{""name"":""justin"",""requestId"":10001026,""amount"":26000}";
9595
string requestUri = "api/test";
9696
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
97-
httpRequestMessage.Content = new FormUrlEncodedContent(new[]
97+
httpRequestMessage.Content = new FormUrlEncodedContent(new[]
9898
{
9999
new KeyValuePair<string, string>("session", "703438f3-16ad-4ba5-b923-8f72cd0f2db9"),
100100
new KeyValuePair<string, string>("payload", requestBody),
101101
});
102-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
103-
102+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
104103
using var httpClient = new HttpClient();
105104
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
106-
107105
httpClient.GenerateCurlInConsole(
108106
httpRequestMessage,
109107
config =>
@@ -129,7 +127,7 @@ string requestBody = @"<?xml version = ""1.0"" encoding = ""UTF-8""?>
129127

130128
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "api/test");
131129
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
132-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
130+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
133131

134132
using var httpClient = new HttpClient();
135133
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -146,44 +144,37 @@ httpClient.GenerateCurlInConsole(
146144
// Call PostAsync => await client.PostAsync(requestUri, httpRequestMessage.Content);
147145
```
148146

149-
### **Post Method** sample code (it will be written in the **file**):
150-
151-
If the path variable is null or empty, then the file is created in the **root project**.
152-
153-
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
147+
### **Get Method** sample code (it will be written in the **console**):
154148

155149
```cs
156-
string path = string.Empty;
157-
string filename = "PostMethodResult" ;
158-
string requestBody = @"{""name"":""sara"",""requestId"":""10001001"",""amount"":20000}";
159150
string requestUri = "api/test";
160-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
161-
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
162-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
151+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
152+
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
153+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
163154

164155
using var httpClient = new HttpClient();
165156
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
166157

167-
httpClient.GenerateCurlInFile(
158+
httpClient.GenerateCurlInConsole(
168159
httpRequestMessage,
169160
config =>
170161
{
171-
config.Filename = filename;
172-
config.Path = path;
173162
config.TurnOn = true;
174163
config.NeedAddDefaultHeaders = true;
164+
config.EnableCodeBeautification = false;
175165
});
176166

177-
// Call PostAsync => await client.PostAsync(requestUri, httpRequestMessage.Content);
167+
// Call GetAsync => await client.GetAsync(requestUri);
178168
```
179169

180-
### **Get Method** sample code (it will be written in the **console**):
170+
### **Put Method** sample code (it will be written in the **console**):
181171

182172
```cs
173+
string requestBody = @"{""name"":""jadi"",""requestId"":""10001003"",""amount"":30000}";
183174
string requestUri = "api/test";
184-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
185-
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
186-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
175+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
176+
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
177+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
187178

188179
using var httpClient = new HttpClient();
189180
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -197,47 +188,41 @@ httpClient.GenerateCurlInConsole(
197188
config.EnableCodeBeautification = false;
198189
});
199190

200-
// Call GetAsync => await client.GetAsync(requestUri);
191+
// Call PutAsync => await client.PutAsync(requestUri, httpRequestMessage.Content);
201192
```
202193

203-
### **Get Method** sample code (it will be written in the **file**):
204-
205-
If the path variable is null or empty, then the file is created in the **root project**.
206-
207-
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
194+
### **Patch Method** sample code (it will be written in the **console**):
208195

209196
```cs
210-
string path = string.Empty;
211-
string filename = "GetMethodResult";
197+
string requestBody = @"{""name"":""hamed"",""requestId"":""10001005"",""amount"":50000}";
212198
string requestUri = "api/test";
213-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
214-
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
215-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
199+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
200+
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
201+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
216202

217203
using var httpClient = new HttpClient();
218204
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
219205

220-
httpClient.GenerateCurlInFile(
206+
httpClient.GenerateCurlInConsole(
221207
httpRequestMessage,
222208
config =>
223209
{
224-
config.Filename = filename;
225-
config.Path = path;
226210
config.TurnOn = true;
227211
config.NeedAddDefaultHeaders = true;
212+
config.EnableCodeBeautification = false;
228213
});
229214

230-
// Call GetAsync => await client.GetAsync(requestUri);
215+
// Call PatchAsync => await client.PatchAsync(requestUri, httpRequestMessage.Content);
231216
```
232217

233-
### **Put Method** sample code (it will be written in the **console**):
218+
### **Delete Method** sample code (it will be written in the **console**):
234219

235220
```cs
236-
string requestBody = @"{""name"":""jadi"",""requestId"":""10001003"",""amount"":30000}";
237-
string requestUri = "api/test";
238-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
239-
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
240-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
221+
int id = 12;
222+
string requestUri = $"api/test/{id}";
223+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, requestUri);
224+
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
225+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
241226

242227
using var httpClient = new HttpClient();
243228
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -251,23 +236,23 @@ httpClient.GenerateCurlInConsole(
251236
config.EnableCodeBeautification = false;
252237
});
253238

254-
// Call PutAsync => await client.PutAsync(requestUri, httpRequestMessage.Content);
239+
// Call DeleteAsync => await client.DeleteAsync(requestUri);
255240
```
256241

257-
### **Put Method** sample code (it will be written in the **file**):
242+
### **Post Method** sample code (it will be written in the **file**):
258243

259-
If the path variable is null or empty, then the file is created in the **root project**.
244+
If the path variable is null or empty, then the file is created in the **yourProjectPath/bin/Debug/netx.0**
260245

261246
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
262247

263248
```cs
264249
string path = string.Empty;
265-
string filename = "PutMethodResult" ;
266-
string requestBody = @"{ ""name"" : ""reza"",""requestId"" : ""10001004"",""amount"":40000 }";
250+
string filename = "PostMethodResult" ;
251+
string requestBody = @"{""name"":""sara"",""requestId"":""10001001"",""amount"":20000}";
267252
string requestUri = "api/test";
268-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
253+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
269254
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
270-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
255+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
271256

272257
using var httpClient = new HttpClient();
273258
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -282,47 +267,53 @@ httpClient.GenerateCurlInFile(
282267
config.NeedAddDefaultHeaders = true;
283268
});
284269

285-
// Call PutAsync => await client.PutAsync(requestUri, httpRequestMessage.Content);
270+
// Call PostAsync => await client.PostAsync(requestUri, httpRequestMessage.Content);
286271
```
287272

288-
### **Patch Method** sample code (it will be written in the **console**):
273+
### **Get Method** sample code (it will be written in the **file**):
274+
275+
If the path variable is null or empty, then the file is created in the **yourProjectPath/bin/Debug/netx.0**
276+
277+
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
289278

290279
```cs
291-
string requestBody = @"{""name"":""hamed"",""requestId"":""10001005"",""amount"":50000}";
280+
string path = string.Empty;
281+
string filename = "GetMethodResult";
292282
string requestUri = "api/test";
293-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
294-
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
295-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
283+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
284+
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
285+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
296286

297287
using var httpClient = new HttpClient();
298288
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
299289

300-
httpClient.GenerateCurlInConsole(
290+
httpClient.GenerateCurlInFile(
301291
httpRequestMessage,
302292
config =>
303293
{
294+
config.Filename = filename;
295+
config.Path = path;
304296
config.TurnOn = true;
305297
config.NeedAddDefaultHeaders = true;
306-
config.EnableCodeBeautification = false;
307298
});
308299

309-
// Call PatchAsync => await client.PatchAsync(requestUri, httpRequestMessage.Content);
300+
// Call GetAsync => await client.GetAsync(requestUri);
310301
```
311302

312-
### **Patch Method** sample code (it will be written in the **file**):
303+
### **Put Method** sample code (it will be written in the **file**):
313304

314-
If the path variable is null or empty, then the file is created in the **root project**.
305+
If the path variable is null or empty, then the file is created in the **yourProjectPath/bin/Debug/netx.0**
315306

316307
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
317308

318309
```cs
319310
string path = string.Empty;
320-
string filename = "PatchMethodResult" ;
321-
string requestBody = @"{ ""name"" : ""zara"",""requestId"" : ""10001006"",""amount"":60000 }";
311+
string filename = "PutMethodResult" ;
312+
string requestBody = @"{ ""name"" : ""reza"",""requestId"" : ""10001004"",""amount"":40000 }";
322313
string requestUri = "api/test";
323-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
314+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
324315
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
325-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
316+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
326317

327318
using var httpClient = new HttpClient();
328319
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
@@ -337,36 +328,43 @@ httpClient.GenerateCurlInFile(
337328
config.NeedAddDefaultHeaders = true;
338329
});
339330

340-
// Call PatchAsync => await client.PatchAsync(requestUri, httpRequestMessage.Content);
331+
// Call PutAsync => await client.PutAsync(requestUri, httpRequestMessage.Content);
341332
```
342333

343-
### **Delete Method** sample code (it will be written in the **console**):
334+
### **Patch Method** sample code (it will be written in the **file**):
335+
336+
If the path variable is null or empty, then the file is created in the **yourProjectPath/bin/Debug/netx.0**
337+
338+
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
344339

345340
```cs
346-
int id = 12;
347-
string requestUri = $"api/test/{id}";
348-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, requestUri);
349-
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
350-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
341+
string path = string.Empty;
342+
string filename = "PatchMethodResult" ;
343+
string requestBody = @"{ ""name"" : ""zara"",""requestId"" : ""10001006"",""amount"":60000 }";
344+
string requestUri = "api/test";
345+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
346+
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
347+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
351348

352349
using var httpClient = new HttpClient();
353350
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");
354351

355-
httpClient.GenerateCurlInConsole(
352+
httpClient.GenerateCurlInFile(
356353
httpRequestMessage,
357354
config =>
358355
{
356+
config.Filename = filename;
357+
config.Path = path;
359358
config.TurnOn = true;
360359
config.NeedAddDefaultHeaders = true;
361-
config.EnableCodeBeautification = false;
362360
});
363361

364-
// Call DeleteAsync => await client.DeleteAsync(requestUri);
362+
// Call PatchAsync => await client.PatchAsync(requestUri, httpRequestMessage.Content);
365363
```
366364

367365
### **Delete Method** sample code (it will be written in the **file**):
368366

369-
If the path variable is null or empty, then the file is created in the **root project**.
367+
If the path variable is null or empty, then the file is created in the **yourProjectPath/bin/Debug/netx.0**
370368

371369
If the filename variable is null or empty, then the current date will be set for it with this format: **yyyyMMdd**
372370

@@ -377,7 +375,7 @@ int id = 12;
377375
string requestUri = $"api/test/{id}";
378376
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, requestUri);
379377
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
380-
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
378+
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid()}");
381379

382380
using var httpClient = new HttpClient();
383381
httpClient.BaseAddress = new Uri("http://localhost:1213/v1/");

0 commit comments

Comments
 (0)