diff --git a/paypayopa/constants/url.py b/paypayopa/constants/url.py index 180129f..9a29672 100644 --- a/paypayopa/constants/url.py +++ b/paypayopa/constants/url.py @@ -5,3 +5,4 @@ class URL(object): PAYMENT = "/v2/payments" ACCOUNT_LINK = "/v1/qr/sessions" PENDING_PAYMENT = "/v1/requestOrder" + USER_AUTH = "/v2/user/authorizations" diff --git a/paypayopa/resources/__init__.py b/paypayopa/resources/__init__.py index 03006eb..f8ed16f 100644 --- a/paypayopa/resources/__init__.py +++ b/paypayopa/resources/__init__.py @@ -3,6 +3,7 @@ from .account import Account from .preauth import Preauth from .pending import Pending +from .user import User __all__ = [ 'Code', @@ -10,4 +11,5 @@ 'Account', 'Preauth', 'Pending', + 'User', ] diff --git a/paypayopa/resources/user.py b/paypayopa/resources/user.py new file mode 100644 index 0000000..97ea7dc --- /dev/null +++ b/paypayopa/resources/user.py @@ -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)