Metadata-Version: 2.1
Name: spook
Version: 1.0.0rc1
Summary: Django Rest Framework library to interconnect external APIs
License: MIT
Author: Pablo Moreno
Author-email: pablomoreno.inf@gmail.com
Requires-Python: >=3.7,<4
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: coverage (>=5.3,<6.0)
Requires-Dist: django (>=1.11.0)
Requires-Dist: djangorestframework (>=3.11.0,<4.0.0)
Requires-Dist: requests (>=2.24.0,<3.0.0)
Description-Content-Type: text/markdown

# Django Spook

![PyPI](https://img.shields.io/pypi/v/spook?style=flat-square)
[![codecov](https://codecov.io/gh/pablo-moreno/spook/branch/master/graph/badge.svg?token=6ZAHAHZG7Z)](https://codecov.io/gh/pablo-moreno/spook/)

Library to interconnect multiple external HTTP APIs as Http Services

## Installation

```bash
pip install spook
```

## Usage

Declare your internal model

```python
class MyModel(models.Model):
    name = models.CharField(max_length=16)
    age = models.IntegerField(default=0)
```

Declare a serializer class for your external service

```python
from rest_framework import serializers

class MyModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = MyModel
        fields = ('name', 'age', )
```

Declare a Http Service class and its manager.

```python
from spook.services import HttpService
from spook.managers import DatabaseDataManager

class MyManager(DatabaseDataManager):
    model = MyModel
    serializer = MyModelSerializer

class MyService(HttpService):
    api_url = 'https://my.external/api'
    manager = MyManager
```

And you can instance MyService class and use the methods

```python
service = MyService()

response = service.list()
data = response.queryset
queryset = data.get_queryset()
```

