merge-api / merge-sdk-python

The Python SDK for accessing various Merge Unified APIs
Other
0 stars 1 forks source link

Clarification on Expanded Attribute Behavior #17

Open helgi-empower opened 1 year ago

helgi-empower commented 1 year ago

Hi there,

I have a question regarding the example in your README where you demonstrate how to use the expand parameter. Specifically, I noticed that the employments attribute returns a list of ids when it is not expanded. However, when expanded, it returns an Employment object. Is this expected behavior? And if so, how do I access all of the employments for a given employee?

from MergePythonSDK.shared import Configuration, ApiClient
from MergePythonSDK.hris.api.employees_api import EmployeesApi

configuration = Configuration()
configuration.access_token = "YOUR_API_KEY_HERE"
configuration.api_key_prefix['tokenAuth'] = 'Bearer'
configuration.api_key['accountTokenAuth'] = 'YOUR_X_ACCOUNT_TOKEN_HERE'
with ApiClient(configuration) as api_client:
    hris_employees_api_instance = EmployeesApi(api_client)
    try:
        # Test expands
        _id = "YOUR_EMPLOYEE_ID_HERE"
        employee_expands = hris_employees_api_instance.employees_retrieve(
          _id, expand="employments"
        )
        assert employee_expands.employments.employee == employee_expands.id