diff --git a/fyle/platform/apis/v1/admin/__init__.py b/fyle/platform/apis/v1/admin/__init__.py index 6ed665f..0c7661d 100644 --- a/fyle/platform/apis/v1/admin/__init__.py +++ b/fyle/platform/apis/v1/admin/__init__.py @@ -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) \ No newline at end of file diff --git a/fyle/platform/apis/v1/admin/advance_requests_stats.py b/fyle/platform/apis/v1/admin/advance_requests_stats.py new file mode 100644 index 0000000..063e9c2 --- /dev/null +++ b/fyle/platform/apis/v1/admin/advance_requests_stats.py @@ -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) diff --git a/fyle/platform/apis/v1/admin/expense_comments.py b/fyle/platform/apis/v1/admin/expense_comments.py new file mode 100644 index 0000000..182ef88 --- /dev/null +++ b/fyle/platform/apis/v1/admin/expense_comments.py @@ -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) diff --git a/fyle/platform/apis/v1/admin/expense_stats.py b/fyle/platform/apis/v1/admin/expense_stats.py new file mode 100644 index 0000000..79b2b36 --- /dev/null +++ b/fyle/platform/apis/v1/admin/expense_stats.py @@ -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) diff --git a/fyle/platform/apis/v1/admin/expenses.py b/fyle/platform/apis/v1/admin/expenses.py index bfb31d8..43be540 100644 --- a/fyle/platform/apis/v1/admin/expenses.py +++ b/fyle/platform/apis/v1/admin/expenses.py @@ -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' diff --git a/fyle/platform/apis/v1/admin/policy.py b/fyle/platform/apis/v1/admin/policy.py new file mode 100644 index 0000000..9d1dc51 --- /dev/null +++ b/fyle/platform/apis/v1/admin/policy.py @@ -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 + ) diff --git a/fyle/platform/apis/v1/admin/report_stats.py b/fyle/platform/apis/v1/admin/report_stats.py new file mode 100644 index 0000000..148bba5 --- /dev/null +++ b/fyle/platform/apis/v1/admin/report_stats.py @@ -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) diff --git a/fyle/platform/apis/v1/admin/trip_requests_stats.py b/fyle/platform/apis/v1/admin/trip_requests_stats.py new file mode 100644 index 0000000..7fba330 --- /dev/null +++ b/fyle/platform/apis/v1/admin/trip_requests_stats.py @@ -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) diff --git a/fyle/platform/apis/v1/fyler/expense_comments.py b/fyle/platform/apis/v1/fyler/expense_comments.py index f25431e..968ce4b 100644 --- a/fyle/platform/apis/v1/fyler/expense_comments.py +++ b/fyle/platform/apis/v1/fyler/expense_comments.py @@ -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' diff --git a/fyle/platform/internals/api_base.py b/fyle/platform/internals/api_base.py index 3023dd1..7580448 100644 --- a/fyle/platform/internals/api_base.py +++ b/fyle/platform/internals/api_base.py @@ -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), diff --git a/setup.py b/setup.py index 0295a65..08a07bd 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='fyle', - version='0.1.2-beta', + version='0.1.3-beta', author='Siva Narayanan', author_email='siva@fyle.in', description='Python SDK for accessing Fyle Platform APIs',