Skip to content

Commit

Permalink
Items support for QBO SDK (#18)
Browse files Browse the repository at this point in the history
* Items support

* fixing lint check

* adding pylint to requirement.txt file

* bumping version
  • Loading branch information
labhvam5 authored Apr 11, 2023
1 parent 871c73a commit 2aa752e
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 44 deletions.
72 changes: 33 additions & 39 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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=

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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=

Expand All @@ -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]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion qbosdk/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -34,5 +35,6 @@
'Customers',
'BillPayments',
'TaxCodes',
'TaxRates'
'TaxRates',
'Items'
]
3 changes: 2 additions & 1 deletion qbosdk/apis/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import requests

from ..exceptions import *
from ..exceptions import WrongParamsError, InvalidTokenError, QuickbooksOnlineSDKError, \
NoPrivilegeError, NotFoundItemError, ExpiredTokenError, InternalServerError


class ApiBase:
Expand Down
19 changes: 19 additions & 0 deletions qbosdk/apis/items.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 5 additions & 1 deletion qbosdk/qbosdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *


Expand Down Expand Up @@ -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()
Expand All @@ -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):
"""
Expand All @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
requests>=2.25.0
future==0.18.2
future==0.18.2
pylint==2.17.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 2aa752e

Please sign in to comment.