Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add v2/user/authorizations to SDK as a new resource under User #32

Merged
merged 1 commit into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions paypayopa/constants/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ class URL(object):
PAYMENT = "/v2/payments"
ACCOUNT_LINK = "/v1/qr/sessions"
PENDING_PAYMENT = "/v1/requestOrder"
USER_AUTH = "/v2/user/authorizations"
2 changes: 2 additions & 0 deletions paypayopa/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from .account import Account
from .preauth import Preauth
from .pending import Pending
from .user import User

__all__ = [
'Code',
'Payment',
'Account',
'Preauth',
'Pending',
'User',
]
25 changes: 25 additions & 0 deletions paypayopa/resources/user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from ..resources.base import Resource
from ..constants.url import URL


class User(Resource):
def __init__(self, client=None):
super(User, self).__init__(client)
User.base_url = URL.USER_AUTH

def get_authorization_status(self, id, **kwargs):
url = self.base_url
params = {
"userAuthorizationId": id
}
if id is None:
raise ValueError("\x1b[31m MISSING QUERY PARAM"
" \x1b[0m for userAuthorizationId")
return self.fetch(None, url, params, **kwargs)

def unlink_user_athorization(self, id=None, **kwargs):
if id is None:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for codeId")
url = "{}/{}".format(self.base_url, id)
return self.delete(None, url, **kwargs)