Metadata-Version: 2.1
Name: pydantic-fetch
Version: 0.0.2
Summary: Extension of pydantic models for HTTP send/recieve
Home-page: https://github.com/bayinfosys/pydantic-fetch
Author: ed
Author-email: ed@bayis.co.uk
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: pydantic
Provides-Extra: httpx
Requires-Dist: httpx ; extra == 'httpx'
Provides-Extra: tests
Requires-Dist: mock ; extra == 'tests'
Requires-Dist: pytest ; extra == 'tests'

# Pydantic-fetch

Extension of `pydantic.BaseModel` which supports sending and parsing from HTTP endpoints.

## Description

`BaseModel` is extended with two class functions:

+ `fetch` to recieve a json payload from an endpoint and validate it as the pydantic model
+ `submit` to send a pydantic model to an endpoint as a json payload.

## Usage

```python3
from pydantic_fetch import BaseModel

class User(BaseModel):
  id: str
  name: str


def send_user(endpoint, id: str, name: str):
  user = User(id=id, name=name)
  user.submit(endpoint)


def get_user(endpoint):
  user = User.fetch(endpoint)
```

