diff --git a/.pylintrc b/.pylintrc index 22c463a..702ae8b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,7 +1,5 @@ [MASTER] -[pre-commit-hook] -limit=10 # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may @@ -29,7 +27,7 @@ jobs=1 # complex, nested conditions. limit-inference-results=100 -# List of plugins (as comma separated values of python module names) to load, +# List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. load-plugins= @@ -142,19 +140,26 @@ disable=print-statement, deprecated-sys-function, exception-escape, comprehension-escape, - line-too-long, + no-self-use, + unused-argument, invalid-name, + missing-docstring, + too-many-return-statements, + no-else-raise, + inconsistent-return-statements, + duplicate-code, + no-else-return, + no-member, + simplifiable-if-expression, + broad-except, too-many-arguments, - abstract-class-instantiated, + too-many-locals, too-few-public-methods, - len-as-condition, - duplicate-code, + consider-using-f-string, + missing-timeout, + super-with-arguments, too-many-instance-attributes, - redefined-outer-name, - wildcard-import, - no-value-for-parameter, - unused-wildcard-import, - super-with-arguments + wildcard-import # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -165,11 +170,11 @@ enable=c-extension-no-member [REPORTS] -# Python expression which should return a score less than or equal to 10. You -# have access to the variables 'error', 'warning', 'refactor', and 'convention' -# which contain the number of messages in each category, as well as 'statement' -# which is the total number of statements analyzed. This score is used by the -# global evaluation report (RP0004). +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) # Template used to display messages. This is a python new-style format string @@ -203,7 +208,7 @@ never-returning-functions=sys.exit [LOGGING] # Format style used to check logging format string. `old` means using % -# formatting, `new` is for `{}` formatting,and `fstr` is for f-strings. +# formatting, while `new` is for `{}` formatting. logging-format-style=old # Logging modules to check that the string format arguments are in logging @@ -216,18 +221,18 @@ logging-modules=logging # Limits count of emitted suggestions for spelling mistakes. max-spelling-suggestions=4 -# Spelling dictionary name. Available dictionaries: none. To make it work, -# install the python-enchant package. +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package.. spelling-dict= # List of comma separated words that should not be checked. spelling-ignore-words= -# A path to a file that contains the private dictionary; one word per line. +# A path to a file that contains private dictionary; one word per line. spelling-private-dict-file= -# Tells whether to store unknown words to the private dictionary (see the -# --spelling-private-dict-file option) instead of raising a message. +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. spelling-store-unknown-words=no @@ -274,7 +279,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local # List of module names for which member attributes should not be checked # (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis). It +# and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. ignored-modules= @@ -290,9 +295,6 @@ missing-member-hint-distance=1 # showing a hint for a missing member. missing-member-max-choices=1 -# List of decorators that change the signature of a decorated function. -signature-mutators= - [VARIABLES] @@ -340,7 +342,7 @@ indent-after-paren=4 indent-string=' ' # Maximum number of characters on a single line. -max-line-length=100 +max-line-length=120 # Maximum number of lines in a module. max-module-lines=1000 @@ -495,10 +497,6 @@ check-str-concat-over-line-jumps=no [IMPORTS] -# List of modules that can be imported at any level, not just the top level -# one. -allow-any-import-level= - # Allow wildcard imports from modules that define __all__. allow-wildcard-with-all=no @@ -529,17 +527,13 @@ known-standard-library= # Force import order to recognize a module as part of a third party library. known-third-party=enchant -# Couples of modules and preferred modules, separated by a comma. -preferred-modules= - [CLASSES] # List of method names used to declare (i.e. assign) instance attributes. defining-attr-methods=__init__, __new__, - setUp, - __post_init__ + setUp # List of member names, which should be excluded from the protected access # warning. @@ -564,14 +558,14 @@ max-args=5 # Maximum number of attributes for a class (see R0902). max-attributes=7 -# Maximum number of boolean expressions in an if statement (see R0916). +# Maximum number of boolean expressions in an if statement. max-bool-expr=5 # Maximum number of branch for function / method body. max-branches=12 # Maximum number of locals for function / method body. -max-locals=15 +max-locals=20 # Maximum number of parents for a class (see R0901). max-parents=7 diff --git a/qbosdk/apis/__init__.py b/qbosdk/apis/__init__.py index c93cf69..d9c8430 100644 --- a/qbosdk/apis/__init__.py +++ b/qbosdk/apis/__init__.py @@ -17,6 +17,7 @@ from .bill_payments import BillPayments from .tax_codes import TaxCodes from .tax_rates import TaxRates +from .items import Items __all_ = [ 'Accounts', @@ -34,5 +35,6 @@ 'Customers', 'BillPayments', 'TaxCodes', - 'TaxRates' + 'TaxRates', + 'Items' ] diff --git a/qbosdk/apis/api_base.py b/qbosdk/apis/api_base.py index 16d31a6..2aa792d 100644 --- a/qbosdk/apis/api_base.py +++ b/qbosdk/apis/api_base.py @@ -6,7 +6,8 @@ import requests -from ..exceptions import * +from ..exceptions import WrongParamsError, InvalidTokenError, QuickbooksOnlineSDKError, \ + NoPrivilegeError, NotFoundItemError, ExpiredTokenError, InternalServerError class ApiBase: diff --git a/qbosdk/apis/items.py b/qbosdk/apis/items.py new file mode 100644 index 0000000..747328e --- /dev/null +++ b/qbosdk/apis/items.py @@ -0,0 +1,19 @@ +""" +Quickbooks Online employees +""" + +from .api_base import ApiBase + + +class Items(ApiBase): + """Class for Items APIs.""" + + GET_ITEMS = '/query?query=select * from Item STARTPOSITION {0} MAXRESULTS 1000' + + def get(self): + """Get a list of the existing items in the Organization. + + Returns: + List with dicts in Items schema. + """ + return self._query_get_all('Item', Items.GET_ITEMS) diff --git a/qbosdk/qbosdk.py b/qbosdk/qbosdk.py index bc94ce7..15b0291 100644 --- a/qbosdk/qbosdk.py +++ b/qbosdk/qbosdk.py @@ -6,7 +6,8 @@ import requests from future.moves.urllib.parse import urlencode -from .exceptions import * +from .exceptions import NotFoundClientError, QuickbooksOnlineSDKError, UnauthorizedClientError,\ + WrongParamsError, InternalServerError from .apis import * @@ -60,6 +61,7 @@ def __init__(self, client_id: str, client_secret: str, self.bill_payments = BillPayments() self.tax_codes = TaxCodes() self.tax_rates = TaxRates() + self.items = Items() self.update_server_url() self.update_access_token() @@ -86,6 +88,7 @@ def update_server_url(self): self.bill_payments.set_server_url(base_url) self.tax_codes.set_server_url(base_url) self.tax_rates.set_server_url(base_url) + self.items.set_server_url(base_url) def update_access_token(self): """ @@ -110,6 +113,7 @@ def update_access_token(self): self.bill_payments.change_access_token(access_token) self.tax_codes.change_access_token(access_token) self.tax_rates.change_access_token(access_token) + self.items.change_access_token(access_token) def __get_access_token(self): """Get the access token using a HTTP post. diff --git a/requirements.txt b/requirements.txt index 20cdadb..3a710e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ requests>=2.25.0 -future==0.18.2 \ No newline at end of file +future==0.18.2 +pylint==2.17.2 \ No newline at end of file diff --git a/setup.py b/setup.py index 0da14e2..c4f1b9f 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='qbosdk', - version='0.14.0', + version='0.15.0', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Python SDK for accessing Quickbooks Online APIs',