Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omarhimada/pype
Pype is a generic API utility which aims to expedite integration with third-parties. Includes ILogger support
https://github.com/omarhimada/pype
Last synced: about 1 month ago
JSON representation
Pype is a generic API utility which aims to expedite integration with third-parties. Includes ILogger support
- Host: GitHub
- URL: https://github.com/omarhimada/pype
- Owner: omarhimada
- License: apache-2.0
- Created: 2020-03-06T18:31:11.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T09:52:29.000Z (about 2 years ago)
- Last Synced: 2024-12-03T11:40:33.360Z (about 1 month ago)
- Language: C#
- Homepage:
- Size: 111 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pype
Pype is a generic API utility which aims to expedite integration with third-parties. Includes ILogger support![Nuget](https://img.shields.io/nuget/dt/Flopype?logo=nuget&style=flat-square)
***Breaking changes:*** *version 1.1.5 includes a refactoring of the generics implementation.*
**https://www.nuget.org/packages/FloPype/**
### GET example:
```` C#
// Make a fitting to get animals from a zoo API
Fitting animalsFitting = new Fitting
{
ApiBasePath = "https://the-zoo.com",
RequestSuffix = "/api/animals/123",
ContentType = "application/json",
Method = "GET"
};// Send the request asynchronously
FittingResponse response = await animalsFitting.SendRequest();// Check the status of the response
switch (response.Status.Health) { ... }// Do something with the result
Animal myAnimal = response.Result;
````#### POST example:
```` C#
// Make a fitting to create a new animal
Fitting createAnimalFitting = new Fitting
{
ApiBasePath = "https://the-zoo.com",
RequestSuffix = "/api/animals/create",
ContentType = "application/json",
Method = "POST"
};// Parameters can be changed at any point so you can re-use the Fitting
createAnimalFitting.Parameters = new Dictionary
{
{ "Name", "Zebra" },
{ "Stripes", true },
{ "Legs", 4 }
};// Send the request asynchronously
FittingResponse response = await createAnimalFitting.SendRequest();// Check the status of the response
switch (response.Status.Health) { ... }// Do something with the result
Animal myNewAnimal = response.Result;
````### 'OpenFaucet' to return a Stream
*Use this if you don't want to hold the response in memory for performance reasons.*
````C#
using (Stream stream = await _fitting.OpenFaucet())
using (StreamReader sr = new StreamReader(stream))
using (JsonReader reader = new JsonTextReader(sr))
{
JsonSerializer serializer = new JsonSerializer();// * For performance: read the JSON response from a stream
SomeBigThing response = serializer.Deserialize(reader);
...
}
````