Skip to content

Commit

Permalink
Fixes lint and english documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gustav0 committed Sep 20, 2022
1 parent 934b596 commit 163a4d0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 26 deletions.
30 changes: 19 additions & 11 deletions mercadopago/resources/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Plan(MPBase):
"""

def search(self, filters=None, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.co/developers/es/reference/subscriptions/_preapproval_plan_search/get) # pylint: disable=line-too-long
"""[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_plan_search/get) # pylint: disable=line-too-long
Args:
request_options (mercadopago.config.request_options, optional): An instance of
Expand All @@ -23,11 +23,13 @@ def search(self, filters=None, request_options=None):
Returns:
dict: Plans found
"""
return self._get(uri="/preapproval_plan/search", filters=filters,
request_options=request_options)
return self._get(
uri="/preapproval_plan/search",
filters=filters,
request_options=request_options)

def get(self, plan_id, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.co/developers/es/reference/subscriptions/_preapproval_plan_id/get) # pylint: disable=line-too-long
"""[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_plan_id/get) # pylint: disable=line-too-long
Args:
plan_id (str): The plan ID
Expand All @@ -38,10 +40,12 @@ def get(self, plan_id, request_options=None):
Returns:
dict: Plan found
"""
return self._get(uri="/preapproval_plan/" + str(plan_id), request_options=request_options)
return self._get(
uri="/preapproval_plan/" + str(plan_id),
request_options=request_options)

def create(self, plan_object, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.co/developers/es/reference/subscriptions/_preapproval_plan/post) # pylint: disable=line-too-long
"""[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_plan/post) # pylint: disable=line-too-long
Args:
plan_object (dict): Plan to be created
Expand All @@ -58,11 +62,13 @@ def create(self, plan_object, request_options=None):
if not isinstance(plan_object, dict):
raise ValueError("Param plan_object must be a Dictionary")

return self._post(uri="/preapproval_plan", data=plan_object,
request_options=request_options)
return self._post(
uri="/preapproval_plan",
data=plan_object,
request_options=request_options)

def update(self, plan_id, plan_object, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.co/developers/es/reference/subscriptions/_preapproval_plan_id/put) # pylint: disable=line-too-long
"""[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_plan_id/put) # pylint: disable=line-too-long
Args:
plan_id (str): The plan ID to be updated
Expand All @@ -80,5 +86,7 @@ def update(self, plan_id, plan_object, request_options=None):
if not isinstance(plan_object, dict):
raise ValueError("Param plan_object must be a Dictionary")

return self._put(uri="/preapproval_plan/" + str(plan_id),
data=plan_object, request_options=request_options)
return self._put(
uri="/preapproval_plan/" + str(plan_id),
data=plan_object,
request_options=request_options)
23 changes: 16 additions & 7 deletions mercadopago/resources/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ def search(self, filters=None, request_options=None):
Returns:
dict: Subscriptions found
"""
return self._get(uri="/preapproval/search", filters=filters, request_options=request_options)
return self._get(
uri="/preapproval/search",
filters=filters,
request_options=request_options)

def get(self, subscription_id, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.co/developers/es/reference/subscriptions/_preapproval_id/get) # pylint: disable=line-too-long
"""[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_id/get) # pylint: disable=line-too-long
Args:
subscription_id (str): The subscription ID
Expand All @@ -37,7 +40,9 @@ def get(self, subscription_id, request_options=None):
Returns:
dict: Subscription found
"""
return self._get(uri="/preapproval/" + str(subscription_id), request_options=request_options)
return self._get(
uri="/preapproval/" + str(subscription_id),
request_options=request_options)

def create(self, subscription_object, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval/post) # pylint: disable=line-too-long
Expand All @@ -57,10 +62,13 @@ def create(self, subscription_object, request_options=None):
if not isinstance(subscription_object, dict):
raise ValueError("Param subscription_object must be a Dictionary")

return self._post(uri="/preapproval", data=subscription_object, request_options=request_options)
return self._post(
uri="/preapproval",
data=subscription_object,
request_options=request_options)

def update(self, subscription_id, subscription_object, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.co/developers/es/reference/subscriptions/_preapproval_id/put) # pylint: disable=line-too-long
"""[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_id/put) # pylint: disable=line-too-long
Args:
subscription_id (str): The subscription ID to be updated
Expand All @@ -79,5 +87,6 @@ def update(self, subscription_id, subscription_object, request_options=None):
raise ValueError("Param subscription_object must be a Dictionary")

return self._put(
uri="/preapproval_plan/" + str(subscription_id), data=subscription_object, request_options=request_options
)
uri="/preapproval/" + str(subscription_id),
data=subscription_object,
request_options=request_options)
16 changes: 8 additions & 8 deletions tests/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def test_all(self):
self.assertEqual(subscription_object["status"], "authorized")

# TODO: WHENEVER I TRY TO UPDATE A SUBSCRIPTION THE API TRHOWS 404.
# update_payload = {
# "reason": f"MercadoPago API Subscription A #{random_reason_number}",
# }
# update_response = self.sdk.subscription().update(
# subscription_object["id"], update_payload)
# self.assertEqual(update_response["status"], 200)
# update_object = update_response["response"]
# self.assertEqual(update_object["reason"], update_payload["reason"])
update_payload = {
"reason": f"MercadoPago API Subscription A #{random_reason_number}",
}
update_response = self.sdk.subscription().update(
subscription_object["id"], update_payload)
self.assertEqual(update_response["status"], 200)
update_object = update_response["response"]
self.assertEqual(update_object["reason"], update_payload["reason"])

get_response = self.sdk.subscription().get(subscription_object["id"])
self.assertEqual(get_response["status"], 200)
Expand Down

0 comments on commit 163a4d0

Please sign in to comment.