Skip to content

Commit

Permalink
Merge pull request #57 from mercadopago/release/2.1.0
Browse files Browse the repository at this point in the history
Release/2.1.0
  • Loading branch information
eltinMeli authored Apr 5, 2022
2 parents 55fca29 + e4fe040 commit c65b2cd
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.py[cod]
*.pyc
.DS_Store
.idea
venv

# C extensions
Expand Down
4 changes: 2 additions & 2 deletions docs/config/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 class="title">Module <code>mercadopago.config.config</code></h1>
&#34;&#34;&#34;

def __init__(self):
self.__version = &#34;2.0.10&#34;
self.__version = &#34;2.1.0&#34;
self.__user_agent = &#34;MercadoPago Python SDK v&#34; + self.__version
self.__product_id = &#34;bc32bpftrpp001u8nhlg&#34;
self.__tracking_id = &#34;platform:&#34; + platform.python_version()
Expand Down Expand Up @@ -123,7 +123,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
&#34;&#34;&#34;

def __init__(self):
self.__version = &#34;2.0.10&#34;
self.__version = &#34;2.1.0&#34;
self.__user_agent = &#34;MercadoPago Python SDK v&#34; + self.__version
self.__product_id = &#34;bc32bpftrpp001u8nhlg&#34;
self.__tracking_id = &#34;platform:&#34; + platform.python_version()
Expand Down
2 changes: 1 addition & 1 deletion docs/config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
&#34;&#34;&#34;

def __init__(self):
self.__version = &#34;2.0.10&#34;
self.__version = &#34;2.1.0&#34;
self.__user_agent = &#34;MercadoPago Python SDK v&#34; + self.__version
self.__product_id = &#34;bc32bpftrpp001u8nhlg&#34;
self.__tracking_id = &#34;platform:&#34; + platform.python_version()
Expand Down
2 changes: 1 addition & 1 deletion mercadopago/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Config:
"""

def __init__(self):
self.__version = "2.0.10"
self.__version = "2.1.0"
self.__user_agent = "MercadoPago Python SDK v" + self.__version
self.__product_id = "bc32bpftrpp001u8nhlg"
self.__tracking_id = "platform:" + platform.python_version()
Expand Down
2 changes: 2 additions & 0 deletions mercadopago/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from mercadopago.resources.preference import Preference
from mercadopago.resources.refund import Refund
from mercadopago.resources.user import User
from mercadopago.resources.chargeback import Chargeback


__all__ = (
Expand All @@ -34,4 +35,5 @@
'Refund',
'RequestOptions',
'User',
'Chargeback',
)
41 changes: 41 additions & 0 deletions mercadopago/resources/chargeback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Module: chargeback
"""
from mercadopago.core import MPBase


class Chargeback(MPBase):
"""
Access to Chargebacks
[Click here for more info](https://www.mercadopago.com.br/developers/pt/guides/manage-account/account/chargebacks) # pylint: disable=line-too-long
"""

def search(self, filters=None, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.br/developers/pt/reference/chargebacks/_chargebacks_search/get) # pylint: disable=line-too-long
Args:
request_options (mercadopago.config.request_options, optional): An instance of
RequestOptions can be pass changing or adding custom options to ur REST call.
Defaults to None.
Returns:
dict: Chargeback find response
"""
return self._get(uri="/v1/chargebacks/search", filters=filters,
request_options=request_options)

def get(self, chargeback_id, request_options=None):
"""[Click here for more info](https://www.mercadopago.com.br/developers/pt/reference/chargebacks/_chargebacks_id/get) # pylint: disable=line-too-long
Args:
chargeback_id (str): The Chargeback ID
request_options (mercadopago.config.request_options, optional): An instance of
RequestOptions can be pass changing or adding custom options to ur REST call.
Defaults to None.
Returns:
dict: Chargeback find response
"""
return self._get(uri="/v1/chargebacks/" + str(chargeback_id),
request_options=request_options)
9 changes: 9 additions & 0 deletions mercadopago/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Preference,
Refund,
User,
Chargeback,
)


Expand All @@ -36,6 +37,7 @@ class SDK:
11. Preference
12. Refund
13. User
14. Chargeback
"""

def __init__(
Expand Down Expand Up @@ -157,6 +159,13 @@ def user(self, request_options=None):
return User(request_options is not None and request_options
or self.request_options, self.http_client)

def chargeback(self, request_options=None):
"""
Returns the attribute value of the function
"""
return Chargeback(request_options is not None and request_options
or self.request_options, self.http_client)

@property
def request_options(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="mercadopago",
version="2.0.10",
version="2.1.0",
description="Mercadopago SDK module for Payments integration",
author="Mercado Pago SDK",
author_email="[email protected]",
Expand Down
7 changes: 6 additions & 1 deletion tests/test_advanced_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ def test_all(self):
}
}

print(self.sdk.advanced_payment().create(advanced_payment_object))
advanced_payment_created = self.sdk.advanced_payment().create(advanced_payment_object)
self.assertEqual(advanced_payment_created["status"], 201)

advanced_payment_found = self.sdk.advanced_payment().get(
advanced_payment_created["response"]["id"])
self.assertEqual(advanced_payment_found["status"], 200)


if __name__ == "__main__":
Expand Down
7 changes: 2 additions & 5 deletions tests/test_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TestCard(unittest.TestCase):
@classmethod
def setUpClass(cls):
customer_data = cls.create_customer()
print(customer_data)
cls._customer_id = customer_data["response"]["id"]

@classmethod
Expand All @@ -45,6 +46,7 @@ def test_all(self):
}

card_token_created = self.sdk.card_token().create(card_token_object)
print(card_token_created)

card_object = {
"customer_id": self._customer_id,
Expand Down Expand Up @@ -74,11 +76,6 @@ def create_customer(cls):
"type": "DNI",
"number": "29804555"
},
"address": {
"zip_code": "47807078",
"street_name": "some street",
"street_number": 123
},
"description": "customer description"
}

Expand Down
29 changes: 29 additions & 0 deletions tests/test_chargeback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Module: test_chargeback
"""
import unittest

import mercadopago


class TestChargeback(unittest.TestCase):
"""
Test Module: Chargeback
"""
sdk = mercadopago.SDK(
"APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966")

def test_search_chargeback(self):
"""
Test Function: Chargeback
"""
filters_chargeback = {
"payment_id": "12345"
}

chargebacks = self.sdk.chargeback().search(filters=filters_chargeback)
self.assertEqual(chargebacks["status"], 200)


if __name__ == "__main__":
unittest.main()
11 changes: 3 additions & 8 deletions tests/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,23 @@ def test_all(self):
"type": "DNI",
"number": "29804555"
},
"address": {
"zip_code": "47807078",
"street_name": "some street",
"street_number": 123
},
"description": "customer description"
}

customer_saved = self.sdk.customer().create(customer_object)
self.assertEqual(customer_saved["status"], 201)
self.assertEqual(201, customer_saved["status"])

customer_update = self.sdk.customer().update(
customer_saved["response"]["id"], {"last_name": "Payer"})
self.assertEqual(customer_update["status"], 200)
self.assertEqual(200, customer_update["status"])

customer_updated = self.sdk.customer().get(
customer_saved["response"]["id"])
self.assertEqual(customer_updated["response"]["last_name"], "Payer")

customer_deleted = self.sdk.customer().delete(
customer_saved["response"]["id"])
self.assertEqual(customer_deleted["status"], 200)
self.assertEqual(200, customer_deleted["status"])


if __name__ == "__main__":
Expand Down

0 comments on commit c65b2cd

Please sign in to comment.