Skip to content

Commit

Permalink
Added required admin apis
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyansh committed Dec 7, 2020
1 parent ddd6e31 commit 4e869ea
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 6 deletions.
12 changes: 12 additions & 0 deletions fyle/platform/apis/v1/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,46 @@
Intializing Admin API's
"""

from .advance_requests_stats import AdvanceRequestsStats
from .advance_requests import AdvanceRequests
from .advances import Advances
from .balance_transfers import BalanceTransfers
from .categories import Categories
from .cost_centers import CostCenters
from .employees import Employees
from .expense_comments import ExpenseComments
from .expense_fields import ExpenseFields
from .expense_stats import ExpenseStats
from .expenses import Expenses
from .policy import Policy
from .projects import Projects
from .refunds import Refunds
from .reimbursements import Reimbursements
from .report_stats import ReportStats
from .reports import Reports
from .settlements import Settlements
from .trip_requests_stats import TripRequestsStats

from ..version import version

role = 'admin'

advance_requests_stats = AdvanceRequestsStats(version, role)
advance_requests = AdvanceRequests(version, role)
advances = Advances(version, role)
balance_transfers = BalanceTransfers(version, role)
categories = Categories(version, role)
cost_centers = CostCenters(version, role)
employees = Employees(version, role)
expense_comments = ExpenseComments(version, role)
expense_fields = ExpenseFields(version, role)
expense_stats = ExpenseStats(version, role)
expenses = Expenses(version, role)
policy = Policy(version, role)
projects = Projects(version, role)
refunds = Refunds(version, role)
reimbursements = Reimbursements(version, role)
report_stats = ReportStats(version, role)
reports = Reports(version, role)
settlements = Settlements(version, role)
trip_requests_stats = TripRequestsStats(version, role)
14 changes: 14 additions & 0 deletions fyle/platform/apis/v1/admin/advance_requests_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
V1 Admin Advance Requests Stats
"""

from ....internals.get_resources import GetResources


class AdvanceRequestsStats(GetResources):
"""Class for Advance Requests Stats APIs."""

ADVANCE_REQUESTS_STATS = '/advance_requests_stats'

def __init__(self, version, role):
super().__init__(version, role, AdvanceRequestsStats.ADVANCE_REQUESTS_STATS)
14 changes: 14 additions & 0 deletions fyle/platform/apis/v1/admin/expense_comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
V1 Admin Expense Comments
"""

from ....internals.post_resources import PostResources


class ExpenseComments(PostResources):
"""Class for Expense Comments APIs."""

EXPENSE_COMMENT = '/expense_comments'

def __init__(self, version, role):
super().__init__(version, role, ExpenseComments.EXPENSE_COMMENT)
14 changes: 14 additions & 0 deletions fyle/platform/apis/v1/admin/expense_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
V1 Admin Expense Stats
"""

from ....internals.get_resources import GetResources


class ExpenseStats(GetResources):
"""Class for Expense Stats APIs."""

EXPENSE_STATS = '/expense_stats'

def __init__(self, version, role):
super().__init__(version, role, ExpenseStats.EXPENSE_STATS)
4 changes: 3 additions & 1 deletion fyle/platform/apis/v1/admin/expenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

from ....internals.list_resources import ListResources
from ....internals.post_resources import PostResources
from ....internals.delete_resources import DeleteResources
from ....internals.get_resources import GetResources


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

EXPENSES = '/expenses'
Expand Down
30 changes: 30 additions & 0 deletions fyle/platform/apis/v1/admin/policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
V1 Admin Policy
"""

from typing import Dict

from ....internals.api_base import ApiBase


class Policy:
"""Class for Policy APIs."""

TEST_POLICY = '/policy_test'

def __init__(self, version, role):
self.version = version
self.role = role

def test(self, payload) -> Dict:
"""
Test's Policy against an expense
:param payload: Expense Object
:return: Policy Test Object
"""
api = ApiBase(self.version, self.role)

return api.make_post_request(
api_url=Policy.TEST_POLICY,
payload=payload
)
14 changes: 14 additions & 0 deletions fyle/platform/apis/v1/admin/report_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
V1 Admin Report Stats
"""

from ....internals.get_resources import GetResources


class ReportStats(GetResources):
"""Class for Report Stats APIs."""

REPORT_STATS = '/report_stats'

def __init__(self, version, role):
super().__init__(version, role, ReportStats.REPORT_STATS)
14 changes: 14 additions & 0 deletions fyle/platform/apis/v1/admin/trip_requests_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
V1 Admin Trip Requests Stats
"""

from ....internals.get_resources import GetResources


class TripRequestsStats(GetResources):
"""Class for Trip Requests Stats APIs."""

TRIP_REQUESTS_STATS = '/trip_requests_stats'

def __init__(self, version, role):
super().__init__(version, role, TripRequestsStats.TRIP_REQUESTS_STATS)
6 changes: 3 additions & 3 deletions fyle/platform/apis/v1/fyler/expense_comments.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
V1 Admin Expense Comments
V1 Fyler Expense Comments
"""

from ....internals.list_resources import ListResources
from ....internals.post_resources import PostResources


class ExpenseComments(ListResources):
class ExpenseComments(PostResources):
"""Class for Expense Comments APIs."""

EXPENSE_COMMENT = '/expense_comments'
Expand Down
2 changes: 1 addition & 1 deletion fyle/platform/internals/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def make_post_request(self, api_url, payload):
A response from the request (dict).
"""

api_headers = {'Authorization': 'Bearer {0}'.format(config.get('AUTH', 'ACCESS_TOKEN'))}
api_headers = {'Authorization': 'Bearer {0}'.format(config.get('AUTH', 'ACCESS_TOKEN')), 'Content-Type': 'application/json'}

response = self.post_request(
url=self._format_api_url(api_url),
Expand Down
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='0.1.2-beta',
version='0.1.3-beta',
author='Siva Narayanan',
author_email='[email protected]',
description='Python SDK for accessing Fyle Platform APIs',
Expand Down

0 comments on commit 4e869ea

Please sign in to comment.