Metadata-Version: 2.2
Name: gefest_simple_rest_client
Version: 1.2025.3.16
Summary: Abstractions for create REST API client
Author-email: "Sergei (Gefest) Romanchuk" <pod.cargoes.0u@icloud.com>
License: MIT License
        
        Copyright (c) 2025 Sergei Romanchuk
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: homepage, https://github.com/GefMar/gefest_simple_rest_client
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.28.1

# Gefest Simple REST Client

## Description
**Gefest Simple REST Client** is a library designed to simplify the creation of REST API clients in Python. Built on `httpx`, it provides both synchronous and asynchronous API interaction.

## Features
- 🛠️ Abstraction of clients and endpoints
- ⚙️ Support for both synchronous (`httpx.Client`) and asynchronous (`httpx.AsyncClient`) request models
- ✅ Dynamic access to endpoints
- ✨ URL templates for handling path parameters

## Installation
```sh
pip install gefest_simple_rest_client
```

## Usage Example
```python
from gefest_simple_rest_client.client import BaseClient
from gefest_simple_rest_client.endpoint import BaseEndpoint, PathTemplate

class MyEndpoint(BaseEndpoint):
    name = "example"
    path_template = PathTemplate("/example/{id:int}")

class MyClient(BaseClient):
    base_url = "https://api.example.com"
    headers = {"Authorization": "Bearer YOUR_TOKEN"}
    endpoints = [MyEndpoint]

client = MyClient()
```

### Synchronous Usage
```python
response = client.example.get(path_params={"id": 123})
print(response.json())
```

### Asynchronous Usage
```python
import asyncio

async def fetch():
    async with MyClient() as client:
        response = await client.example.get_async(path_params={"id": 123})
        print(response.json())

asyncio.run(fetch())
```

## Errors when Passing Invalid Path Parameters
If incorrect parameters are provided, exceptions are raised:

```python
try:
    response = client.example.get(path_params={"id": "invalid_string"})
except Exception as e:
    print(f"Error: {e}")
```

Example error:
```
PathParamsValidationError: Parameter 'id' must be of type int
```

## Feedback
If you have any questions or suggestions, feel free to reach out via [GitHub Issues](https://github.com/GefMar/gefest_simple_rest_client/issues).
