Giter Club home page Giter Club logo

drapion's Introduction

/// Giancarlo's Profile
/// 
/// I'm a software developer working mainly with rails and flutter
///
/// Find me on:
///   Github   : [giancarlopro]
///   Valorant : [Giancarlo]
class Giancarlo extends Developer {
  final String name  = 'Giancarlo Rocha';
  final String email = '[email protected]';
  
  List<String> get languages => [
    'dart',
    'ruby',
    'javascript',
  ];
  
  List<String> get technologies => [
    'flutter',
    'rails',
    'react',
    'postgresql',
    'mariadb',
  ];
  
  String get OS => 'Arch Linux';
  List<String> get editors => [
    'vscode',
    'vim',
  ];
}

drapion's People

Contributors

giancarlopro avatar

Stargazers

 avatar

Forkers

mishakuzma

drapion's Issues

Support for authentication methods

Authentication

Currently you can authenticate only passing a headers attribute when calling a Drapion instance method.

Would be nice to support ways to authenticate using other ways of authentication.

[Hacktoberfest] Create custom API's classes

How drapion works

Drapion can be used with any web api.
with a drapion instance, you can call methods and pass parameters and the library will know how to connect to the api and parse the response.
e.g.

from drapion import Drapion

api = Drapion('http://some.api/')

response = api.status()
# When you call this status function
# drapion will parse the response from http://some.api/status
# and give it to you as an GenericObject instance
# let's say this is the response: {"api_v1": true}
# the response object will have a 'api_v1' attribute

response.api_v1 # True

How to add new public API's

Check this repo for api's suggestion

  1. Create a file inside drapion/api/ with your api name.
  2. Create a class that inherit's Drapion class.
  3. Call super().__init__() inside your __init__ method, and pass the api root endpoint.
  4. Add a docstring to your class and add your api documentation url inside it

You can check drapion/api/telegram.py for example.

Take this as a skeleton:

# drapion/api/myapi.py

from drapion import Drapion


class MyApi(Drapion)
    """Does something
    
    Check online documentation: http://my.api/docs
    """

    def __init__(self):
        super().__init__('http://my.api/root/')

You can add your class to the __all__ list inside drapion/api/__init__.py file, so your class can be imported directly from drapion.api module. e.g.:

"""
drapion.api
~~~~~~~~~~~~~~~
This module contains specific implementations for public API's
:copyright: (c) 2018 Giancarlo Rocha
:license: Apache 2.0, see LICENSE for more details.
"""

from .telegram import TelegramBotAPI
from .myapi import MyApi


__all__ = ['TelegramBotAPI', 'MyApi']

Now you can do this

from drapion.api import MyApi

Instead of that

from drapion.api.myapi import MyApi

Separate parser logic from GenericObject

A GenericObject instance is created from it's parse class method.
I need to separate this function and create another logic to parse objects into GenericObject.

I want a generic parser that can be inherited by others parsers. That way will be possible to create specific parsers for specific apis.

e.g.
Using drapion with Telegram Bot API, i have responses like this one:
{ "ok":true, "result":{ "id":111111111,"is_bot":true,"first_name":"examplebot","username":"examplebot" }}
so, i want a parser to return only what's inside result key when ok is true, and i want it to raise exceptions, when ok is false, based on the API's response.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.