internal static WorkingHoursSummaryCurrentDayApiModel DeserializeWorkingHoursSummaryCurrentDayApiModel(JsonElement element)
        {
            Optional <int> totalWorkedHours   = default;
            Optional <int> totalWorkedMinutes = default;
            Optional <IReadOnlyList <WorkingHoursApiModel> > workingHoursEntries = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("totalWorkedHours"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalWorkedHours = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("totalWorkedMinutes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalWorkedMinutes = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("workingHoursEntries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <WorkingHoursApiModel> array = new List <WorkingHoursApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(WorkingHoursApiModel.DeserializeWorkingHoursApiModel(item));
                    }
                    workingHoursEntries = array;
                    continue;
                }
            }
            return(new WorkingHoursSummaryCurrentDayApiModel(Optional.ToNullable(totalWorkedHours), Optional.ToNullable(totalWorkedMinutes), Optional.ToList(workingHoursEntries)));
        }
        internal static ApiListResultWorkingHoursApiModel DeserializeApiListResultWorkingHoursApiModel(JsonElement element)
        {
            Optional <long> count = default;
            Optional <IReadOnlyList <WorkingHoursApiModel> > data = default;
            Optional <long> totalCount = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    count = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("data"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <WorkingHoursApiModel> array = new List <WorkingHoursApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(WorkingHoursApiModel.DeserializeWorkingHoursApiModel(item));
                    }
                    data = array;
                    continue;
                }
                if (property.NameEquals("totalCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalCount = property.Value.GetInt64();
                    continue;
                }
            }
            return(new ApiListResultWorkingHoursApiModel(Optional.ToNullable(count), Optional.ToList(data), Optional.ToNullable(totalCount)));
        }
Exemplo n.º 3
0
        internal static ApiResultWorkingHoursApiModel DeserializeApiResultWorkingHoursApiModel(JsonElement element)
        {
            Optional <WorkingHoursApiModel> data = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("data"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    data = WorkingHoursApiModel.DeserializeWorkingHoursApiModel(property.Value);
                    continue;
                }
            }
            return(new ApiResultWorkingHoursApiModel(data.Value));
        }
        internal static ApiListResultWorkingHoursApiModel DeserializeApiListResultWorkingHoursApiModel(XElement element)
        {
            long?count      = default;
            long?totalCount = default;
            IReadOnlyList <WorkingHoursApiModel> data = default;

            if (element.Element("count") is XElement countElement)
            {
                count = (long?)countElement;
            }
            if (element.Element("totalCount") is XElement totalCountElement)
            {
                totalCount = (long?)totalCountElement;
            }
            var array = new List <WorkingHoursApiModel>();

            foreach (var e in element.Elements("WorkingHoursApiModel"))
            {
                array.Add(WorkingHoursApiModel.DeserializeWorkingHoursApiModel(e));
            }
            data = array;
            return(new ApiListResultWorkingHoursApiModel(count, data, totalCount));
        }
        internal static WorkHoursSummaryDayOverviewApiModel DeserializeWorkHoursSummaryDayOverviewApiModel(XElement element)
        {
            string         employeeName   = default;
            DateTimeOffset?firstStartTime = default;
            bool?          firstStartTimeIsPreviousThanRequestedDate = default;
            DateTimeOffset?lastEndTime = default;
            bool?          lastEndTimeIsLaterThanRequestedDate = default;
            DateTimeOffset?requestedDate            = default;
            int?           stopsNumber              = default;
            double?        totalWorkedTimeInMinutes = default;
            int?           unclosedEntries          = default;
            string         userEmail     = default;
            long?          userId        = default;
            double?        workedHours   = default;
            double?        workedMinutes = default;
            IReadOnlyList <WorkingHoursApiModel> entries = default;

            if (element.Element("employeeName") is XElement employeeNameElement)
            {
                employeeName = (string)employeeNameElement;
            }
            if (element.Element("firstStartTime") is XElement firstStartTimeElement)
            {
                firstStartTime = firstStartTimeElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("firstStartTimeIsPreviousThanRequestedDate") is XElement firstStartTimeIsPreviousThanRequestedDateElement)
            {
                firstStartTimeIsPreviousThanRequestedDate = (bool?)firstStartTimeIsPreviousThanRequestedDateElement;
            }
            if (element.Element("lastEndTime") is XElement lastEndTimeElement)
            {
                lastEndTime = lastEndTimeElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("lastEndTimeIsLaterThanRequestedDate") is XElement lastEndTimeIsLaterThanRequestedDateElement)
            {
                lastEndTimeIsLaterThanRequestedDate = (bool?)lastEndTimeIsLaterThanRequestedDateElement;
            }
            if (element.Element("requestedDate") is XElement requestedDateElement)
            {
                requestedDate = requestedDateElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("stopsNumber") is XElement stopsNumberElement)
            {
                stopsNumber = (int?)stopsNumberElement;
            }
            if (element.Element("totalWorkedTimeInMinutes") is XElement totalWorkedTimeInMinutesElement)
            {
                totalWorkedTimeInMinutes = (double?)totalWorkedTimeInMinutesElement;
            }
            if (element.Element("unclosedEntries") is XElement unclosedEntriesElement)
            {
                unclosedEntries = (int?)unclosedEntriesElement;
            }
            if (element.Element("userEmail") is XElement userEmailElement)
            {
                userEmail = (string)userEmailElement;
            }
            if (element.Element("userId") is XElement userIdElement)
            {
                userId = (long?)userIdElement;
            }
            if (element.Element("workedHours") is XElement workedHoursElement)
            {
                workedHours = (double?)workedHoursElement;
            }
            if (element.Element("workedMinutes") is XElement workedMinutesElement)
            {
                workedMinutes = (double?)workedMinutesElement;
            }
            var array = new List <WorkingHoursApiModel>();

            foreach (var e in element.Elements("WorkingHoursApiModel"))
            {
                array.Add(WorkingHoursApiModel.DeserializeWorkingHoursApiModel(e));
            }
            entries = array;
            return(new WorkHoursSummaryDayOverviewApiModel(employeeName, entries, firstStartTime, firstStartTimeIsPreviousThanRequestedDate, lastEndTime, lastEndTimeIsLaterThanRequestedDate, requestedDate, stopsNumber, totalWorkedTimeInMinutes, unclosedEntries, userEmail, userId, workedHours, workedMinutes));
        }
        internal static WorkHoursSummaryDayOverviewApiModel DeserializeWorkHoursSummaryDayOverviewApiModel(JsonElement element)
        {
            Optional <string> employeeName = default;
            Optional <IReadOnlyList <WorkingHoursApiModel> > entries = default;
            Optional <DateTimeOffset> firstStartTime = default;
            Optional <bool>           firstStartTimeIsPreviousThanRequestedDate = default;
            Optional <DateTimeOffset> lastEndTime = default;
            Optional <bool>           lastEndTimeIsLaterThanRequestedDate = default;
            Optional <DateTimeOffset> requestedDate            = default;
            Optional <int>            stopsNumber              = default;
            Optional <double>         totalWorkedTimeInMinutes = default;
            Optional <int>            unclosedEntries          = default;
            Optional <string>         userEmail     = default;
            Optional <long>           userId        = default;
            Optional <double>         workedHours   = default;
            Optional <double>         workedMinutes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("employeeName"))
                {
                    employeeName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("entries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <WorkingHoursApiModel> array = new List <WorkingHoursApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(WorkingHoursApiModel.DeserializeWorkingHoursApiModel(item));
                    }
                    entries = array;
                    continue;
                }
                if (property.NameEquals("firstStartTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    firstStartTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("firstStartTimeIsPreviousThanRequestedDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    firstStartTimeIsPreviousThanRequestedDate = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("lastEndTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lastEndTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("lastEndTimeIsLaterThanRequestedDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lastEndTimeIsLaterThanRequestedDate = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("requestedDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    requestedDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("stopsNumber"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    stopsNumber = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("totalWorkedTimeInMinutes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalWorkedTimeInMinutes = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("unclosedEntries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    unclosedEntries = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("userEmail"))
                {
                    userEmail = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("userId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    userId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("workedHours"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    workedHours = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("workedMinutes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    workedMinutes = property.Value.GetDouble();
                    continue;
                }
            }
            return(new WorkHoursSummaryDayOverviewApiModel(employeeName.Value, Optional.ToList(entries), Optional.ToNullable(firstStartTime), Optional.ToNullable(firstStartTimeIsPreviousThanRequestedDate), Optional.ToNullable(lastEndTime), Optional.ToNullable(lastEndTimeIsLaterThanRequestedDate), Optional.ToNullable(requestedDate), Optional.ToNullable(stopsNumber), Optional.ToNullable(totalWorkedTimeInMinutes), Optional.ToNullable(unclosedEntries), userEmail.Value, Optional.ToNullable(userId), Optional.ToNullable(workedHours), Optional.ToNullable(workedMinutes)));
        }