Skip to content

Commit

Permalink
Fix bug in baseapi
Browse files Browse the repository at this point in the history
  • Loading branch information
gray-adeyi committed Aug 22, 2022
1 parent 5bf03f5 commit e0f2af4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ in the `Invoice` wrapper. Say you wanted to create an invoice by sending a
```python
from pypaystack2.api import Invoice
invoice_wrapper = Invoice()
response = invoice_wrapper.create(custmer="CUS_xwaj0txjryg393b",amount=1000) # Creates an invoice with a charge of ₦100
response = invoice_wrapper.create(customer="CUS_xwaj0txjryg393b",amount=10000) # Creates an invoice with a charge of ₦100
print(response)
```

From here you can check out the tutorials section to get more examples and get familiar or surf the
Expand Down
13 changes: 6 additions & 7 deletions pypaystack2/baseapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from typing import Any, Dict, NamedTuple, Union
from pyparsing import Optional
from typing import Any, Dict, NamedTuple, Union, Optional
import requests
from requests import Response as RResponse
import json
Expand All @@ -15,7 +14,7 @@

class Response(NamedTuple):
"""A namedtuple that models the data gotten from making a request to
paystacks API endpoints.
paystack's API endpoints.
Parameters
----------
Expand Down Expand Up @@ -44,13 +43,13 @@ class BaseAPI:
_CONTENT_TYPE = "application/json"
_BASE_END_POINT = "https://api.paystack.co"

def __init__(self, auth_key: str = None):
def __init__(self, auth_key: Optional[str] = None):
"""
Parameters
----------
auth_key:
Your paystack authorization key. Required only
if it is not provided in your enviromental
if it is not provided in your environmental
variables as ``PAYSTACK_AUTHORIZATION_KEY=your_key``
"""
Expand Down Expand Up @@ -78,7 +77,7 @@ def _headers(self) -> dict[str, str]:
def _parse_json(self, response_obj: RResponse) -> Response:
"""
This function takes in every json response sent back by the
server and trys to get out the important return variables
server and tries to get out the important return variables
Returns a python namedtuple of Response which contains
status code, status(bool), message, data
Expand Down Expand Up @@ -110,7 +109,7 @@ def _handle_request(
request = method_map.get(method)

if not request:
raise InvalidMethodError("Request method not recognised or implemented")
raise InvalidMethodError("Request method not recognized or implemented")

response = request(url, headers=self._headers(), data=payload, verify=True)
if response.status_code == 404:
Expand Down
2 changes: 1 addition & 1 deletion pypaystack2/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "pypaystack2"
__version__ = "1.0.0"
__version__ = "1.0.1"
__author__ = ["Gbenga Adeyi"]
__license__ = "MIT"
__copyright__ = "Copyright 2022."
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pypaystack2"
version = "1.0.0"
version = "1.0.1"
description = "A fork of PyPaystack. A simple python wrapper for Paystack API."
authors = ["Gbenga Adeyi"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pypaystack2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == "1.0.0"
assert __version__ == "1.0.1"

0 comments on commit e0f2af4

Please sign in to comment.