Skip to content

Commit

Permalink
Merge pull request #3 from Chapa-Et/main
Browse files Browse the repository at this point in the history
Merge changes
  • Loading branch information
adilmohak committed Jun 2, 2023
2 parents a946560 + 04980d0 commit 9819120
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 53 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/Linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,3 @@ jobs:
- name: Analysing the code with pylint
run: |
pylint chapa/*
Publish-Package:
runs-on: ubuntu-latest
needs:
- build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Publish the package
uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
37 changes: 37 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deployment

# deploy package to pypi on condition of
# push to main branch
# and release published

on:
release:
types:
- published

jobs:
Publish-Package:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9

- name: Version the package
run: |
echo "__version__ = '${{ github.ref_name }}'" > chapa/__init__.py
export CHAPA_VERSION=${{ github.ref_name }}
- name: Install pypa/build
run: |
python -m pip install build
python -m pip install wheel twine setuptools
- name: Build a binary wheel and a source tarball
run: python -m build

- name: Publish distribution 📦 to PyPI
run: python -m twine upload dist/* --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ lib/
lib64/
parts/
sdist/
dist/
var/
wheels/
pip-wheel-metadata/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Chapa

[![Linter](https://github.com/chapimenge3/chapa/actions/workflows/Linter.yml/badge.svg)](https://github.com/chapimenge3/chapa/actions/workflows/Linter.yml)
[![Version](https://img.shields.io/static/v1?label=version&message=0.0.1&color=green)](https://travis-ci.com/chapimenge3/chapa)
[![Build](https://github.com/chapimenge3/chapa/actions/workflows/Linter.yml/badge.svg)](https://travis-ci.com/chapimenge3/chapa)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://choosealicense.com/licenses/mit)
Expand Down
54 changes: 54 additions & 0 deletions chapa/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,57 @@ def verify(self, transaction, headers=None):
headers=headers
)
return response

def get_banks(self, headers=None):
"""Get the list of all banks
Response:
dict: response from the server
response(Response): response object of the response data return from the Chapa server.
"""
response = self._construct_request(
url=f"{self.base_url}/{self.api_version}/banks",
method="get",
headers=headers,
)
return response

def create_subaccount(
self,
business_name: str,
account_name: str,
bank_code: str,
account_number: str,
split_type: str,
split_value: float,
headers=None,
):
"""Create a subaccount
Args:
business_name (str): The vendor/merchant detail the subaccount for
account_name (str): The vendor/merchant account`s name matches from the bank account
bank_code (str): The bank id (you can get this from the get_banks method)
account_number (str): The bank account number for this subaccount
split_type (str): The type of split you want to use with this subaccount
(percentage or flat)
split_value (float): The amount you want to get as commission on each transaction
Response:
dict: response from the server
response(Response): response object of the response data return from the Chapa server.
"""
data = {
"business_name": business_name,
"account_name": account_name,
"bank_code": bank_code,
"account_number": account_number,
"split_value": split_value,
"split_type": split_type,
}
response = self._construct_request(
url=f"{self.base_url}/{self.api_version}/subaccount",
method="post",
data=data,
headers=headers,
)
return response
Binary file removed dist/Chapa-0.0.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/Chapa-0.0.1.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools>=42"]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
requests==2.27.1
requests==2.31.0
43 changes: 24 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
from ensurepip import version
import setuptools
import os

with open("README.md", "r", encoding="utf-8") as fh:
with open('README.md', 'r', encoding='utf-8') as fh:
long_description = fh.read()

version = os.environ.get('CHAPA_VERSION')

setuptools.setup(
name="Chapa",
version="0.0.1",
author="Temkin Mengistu, Chapi",
author_email="chapimenge3@gmail.com",
description="Python SDK for Chapa API https://developer.chapa.co",
name='chapa',
version=version,
author='Temkin Mengistu (Chapi)',
author_email='chapimenge3@gmail.com',
description='Python SDK for Chapa API https://developer.chapa.co',
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/chapimenge3/chapa",
long_description_content_type='text/markdown',
url='https://github.com/chapimenge3/chapa',
packages=['chapa'],
package_dir={'chapa': 'chapa'},
project_urls={
"Bug Tracker": "https://github.com/chapimenge3/chapa/issues",
'Source': 'https://github.com/chapimenge3/chapa',
'Bug Tracker': 'https://github.com/chapimenge3/chapa/issues',
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
],
package_dir={"chapa": "chapa"},
packages=setuptools.find_packages(),
python_requires=">=3.6",
python_requires='>=3.6',
install_requires=[
"requests",
'requests',
],
)

0 comments on commit 9819120

Please sign in to comment.