{#
    This is a custom template derived from:
    https://github.com/openapi-generators/openapi-python-client/blob/v0.22.0/openapi_python_client/templates/property_templates/datetime_property.py.jinja
#}
{% macro construct_function(property, source) %}
isoparse({{ source }})
{% endmacro %}

{% from "property_templates/property_macros.py.jinja" import construct_template %}

{% macro construct(property, source) %}
{{ construct_template(construct_function, property, source) }}
{% endmacro %}

{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, str){% endmacro %}

{% macro transform(property, source, destination, declare_type=True) %}
{% set transformed = source + ".isoformat()" %}
{# CHANGE START (1) - make all the fields treated as non-required #}
{# {% if property.required %}
{{ destination }} = {{ transformed }}
{%- else %} #}
{% if declare_type %}
{% set type_annotation = property.get_type_string(json=True) %}
{{ destination }}: {{ type_annotation }} = UNSET
{% else %}
{{ destination }} = UNSET
{% endif %}
if not isinstance({{ source }}, Unset):
    {{ destination }} = {{ transformed }}
{# {%- endif %} #}
{# CHANGE END (1) #}
{% endmacro %}

{% macro transform_multipart(property, source, destination) %}
{% set transformed = source + ".isoformat().encode()" %}
{# CHANGE START (2) - make all the fields treated as non-required #}
{# {% if property.required %}
{{ destination }} = {{ transformed }}
{%- else %} #}
{% set type_annotation = property.get_type_string(json=True) | replace("str", "bytes") %}
{{ destination }}: {{ type_annotation }} = UNSET
if not isinstance({{ source }}, Unset):
    {{ destination }} = {{ transformed }}
{# {%- endif %} #}
{# CHANGE END (2) #}
{% endmacro %}
