# Code generated by Lark OpenAPI.

import lark_oapi as lark
from lark_oapi.api.corehr.v2 import *


def main():
    # 创建client
    client = lark.Client.builder() \
        .app_id(lark.APP_ID) \
        .app_secret(lark.APP_SECRET) \
        .log_level(lark.LogLevel.DEBUG) \
        .build()

    # 构造请求对象
    request: ListEmployeesInternationalAssignmentRequest = ListEmployeesInternationalAssignmentRequest.builder() \
        .user_id_type("open_id") \
        .department_id_type("open_department_id") \
        .page_size(200) \
        .page_token("123456") \
        .employment_ids([]) \
        .international_assignment_ids([]) \
        .effective_time("") \
        .expiration_time("") \
        .employment_status_list([]) \
        .work_location_id_list([]) \
        .department_id_list([]) \
        .direct_manager_id_list([]) \
        .dotted_line_manager_id_list([]) \
        .position_id_list([]) \
        .job_id_list([]) \
        .job_family_id_list([]) \
        .job_level_id_list([]) \
        .job_grade_id_list([]) \
        .working_hours_type_id_list([]) \
        .service_company_list([]) \
        .weekly_working_hours_v2(10) \
        .work_shift_list([]) \
        .compensation_type_list([]) \
        .international_assignment_expected_end_date("") \
        .international_assignment_status_list([]) \
        .international_assignment_type_list([]) \
        .work_calendar_id_list([]) \
        .build()

    # 发起请求
    response: ListEmployeesInternationalAssignmentResponse = client.corehr.v2.employees_international_assignment.list(
        request)

    # 处理失败返回
    if not response.success():
        lark.logger.error(
            f"client.corehr.v2.employees_international_assignment.list failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}")
        return

    # 处理业务结果
    lark.logger.info(lark.JSON.marshal(response.data, indent=4))


# 异步方式
async def amain():
    # 创建client
    client = lark.Client.builder() \
        .app_id(lark.APP_ID) \
        .app_secret(lark.APP_SECRET) \
        .log_level(lark.LogLevel.DEBUG) \
        .build()

    # 构造请求对象
    request: ListEmployeesInternationalAssignmentRequest = ListEmployeesInternationalAssignmentRequest.builder() \
        .user_id_type("open_id") \
        .department_id_type("open_department_id") \
        .page_size(200) \
        .page_token("123456") \
        .employment_ids([]) \
        .international_assignment_ids([]) \
        .effective_time("") \
        .expiration_time("") \
        .employment_status_list([]) \
        .work_location_id_list([]) \
        .department_id_list([]) \
        .direct_manager_id_list([]) \
        .dotted_line_manager_id_list([]) \
        .position_id_list([]) \
        .job_id_list([]) \
        .job_family_id_list([]) \
        .job_level_id_list([]) \
        .job_grade_id_list([]) \
        .working_hours_type_id_list([]) \
        .service_company_list([]) \
        .weekly_working_hours_v2(10) \
        .work_shift_list([]) \
        .compensation_type_list([]) \
        .international_assignment_expected_end_date("") \
        .international_assignment_status_list([]) \
        .international_assignment_type_list([]) \
        .work_calendar_id_list([]) \
        .build()

    # 发起请求
    response: ListEmployeesInternationalAssignmentResponse = await client.corehr.v2.employees_international_assignment.alist(
        request)

    # 处理失败返回
    if not response.success():
        lark.logger.error(
            f"client.corehr.v2.employees_international_assignment.alist failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}")
        return

    # 处理业务结果
    lark.logger.info(lark.JSON.marshal(response.data, indent=4))


if __name__ == "__main__":
    # asyncio.run(amain()) 异步方式
    main()
