Skip to content

Commit

Permalink
API v2 ready
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTempel committed Apr 13, 2018
1 parent 7647750 commit b41a7d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions weebapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__author__ = 'AndyTempel'
__license__ = 'MIT'
__copyright__ = 'Copyright 2018 AndyTempel'
__version__ = '0.1.7b'
__version__ = '0.1.8b'

import logging
from collections import namedtuple
Expand All @@ -18,7 +18,7 @@

VersionInfo = namedtuple('VersionInfo', 'major minor micro releaselevel serial')

version_info = VersionInfo(major=0, minor=1, micro=7, releaselevel='beta', serial=0)
version_info = VersionInfo(major=0, minor=1, micro=8, releaselevel='beta', serial=0)

try:
from logging import NullHandler
Expand Down
18 changes: 12 additions & 6 deletions weebapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
import logging

from .data_objects import *
from .request_lib import krequest
from .router import Router
from .errors import *
from .img_gen import ImgGen
from .request_lib import krequest
from .router import Router

BASE_URL = "https://api.weeb.sh/"
BASE_URL_V2 = "https://api-v2.weeb.sh/"
logger = logging.getLogger()


Expand All @@ -33,6 +34,10 @@ class Client:
*Not required.*
Is the api token type Wolke or Bearer.
**Default:** True
v2_api: bool[Optional]
*Not required.*
Use v2 API.
**Default:** False
check_ssl: bool[Optional]
*Not required.*
Enable SSL certificate verification.
Expand All @@ -47,8 +52,11 @@ class Client:
Your bot client from discord.py
"""
def __init__(self, api_key: str, wolke_token: bool = True, check_ssl: bool = True, base_url: str = BASE_URL,
bot=None):

def __init__(self, api_key: str, wolke_token: bool = True, check_ssl: bool = True, v2_api: bool = False,
base_url: str = BASE_URL, bot=None):
if v2_api is True:
base_url = BASE_URL_V2
self.api_key = api_key
self.check_ssl = check_ssl
self.route = Router(base_url)
Expand All @@ -61,8 +69,6 @@ def __init__(self, api_key: str, wolke_token: bool = True, check_ssl: bool = Tru
logger_string = str("Wolke " if wolke_token else "Bearer ") + self.api_key[-4:].rjust(len(self.api_key), "*")
logger.info(f"WEEB.SH Logging in as {logger_string}")



@classmethod
def pluggable(cls, bot, api_key: str, *args, **kwargs):
"""
Expand Down

0 comments on commit b41a7d4

Please sign in to comment.