Skip to content

Commit

Permalink
Fixing dependent fields get function (#80)
Browse files Browse the repository at this point in the history
* Fixing dependent fields get function

* Adding param types

* Adding separate resource for Dependent Field Values

* Renaming class

* Fixing messaging

* Fixing names

* Changing file name
  • Loading branch information
Shwetabhk authored Oct 16, 2023
1 parent 9ec804f commit 2ab88bf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
2 changes: 2 additions & 0 deletions fyle/platform/apis/v1beta/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .settlements import Settlements
from .projects import Projects
from .expense_fields import ExpenseFields
from .dependent_expense_field_values import DependentExpenseFieldValues
from .advance_requests import AdvanceRequests
from .files import Files
from .accounting_exports import AccountingExports
Expand All @@ -25,6 +26,7 @@
employees = Employees(version, role)
projects = Projects(version, role)
expense_fields = ExpenseFields(version, role)
dependent_expense_field_values = DependentExpenseFieldValues(version, role)
expenses = Expenses(version, role)
tax_groups = TaxGroups(version, role)
reimbursements = Reimbursements(version, role)
Expand Down
33 changes: 33 additions & 0 deletions fyle/platform/apis/v1beta/admin/dependent_expense_field_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
V1 Beta Admin Expense Fields
"""
from typing import Iterable
from ....internals.list_all_resources import ListAllResources
from ....internals.list_resources import ListResources
from ....internals.post_resources import PostResources
from ....internals.get_resources import GetResources
from .... import exceptions


class DependentExpenseFieldValues(ListResources, ListAllResources, PostResources, GetResources):
"""Class for Dependent Expense Field Values APIs."""

DEPENDENT_FIELD_VALUES = '/dependent_expense_field_values'
BULK_CREATE_DEPENDENT_EXPENSE_FIELDS_VALUES = '/dependent_expense_field_values/bulk'

def __init__(self, version, role):
super().__init__(version, role, DependentExpenseFieldValues.DEPENDENT_FIELD_VALUES)

def list_all(self, query_params=None) -> Iterable:
query_params = {} if query_params is None else query_params
if 'expense_field_id' not in query_params:
raise exceptions.WrongParamsError('expense_field_id is a mandatory query param.')
if 'parent_expense_field_id' not in query_params:
raise exceptions.WrongParamsError('parent_expense_field_id is a mandatory query param.')
return super().list_all(query_params)

def bulk_post_dependent_expense_field_values(self, payload):
return self.api.make_post_request(
api_url=DependentExpenseFieldValues.BULK_CREATE_DEPENDENT_EXPENSE_FIELDS_VALUES,
payload=payload
)
14 changes: 0 additions & 14 deletions fyle/platform/apis/v1beta/admin/expense_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ class ExpenseFields(ListResources, ListAllResources, PostResources, GetResources
"""Class for Expense Fields APIs."""

EXPENSE_FIELDS = '/expense_fields'
DEPENDENT_EXPENSE_FIELDS_VALUES = '/dependent_expense_field_values'
BULK_CREATE_DEPENDENT_EXPENSE_FIELDS_VALUES = '/dependent_expense_field_values/bulk'

def __init__(self, version, role):
super().__init__(version, role, ExpenseFields.EXPENSE_FIELDS)


def get_dependent_expense_field_values(self):
return self.api.make_get_request(
api_url=ExpenseFields.DEPENDENT_EXPENSE_FIELDS_VALUES
)

def bulk_post_dependent_expense_field_values(self, payload):
return self.api.make_post_request(
api_url=ExpenseFields.BULK_CREATE_DEPENDENT_EXPENSE_FIELDS_VALUES,
payload=payload
)
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.33.1',
version='v0.34.0',
author='Siva Narayanan',
author_email='[email protected]',
description='Python SDK for accessing Fyle Platform APIs',
Expand Down

0 comments on commit 2ab88bf

Please sign in to comment.