Skip to content

Commit

Permalink
Adding Support for Approver Expenses (#40)
Browse files Browse the repository at this point in the history
* Adding Support for Approver Expenses

* Updating the version in setup.py

* Updating the Readme with steps

* Fixing import path in Readme
  • Loading branch information
Shwetabhk authored Mar 8, 2022
1 parent 5f231e3 commit 5dc1dcb
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
63 changes: 61 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
# fyle-platform-sdk-py
Python SDK for accessing Fyle Platform APIs
# Fyle

Python SDK for accessing Fyle Platform APIs. [Fyle](https://www.fylehq.com/) is an expense management system.

## Installation

This project requires [Python 3+](https://www.python.org/downloads/) and [Requests](https://pypi.org/project/requests/) library (pip install requests).

1. Download this project and use it (copy it in your project, etc).
2. Install it from [pip](https://pypi.org).

$ pip install fyle

## Usage

To use this SDK you'll need these Fyle credentials used for OAuth2 authentication: **client ID**, **client secret** and **refresh token**. You can follow the steps on this [Article](https://help.fylehq.com/en/articles/3045578-integrating-with-fyle) or reach out to [email protected].

This SDK is very easy to use.
* First you'll need to create a connection using the main class Platform.
```python
from fyle.platform import Platform

fyle = Platform(
server_url='FYLE SERVER URL',
token_url='FYLE TOKEN URL',
refresh_token='FYLE REFRESH TOKEN',
client_id='FYLE CLIENT ID',
client_secret='FYLE CLIENT SECRET'
)
```

* You can access the V1beta version of the APIs as follows:
```python
"""
USAGE: <Platform INSTANCE>.<VERSION: eg. v1beta>.<FYLE ROLE: eg. admin>.<API_NAME: eg. expenses>.<API_METHOD: eg. get>(<PARAMETERS>)
"""

# Get a list of all Expenses in a paginated manner and add to a list
expenses = []

query_params = {
'order': 'created_at.desc'
}

expenses_generator = fyle.v1beta.admin.expenses.list_all(query_params=query_params)

for response in expenses_generator:
if response.get('data'):
expenses.extend(response['data'])

```
## Release latest version to [PyPi](https://pypi.org/project/fyle/)

* Open the releases section on GitHub and [Draft a new release](https://github.com/fylein/fyle-platform-sdk-py/releases/new).
* Check the version in setup.py, make sure you update that version along with your changes.
* Add the version and description and click ok `Publish Release` button.
* This will trigger the github action and automatically push the SDK to PyPi

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
2 changes: 2 additions & 0 deletions fyle/platform/apis/v1beta/approver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from .reports import Reports
from .projects import Projects
from .categories import Categories
from .expenses import Expenses
from ..version import version

role = 'approver'

reports = Reports(version, role)
projects = Projects(version, role)
categories = Categories(version, role)
expenses = Expenses(version, role)
17 changes: 17 additions & 0 deletions fyle/platform/apis/v1beta/approver/expenses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
V1 Beta Approver Expenses
"""

from ....internals.get_resources import GetResources
from ....internals.list_all_resources import ListAllResources
from ....internals.list_resources import ListResources
from ....internals.post_resources import PostResources


class Expenses(ListResources, ListAllResources, PostResources, GetResources):
"""Class for Expenses APIs."""

EXPENSES = '/expenses'

def __init__(self, version, role):
super().__init__(version, role, Expenses.EXPENSES)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='fyle',
version='v0.21.0',
version='v0.22.0',
author='Siva Narayanan',
author_email='[email protected]',
description='Python SDK for accessing Fyle Platform APIs',
Expand Down

0 comments on commit 5dc1dcb

Please sign in to comment.