Skip to content

Commit 5b433e8

Browse files
committed
Api fixes
1 parent 2b10d2e commit 5b433e8

17 files changed

+56
-47
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
# E501 is the "Line too long" error and is disabled since we use the black code formatter.
3+
# W504 is the "line break before binary operator" error and is disabled since we use
4+
# the black code formatter.
5+
# W503 is disabled by default, but must be disabled explicitly when using `ignore`.
6+
ignore = E501, W503, W504

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ coverage.xml
4545
*,cover
4646
.hypothesis/
4747
venv/
48-
.venv/
4948
.python-version
5049
.pytest_cache
5150

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ repos:
88
rev: v1.2.3
99
hooks:
1010
- id: flake8
11+
args: ['--config=.flake8']

patch_api/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@
2525
from patch_api.exceptions import ApiValueError
2626
from patch_api.exceptions import ApiKeyError
2727
from patch_api.exceptions import ApiException
28+
29+
from patch_api.api import *
30+
31+
from patch_api.models import *

patch_api/api/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from __future__ import absolute_import
2+
3+
# flake8: noqa
4+
5+
# import apis into api package
6+
from patch_api.api.estimates_api import EstimatesApi
7+
from patch_api.api.orders_api import OrdersApi
8+
from patch_api.api.preferences_api import PreferencesApi
9+
from patch_api.api.projects_api import ProjectsApi

patch_api/api/estimates_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# python 2 and python 3 compatibility library
1919
import six
2020

21-
from patch_api.api_client import ApiClient
2221
from patch_api.exceptions import ApiTypeError, ApiValueError
2322

2423

@@ -30,8 +29,6 @@ class EstimatesApi(object):
3029
"""
3130

3231
def __init__(self, api_client=None):
33-
if api_client is None:
34-
api_client = ApiClient()
3532
self.api_client = api_client
3633

3734
def create_mass_estimate(

patch_api/api/orders_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# python 2 and python 3 compatibility library
1919
import six
2020

21-
from patch_api.api_client import ApiClient
2221
from patch_api.exceptions import ApiTypeError, ApiValueError
2322

2423

@@ -30,8 +29,6 @@ class OrdersApi(object):
3029
"""
3130

3231
def __init__(self, api_client=None):
33-
if api_client is None:
34-
api_client = ApiClient()
3532
self.api_client = api_client
3633

3734
def cancel_order(self, opts={}, id={}, **kwargs): # noqa: E501

patch_api/api/preferences_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# python 2 and python 3 compatibility library
1919
import six
2020

21-
from patch_api.api_client import ApiClient
2221
from patch_api.exceptions import ApiTypeError, ApiValueError
2322

2423

@@ -30,8 +29,6 @@ class PreferencesApi(object):
3029
"""
3130

3231
def __init__(self, api_client=None):
33-
if api_client is None:
34-
api_client = ApiClient()
3532
self.api_client = api_client
3633

3734
def create_preference(

patch_api/api/projects_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# python 2 and python 3 compatibility library
1919
import six
2020

21-
from patch_api.api_client import ApiClient
2221
from patch_api.exceptions import ApiTypeError, ApiValueError
2322

2423

@@ -30,8 +29,6 @@ class ProjectsApi(object):
3029
"""
3130

3231
def __init__(self, api_client=None):
33-
if api_client is None:
34-
api_client = ApiClient()
3532
self.api_client = api_client
3633

3734
def retrieve_project(self, opts={}, id={}, **kwargs): # noqa: E501

patch_api/api_client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
from patch_api.configuration import Configuration
2727
import patch_api.models
28+
from patch_api.api.projects_api import ProjectsApi
29+
from patch_api.api.orders_api import OrdersApi
30+
from patch_api.api.preferences_api import PreferencesApi
31+
from patch_api.api.estimates_api import EstimatesApi
2832
from patch_api import rest
2933
from patch_api.exceptions import ApiValueError
3034

@@ -94,6 +98,15 @@ def __del__(self):
9498
self._pool.join()
9599
self._pool = None
96100

101+
def __getattr__(self, method):
102+
resource = {
103+
"projects": ProjectsApi,
104+
"orders": OrdersApi,
105+
"preferences": PreferencesApi,
106+
"estimates": EstimatesApi,
107+
}[method]
108+
return resource(api_client=self)
109+
97110
@property
98111
def pool(self):
99112
"""Create thread pool on first request

0 commit comments

Comments
 (0)