diff --git a/.gitignore b/.gitignore index cc18c4f..959fd04 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,5 @@ target/ .pypirc .vscode/ + +notes.txt diff --git a/README.md b/README.md index b54cc00..b84d85c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ paystack.subscription.list() ## DOC Reference: +### API Reference: [API](https://paystack.com/docs/api/) + ### Other methods can be found in the docs folder ### Static Use @@ -76,4 +78,4 @@ Verification ``` -Please reference the **docs** folder for usage, +Please reference the **[docs](https://github.com/andela-sjames/paystack-python/tree/master/docs)** folder for usage, diff --git a/docs/customers.md b/docs/customers.md index be443fa..5ac3b0b 100644 --- a/docs/customers.md +++ b/docs/customers.md @@ -35,16 +35,26 @@ response = Customer.get(customer_id=24) JSON data from paystack API. -##### `Customer.list()` - List paystack customers +##### `Customer.list(perPage=50, page=6)` - List paystack customers ```python from paystackapi.customer import Customer -response = Customer.list() +response = Customer.list(perPage=50, page=6) ``` *Arguments* -No argument required. +- `perPage`: Specify how many records you want to retrieve per page. + If not specify we use a default value of 50. (Integer) + +- `page`: Specify exactly what page you want to retrieve. + defaults to 1 if not present(Integer) + +- `from`: A timestamp from which to start listing customers. + e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime) + +- `to`: A timestamp at which to stop listing customers. + e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime) *Returns* diff --git a/docs/verification.md b/docs/verification.md index a6363ab..d72122f 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -16,6 +16,27 @@ response = Verification.verify_bvn(account_number='1234567890') JSON data from paystack API. +##### `Verification.verify_bvn_match(bvn)` - verify BVN match with account number, first name and last name + +```python +from paystackapi.verification import Verification +response = Verification.verify_bvn_match(bvn='1234567890',account_number='34334343',bank_code='34343' ) +``` + +*Arguments* + +- `bvn`: customer's bvn number +- `account_number`: customer's account number +- `bank_code`: customer's bank code +- `first_name`: customer's first name (Optional) +- `last_name`: customer's last name (Optional) +- `middle_name`: customer's middle name (Optional) + +*Returns* + +JSON data from paystack API. + + ##### `Verification.verify_account(account_number)` - verify a customer's BVN ```python diff --git a/paystackapi/customer.py b/paystackapi/customer.py index 6a3bcd1..a27fdb1 100644 --- a/paystackapi/customer.py +++ b/paystackapi/customer.py @@ -35,16 +35,27 @@ def get(cls, customer_id): return cls().requests.get(f"customer/{customer_id}") @classmethod - def list(cls): + def list(cls, **kwargs): """ Static method defined to list paystack customers. Args: - No argument required. + perPage: Specify how many records you want to retrieve per page. + If not specify we use a default value of 50. (Integer) + + page: Specify exactly what page you want to retrieve. + defaults to 1 if not present(Integer) + + from: A timestamp from which to start listing customers + e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime) + + to: A timestamp at which to stop listing customers + e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime) + Returns: Json data from paystack API. """ - return cls().requests.get('customer') + return cls().requests.get('customer', qs=kwargs,) @classmethod def update(cls, customer_id, **kwargs): diff --git a/paystackapi/tests/test_customer.py b/paystackapi/tests/test_customer.py index aff181a..94fe961 100644 --- a/paystackapi/tests/test_customer.py +++ b/paystackapi/tests/test_customer.py @@ -50,7 +50,7 @@ def test_list(self): status=201, ) - response = Customer.list() + response = Customer.list(perPage=50, page=6) self.assertEqual(response['status'], True) @httpretty.activate diff --git a/paystackapi/tests/test_verification.py b/paystackapi/tests/test_verification.py index 01848a3..ab61625 100644 --- a/paystackapi/tests/test_verification.py +++ b/paystackapi/tests/test_verification.py @@ -23,6 +23,24 @@ def test_verify_bvn(self): response = Verification.verify_bvn(bvn='01234567689') self.assertTrue(response['status']) + + @httpretty.activate + def test_verify_bvn_match(self): + """Method defined to test bvn match verification.""" + httpretty.register_uri( + httpretty.POST, + self.endpoint_url("/bank/resolve"), + content_type='text/json', + body='{"status": true, "contributors": true}', + status=201, + ) + + response = Verification.verify_bvn_match( + bvn='01234567689', + account_number='123456', + bank_code='093') + self.assertTrue(response['status']) + @httpretty.activate def test_verify_account(self): """Method defined to test account number verification.""" diff --git a/paystackapi/verification.py b/paystackapi/verification.py index ba20a79..6e8e635 100644 --- a/paystackapi/verification.py +++ b/paystackapi/verification.py @@ -18,6 +18,38 @@ def verify_bvn(cls, bvn): Json data from paystack API. """ return cls().requests.get(f"bank/resolve_bvn/{bvn}") + + @classmethod + def verify_bvn_match(cls, **kwargs): + """ + Verify bvn match with account number, first name and last name + Args: + bvn: customer's bvn + account_number: customer's account number + bank_code: customer's bank code + first_name: customer's first name (Optional) + last_name: customer's last name (Optional) + middle_name: customer's middle name (Optional) + Returns: + Json data from paystack API. + { + "status": true, + "message": "BVN lookup successful", + "data": { + "bvn": "xxxxxxxxxxx", + "is_blacklisted": false, + "account_number": true, + "first_name": true, + "middle_name": false, + "last_name": true + }, + "meta": { + "calls_this_month": 1, + "free_calls_left": 9 + } + } + """ + return cls().requests.post('bank/resolve', data=kwargs) @classmethod def verify_account(cls, **kwargs): diff --git a/requirements.txt b/requirements.txt index 1243bb2..7ebcc10 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,4 +23,4 @@ six==1.10.0 sure==1.2.24 tqdm==4.25.0 twine==1.11.0 -urllib3==1.24.2 +urllib3==1.26.5 diff --git a/setup.py b/setup.py index 2eaa746..3a10803 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( name='paystackapi', - version='2.0.0', + version='2.1.0', description='A python library to consume Paystack API', long_description=long_description, long_description_content_type='text/markdown',