{"id":23734385,"url":"https://github.com/fmazzant/restclient","last_synced_at":"2025-09-04T09:33:38.093Z","repository":{"id":38041938,"uuid":"272731947","full_name":"fmazzant/RestClient","owner":"fmazzant","description":"A library for .NET that can help you to consume REST services","archived":false,"fork":false,"pushed_at":"2025-03-31T12:26:01.000Z","size":366,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T06:41:31.172Z","etag":null,"topics":["c-sharp","client","dotnet-standard","fluent","http-client","net","networking","rest","rest-client","standard-library"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fmazzant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-06-16T14:35:59.000Z","updated_at":"2022-07-30T14:05:51.000Z","dependencies_parsed_at":"2024-04-06T09:25:34.054Z","dependency_job_id":"2955b193-487b-4add-80b1-536f2b5a347a","html_url":"https://github.com/fmazzant/RestClient","commit_stats":{"total_commits":386,"total_committers":4,"mean_commits":96.5,"dds":"0.32383419689119175","last_synced_commit":"e670f34666c26ac1381c1847478ac65bfe7c6330"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/fmazzant/RestClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmazzant%2FRestClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmazzant%2FRestClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmazzant%2FRestClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmazzant%2FRestClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fmazzant","download_url":"https://codeload.github.com/fmazzant/RestClient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmazzant%2FRestClient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273583475,"owners_count":25131838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","client","dotnet-standard","fluent","http-client","net","networking","rest","rest-client","standard-library"],"created_at":"2024-12-31T05:45:32.468Z","updated_at":"2025-09-04T09:33:37.815Z","avatar_url":"https://github.com/fmazzant.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RestClient\n\nRestClient library provides a simple connector to consume REST services.\n\nTo use it in your project, add the Mafe.RestClient NuGet package to your project.\n\n[![Nuget](https://img.shields.io/nuget/v/Mafe.RestClient?style=flat-square)](https://www.nuget.org/packages/Mafe.RestClient)\n\n### What is RestClient?\n\nThe goal of RestClient is to enable developers to easily connect to any server in a really easy way. \nJust define your Data Transfer Object (Dto) and start playing with the client!\n\nUse Build() method to create a RestBuilder from Rest:\n\n```c#\nvar rest = Rest.Build();\n```\n\nTo create a simple get call, just do like this:\n\n```c#\nvar rest = Rest.Build();\nvar result = rest.Url(\"[URL]\").Get();\n```\nor we can use GetAsync() method:\n\n```c#\nvar rest = Rest.Build();\nvar result = await rest.Url(\"[URL]\").GetAsync();\n```\n\nWhenever you find the word \"[URL]\" in this document it reffers to the base URL definition of the webAPI.\n\nWe can define a Root() endpoint and use it to build the request.\n\n```c#\npublic RestBuilder Root() =\u003e rest.Url(\"https://mywebapi.mydomain.com\");\n```\n\nand then, we can use it, like this:\n\n```c#\npublic RestBuilder Root() =\u003e Rest.Build().Url(\"https://mywebapi.mydomain.com\");\nvar result = Root()\n    .Command(\"/my-action\")\n    .Payload(\"mystring\")\n    .Post();\n```\n\n### RestProperties\n\nTo use RestProperties to configure yuor rest root point. To create a simple configuration, just like this:\n\n```c#\nRestProperties properties = new RestProperties\n{\n    EndPoint = new Uri(\"[URL]\"), //if you use .Url(\"[URL]\") you override it\n    BufferSize = 4096,\n    CertificateOption = ClientCertificateOption.Manual,\n    Timeout = TimeSpan.FromMinutes(2)\n};\n```\n\nUse Build() method with properties to create a RestBuilder from Rest:\n\n```c#\nvar rest = Rest.Build(properties);\n```\n\n### Certificate Validation\n\nValidation of X.509 certificates is essential to create secure SSL/TLS sessions not vulnerable to man-in-the-middle attacks.\n\nThe certificate chain validation includes these steps:\n\n* The certificate is issued by its parent Certificate Authority or the root CA trusted by the system.\n* Each CA is allowed to issue certificates.\n* Each certificate in the chain is not expired.\n\nIt's not recommended to reinvent the wheel by implementing custom certificate chain validation.\n\nTLS libraries provide built-in certificate validation functions that should be used.\n\n```c#\nList\u003cstring\u003e validCerts = new List\u003cstring\u003e() {\n    \"CERT STRING\"\n};\n\nvar result = Rest.Build()\n    .CertificateValidation((sender, certificate, chain, errors) =\u003e\n    {\n      // for development, trust all certificates\n      if (development) return true; \n      \n      // Compliant: trust only some certificates\n      return errors == SslPolicyErrors.None \n              \u0026\u0026 validCerts.Contains(certificate.GetCertHashString()); \n    })\n    .Url(\"[URL]\")\n    .Get();\n```\n\n### Authentication\n\nAs defined by HTTP/1.1 [RFC2617], the application should send the access_token directly in the Authorization request header.\nYou can do so by including the bearer token's access_token value in the HTTP request body as 'Authorization: Bearer {access_token_value}'.\n\nIf an authenticated user has a bearer token's access_token or refresh_token that is expired, then a '401 - Unauthorized (invalid or expired refresh token)' error is returned.\n\n```c#\nvar result = Rest.Build()\n    .Authentication(() =\u003e new AuthenticationHeaderValue(\"Bearer\", \"[Token]\"))\n    .Url(\"[URL]\")\n    .Get();\n```\n\n### Refresh Token\n\nA valid bearer token (with active access_token or refresh_token properties) keeps the user's authentication alive without requiring him or her to re-enter their credentials frequently.\nThe access_token can be used for as long as it’s active, which is up to one hour after login or renewal. The refresh_token is active for 336 hours (14 days). After the access_token expires, an active refresh_token can be used to get a new access_token / refresh_token pair as shown in the following example. This cycle can continue for up to 90 days after which the user must log in again. If the refresh_token expires, the tokens cannot be renewed and the user must log in again.\n\nTo refresh a token, use \"RefreshTokenInvoke\" automatically.\n\n```c#\nvar url = \"[URL]\";\nvar result = Rest.Build()\n    .Authentication(() =\u003e new AuthenticationHeaderValue(\"Bearer\", \"[Token]\"))\n    .RefreshToken(true)\n    .RefreshTokenInvoke(async () =\u003e\n    {\n        var result = await rest\n            .Url(url)\n            .Command(\"/refresh\")\n            .GetAsync\u003cTokenObjectResponse\u003e();   \n        doSomethings(); //store the token inside your env.\n        return result;\n    })\n    .Command(\"/detail\")\n    .Url(url)\n    .Get();\n```\n\nA refresh_token should be revoked:\n* If a user is no longer permitted to make requests on the API, or\n* If the access_token or refresh_token have been compromised.\n\n### Network Credential\n\nThe NetworkCredential class is a base class that supplies credentials in password-based authentication schemes such as basic, digest, NTLM, and Kerberos. \nClasses that implement the ICredentials interface, such as the CredentialCache class, return NetworkCredential objects.\nThis class does not support public key-based authentication methods such as Secure Sockets Layer (SSL) client authentication.\n\n```c#\nvar result = Rest.Build()\n    .NetworkCredential(\"myUsername\",\"myPassword\")\n    .Url(\"[URL]\")\n    .Get();\n```\n\n```c#\nvar result = rest\n    .NetworkCredential(() =\u003e  new System.Net.NetworkCredential(\"myUsername\",\"myPassword\"))\n    .Url(\"[URL]\")\n    .Get();\n```\n\n### Headers\n\nThe Headers collection contains the protocol headers associated with the request. The Header((h)=\u003e{}) method allows you to add the list of keys.\n\n```c#\nvar result = Rest.Build()\n    .Header((h) =\u003e {\n        if(!h.Contains(\"auth-custom\"))\n            h.Add(\"auth-custom\", \"value\");\n    })\n    .Url(\"[URL]\")\n    .Get();\n```\n\n### Serialization\n\nTwo types of serialization are supported by RestClient: Xml and Json, but it is possible to implementate ISerializerContent to customize the serialization.\nRestClient uses .Json() to serialize an object into json.\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Json()\n    .Get\u003cResponseObject\u003e();\n```\n\nIt is possible to pass an json serializer options to .Json() method, like this:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Json(new JsonSerializerOptions {\n        WriteIndented = true\n    })\n    .Get\u003cResponseObject\u003e();\n```\n\nThe above snippet code consideres using System.Text.Json library. If we using Netwnsoft like this:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Json(new JsonSerializerSettings {\n        Formatting = Formatting.Indented\n    })\n    .Get\u003cResponseObject\u003e();\n```  \n\nRestClient uses .Xml() to serialize an object into xml.\n\n```c#\nvar result = rest\n    .Url(\"[URL]\")\n    .Xml()\n    .Get\u003cResponseObject\u003e();\n```\n\nIt is possible to pass the settings to .Xml() method, like this:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Xml(new XmlReaderSettings { Indent = true }, new XmlWriterSettings { IgnoreWhitespace = true })\n    .Get\u003cResponseObject\u003e();\n```\n\n### Custom Serialization\n\nBelow an example on how you can do a custom Serialization by implementing the ISerializerContent interface:\n\n```c#\npublic class MyCustomSerializer : ISerializerContent\n{\n    public string MediaTypeAsString =\u003e throw new NotImplementedException();\n\n    public object DeserializeObject(string value, Type typeOf, object options = null)\n    {\n        throw new NotImplementedException();\n    }\n\n    public string SerializeObject(object value, Type typeOf, object options = null)\n    {\n        throw new NotImplementedException();\n    }\n}\n```\nNow, we can use MyCustomSerializer like this:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .CustomSerializer(new MyCustomSerializer { })\n    .Get\u003cResponseObject\u003e();\n```\n\n### BufferSize\n\nBufferSize can be use to set the buffer size during upload and download stream. Default value is 80Kb\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .BufferSize(4096 * 5 * 5) //100Kb\n    .Get();\n```\n\n### GZip Compression\n\nEnables gzip compression during communication with a specified resource:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .EnableGZipCompression()\n    .Get();\n```\n\nThe library uncompresses automatically the response.\n\n### Get\n\nGET is one of the most common HTTP methods and GET is used to request data from a specified resource \n\n```c#\nvar rest = Rest.Build();\n\nvar result = rest\n    .Url(\"[URL]\")\n    .Get();\n\nvar result = await rest\n    .Url(\"[URL]\")\n    .GetAsync();\n```\n\nSome other notes on GET requests:\n\n* GET requests can be cached\n* GET requests remain in the browser history\n* GET requests can be bookmarked\n* GET requests should never be used when dealing with sensitive data\n* GET requests have length restrictions\n* GET requests are only used to request data (not modify)\n\nNote that the query string (name/value pairs) is sent in the URL of a GET request.\n\n### Parameters as query string \n\nIn some cases we need to use arguments as query string. We can use the method Parameter(key, value) to resolve it like this:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/path\")\n    .Parameter(\"id\",\"10\")\n    .Parameter(\"type\", \"myType\")\n    .Get();\n```\n\nThe url generated is: [URL]/path?id=10\u0026type=myType\n\n### Post\n\nPOST is used to send data to a server for create/update a resource.\nThe data sent to the server with POST is stored in the request payload of the HTTP request:\n\n```c#\nvar rest = Rest.Build();\n\nvar result = rest\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new Object{})\n    .Post\u003cResponseObject\u003e();\n\nvar result = await rest\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new Object{})\n    .PostAsync\u003cResponseObject\u003e();\n```\nPost is another common http method, wich is used to:\n\n* POST requests are never cached\n* POST requests do not remain in the browser history\n* POST requests cannot be bookmarked\n* POST requests have no restrictions on data length\n\n### Put\n\nPUT is used to send data to a server for create/update a resource.\n\nThe difference between POST and PUT is that PUT requests are idempotent. That is, calling the same PUT request multiple times will always produce the same result. In contrast, calling a POST request repeatedly have side effects of creating the same resource multiple times.\n\n```c#\nvar rest = Rest.Build();\n\nvar result = rest\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new Object{})\n    .Put\u003cResponseObject\u003e();\n\nvar result = await rest\n    .Url(\"[URL]\")\n    .Payload(new Object{})\n    .PutAsync\u003cResponseObject\u003e();\n```\n\n### Delete\n\nThe DELETE method deletes the specified resource.\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new Object{})\n    .Delete\u003cResponseObject\u003e();\n\nvar result = await Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new Object{})\n    .DeleteAsync\u003cResponseObject\u003e();\n```\n\n### Download\n\nThe DOWNLOAD method download the specified resource.\n\n```c#\nvar result = Rest.Build()\n    .Download(\"[URL]\");\n\nvar result = await rest\n    .DownloadAsync(\"[URL]\");\n```\nIs possible display the download status with OnDownloadProgress.\n\n```c#\nvar rest = Rest.Build();\n\nvar result = await rest\n    .OnDownloadProgress((d) =\u003e Console.WriteLine($\"{d.CurrentBytes}/{d.TotalBytes}\"))\n    .DownloadAsync(\"[URL]\");\n```\n\n### CancellationToken\n\nPropagates notification that operations should be canceled.\n\nA CancellationToken enables cooperative cancellation between threads, thread pool work items, or Task objects. \nYou create a cancellation token by instantiating a CancellationTokenSource object, \nwhich manages cancellation tokens retrieved from its CancellationTokenSource.\n\nThe following example uses cancellation token to stop execution:\n\n```c#\n// Define the cancellation token.\nCancellationTokenSource source = new CancellationTokenSource();\nCancellationToken token = source.Token;\n\n// Schedules a cancel operation on this System.Threading.CancellationTokenSource\n// after the specified number of milliseconds\ntoken.CancelAfter(3000);\n\nvar file1 = Rest.Build().DownloadAsync(\"[URL FILE1]\", token.Token);\nvar file2 = Rest.Build().DownloadAsync(\"[URL FILE2]\", token.Token);\nvar get1 = Rest.Build().Url(\"[URL GET1]\").GetAsync\u003cMyObject\u003e(token.Token);\n\nTask.WaitAll(file1, file2, get1);\n```\n\nAfter cancellation requested it throws a TaskCancellatedException. \nThe exception will be encapsulated into RestResult object.\n\n### Custom Call\n\nThe CUSTOM method customizing the specified resource.\n\n```c#\nHttpMethod PATCH = new HttpMethod(\"PATCH\");\nvar rest = Rest.Build();\n\nvar result = rest\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new Object{})\n    .CustomCall\u003cResponseObject\u003e(PATCH);\n\nvar result = await rest\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new Object{})\n    .CustomCallAsync\u003cResponseObject\u003e(PATCH);\n```\n\n### Payload\n\nRestClient uses Playload\u003cT\u003e(obj) method to set an object on request: \n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new RequestObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .Payload(new RequestObject{})\n    .Put\u003cResponseObject\u003e();\n```\n\n### Form Url Encoded (application/x-www-form-urlencoded)\n\nWhen necessary we can use the request as a form-url-encoded. To use it we need to enabled it, like this:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .EnableFormUrlEncoded(true)\n```\n\nand then we can pass the parameters as a dictionary:\n\n```c#\n var params = new Dictionary\u003cstring, string\u003e();\n params.Add(\"key1\", \"value1\");\n params.Add(\"key2\", \"value2\");\n\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .EnableFormUrlEncoded(true)\n    .FormUrlEncoded(params)\n    .Post();\n```\n\nIt is possible to pass the parameters inside the handler and enabling the form-url-encoded:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .FormUrlEncoded(true, (p) =\u003e\n    {\n        p.Add(\"key1\", \"value1\");\n        p.Add(\"key2\", \"value2\");\n    })\n    .Post();\n```\n\n### OnUploadProgress\n\nOnUploadProgress occurs when the request is running and the data is going out. We can get a percentage of the data being uploaded like this:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .OnUploadProgress(p =\u003e\n    {\n      DoSomethings(p.ProgressPercentage); \n    }) //occurs during request\n    .Payload(new BigObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n### OnDownloadProgress\n\nOnDownloadProgress occurs when the response is running and the data is coming in. We can get a percentage of the data being downloading like this:\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .OnDownloadProgress(p =\u003e\n    {\n      DoSomethings(p.ProgressPercentage); \n    }) //occurs during response\n    .Payload(new BigObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n### Timeout\n\nThe default value is 100,000 milliseconds (100 seconds).\nTo set an infinite timeout, set the property value to InfiniteTimeSpan.\nA Domain Name System (DNS) query may take up to 15 seconds to return or time out. If your request contains a host name that requires resolution and you set Timeout to a value less than 15 seconds, it may take 15 seconds or more before an Exception is thrown to indicate a timeout on your request.\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Timeout(3200) //milliseconds\n    .Get\u003cResponseObject\u003e();\n```\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Timeout(TimeSpan.FromMinutes(10)) \n    .Get\u003cResponseObject\u003e();\n```\n\n### OnStart\n\nOnStart is an event that triggers when the request starts.\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .OnStart((e) =\u003e { \n        DoSomethings(e); \n    })\n    .Payload(new BigObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n### OnPreviewContentRequestAsString\n\nOnPreviewContentRequestAsString is an event that triggers when the request is ready and it isn't no sent yet.\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .OnPreviewContentRequestAsString((e) =\u003e { \n        DoSomethings(e); \n    })\n    .Payload(new BigObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n### OnPreviewContentAsString -\u003e OnPreviewContentResponseAsString (renaming)\n\nOnPreviewContentResponseAsString is an event that triggers when the response is received and it isn't no deserialized yet.\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .OnPreviewContentResponseAsString((e) =\u003e { \n        DoSomethings(e); \n    })\n    .Payload(new BigObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n### OnPreResult -\u003e OnPreCompleted (renaming)\n\nOnPreResult occurs when the request is completing but  still hasn't completed yet. \nWhen OnPreResult is raises we can todo somethings, for example  get and use the result of request.\n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .OnPreCompleted((r) =\u003e { \n        DoSomethings(r.Result); \n    })\n    .Payload(new BigObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n### OnException\n\nOnException occurs when the request raises an exception. \n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .OnException((e) =\u003e { \n      DoSomethings(e); \n    })\n    .Payload(new BigObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n### OnCompleted (changed type of parameter, from EventArgs to CompletedEventArgs)\n\nOnCompleted occurs when the request is completed. \n\n```c#\nvar result = Rest.Build()\n    .Url(\"[URL]\")\n    .Command(\"/action\")\n    .OnCompleted((e) =\u003e { \n        DoSomethings(e); \n    })\n    .Payload(new BigObject{})\n    .Post\u003cResponseObject\u003e();\n```\n\n### Complete code example\n\nRestClient allows to create a flexible and robust network layer and it is very easy to use.\nBelow you find a complete code demostration a complete code example. \n\n```c#\npublic class NetworkService {\n    //building context\n\n    public RestBuilder Root() \n        =\u003e Rest.Build()\n            .CertificateValidation((sender, certificate, chain, errors) =\u003e\n            {\n              if (development) return true; \n              return errors == SslPolicyErrors.None \n                      \u0026\u0026 validCerts.Contains(certificate.GetCertHashString()); \n            })\n            .Url(\"[URL]\");\n    \n    public RestBuilder RootAuthentication() \n        =\u003e Root()\n             .Authentication(() =\u003e new AuthenticationHeaderValue(\"Bearer\", \"[Token]\"))\n             .RefreshToken()\n             .RefreshTokenInvoke(async () =\u003e await PostRefreshAsync(new RefreshRequest { }));\n    \n    public RestBuilder UsersRoot() \n        =\u003e Root().Command(\"/Users\");\n    \n    public RestBuilder DimensionsRoot() \n        =\u003e Root().Command(\"/Dimensions\");\n    \n    public RestBuilder EventsRoot()\n        =\u003e RootAuthentication().Command(\"/Events\");\n    \n    //requests\n\n    public async Task\u003cRestResult\u003cLoginResponse\u003e\u003e PostLoginAsync(LoginRequest request) \n        =\u003e await UsersRoot()\n            .Command(\"/Login\") //[URL]/Users/Login \n            .Payload(request)\n            .PostAsync\u003cLoginResponse\u003e();\n    \n     public async Task\u003cRestResult\u003cRuleResponse\u003e\u003e GetRulesAsync() \n        =\u003e await UsersRoot()\n            .Command(\"/Rules\")\n            .GetAsync\u003cRuleResponse\u003e();\n    \n    public async Task\u003cRestResult\u003cRefreshResponse\u003e\u003e PostRefreshAsync(RefreshRequest request) \n        =\u003e await UsersRoot()\n            .Command(\"/Refresh\")\n            .Payload(request)\n            .PostAsync\u003cRefreshResponse\u003e();\n    \n    public async Task\u003cRestResult\u003cCountryResponse\u003e\u003e PostCountriesAsync(CountryRequest request) \n        =\u003e await DimensionsRoot()\n            .Command(\"/Countries\")\n            .Payload(request)\n            .PostAsync\u003cCountryResponse\u003e();\n\n    public async Task\u003cRestResult\u003cEventDetailResponse\u003e\u003e PostEventDetailAsync(EventDetailRequest request) \n        =\u003e await EventsRoot()\n            .Command(\"/EventDetail\")\n            .Payload(request)\n            .PostAsync\u003cEventDetailResponse\u003e();\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmazzant%2Frestclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffmazzant%2Frestclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmazzant%2Frestclient/lists"}