Skip to content

Commit 47a5efb

Browse files
committed
api v2 changes
1 parent b0b660d commit 47a5efb

13 files changed

Lines changed: 874 additions & 281 deletions

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ Rename .env.example > .env
1919

2020
## Usage
2121

22-
Setup (ApiKey/Secret requiered):
22+
###Setup Public:
2323

2424
from surbtc import SURBTC
25-
client = SURBTC(API_KEY, API_SECRET)
25+
client = SURBTC.Public()
2626

27-
Market Pairs:
27+
###Setup Auth (ApiKey/Secret requiered, Test is optional (default: False)):
28+
29+
from surbtc import SURBTC
30+
client = SURBTC.Auth(API_KEY, API_SECRET, TEST)
31+
32+
## Market Pairs:
2833

2934
btc-clp
3035
btc-cop

requierements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
coverage==4.3
1+
coverage==4.3.4
22
python-decouple==3.0
3-
requests==2.12.4
3+
requests==2.13.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='surbtc',
5-
version='0.1.0',
5+
version='0.2.0',
66
description='SURBTC API Wrapper for Python 3',
77
url='https://github.com/delta575/python-surbtc-api',
88
author='Felipe Aránguiz, Sebastian Aránguiz',

surbtc/__init__.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1-
from .client import SURBTC
1+
from . import constants as _c
2+
from . import models as _m
3+
from .client_auth import SURBTCAuth
4+
from .client_public import SURBTCPublic
25

3-
__all__ = SURBTC
6+
7+
class SURBTC(object):
8+
# Models
9+
models = _m
10+
# Enum Types
11+
BalanceEvent = _c.BalanceEvent
12+
Currency = _c.Currency
13+
Market = _c.Market
14+
OrderState = _c.OrderState
15+
OrderType = _c.OrderType
16+
OrderPriceType = _c.OrderPriceType
17+
QuotationType = _c.QuotationType
18+
ReportType = _c.ReportType
19+
# Clients
20+
Auth = SURBTCAuth
21+
Public = SURBTCPublic
22+
23+
24+
__all__ = [
25+
SURBTCAuth,
26+
SURBTCPublic,
27+
]

surbtc/base.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import json
22
from urllib.parse import urlparse
3+
34
# pip
45
import requests
56
# local
6-
from .common import (check_response,
7-
log_request_exception,
8-
log_json_decode)
7+
from .common import (check_response, log_json_decode,
8+
log_request_exception)
99

1010

1111
class Server(object):
12+
1213
def __init__(self, protocol, host, version=None):
1314
url = '{0:s}://{1:s}'.format(protocol, host)
1415
if version:
@@ -21,6 +22,7 @@ def __init__(self, protocol, host, version=None):
2122

2223

2324
class Client(object):
25+
2426
def __init__(self, server: Server, timeout=30):
2527
self.SERVER = server
2628
self.TIMEOUT = timeout
@@ -42,17 +44,25 @@ def post(self, url, headers, data):
4244

4345
def _request(self, method, url, headers, params=None, data=None):
4446
try:
45-
data = json.dumps(data) if data else data
47+
data = self._encode_data(data)
4648
response = requests.request(
47-
method, url, headers=headers, params=params, data=data,
48-
verify=True, timeout=self.TIMEOUT
49-
)
49+
method,
50+
url,
51+
headers=headers,
52+
params=params,
53+
data=data,
54+
verify=True,
55+
timeout=self.TIMEOUT)
5056
response.raise_for_status()
5157
return response
5258
except requests.exceptions.RequestException as err:
5359
log_request_exception(err)
5460
raise
5561

62+
def _encode_data(self, data):
63+
data = json.dumps(data) if data else data
64+
return data
65+
5666
def _resp_to_json(self, response):
5767
try:
5868
json_resp = response.json()
@@ -71,4 +81,4 @@ def url_for(self, path, path_arg=None):
7181
def url_path_for(self, path, path_arg=None):
7282
url = self.url_for(path, path_arg)
7383
path = urlparse(url).path
74-
return url, path
84+
return url, path

surbtc/client.py

Lines changed: 0 additions & 207 deletions
This file was deleted.

0 commit comments

Comments
 (0)