Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/dotnet/Timr.Api/Client/ClientUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public static bool TryDeserialize<T>(ref Utf8JsonReader reader, JsonSerializerOp
return boolean
? "true"
: "false";
if (obj is AttachmentsSortColumn attachmentsSortColumn)
return AttachmentsSortColumnValueConverter.ToJsonValue(attachmentsSortColumn);
if (obj is BreakTimeType breakTimeType)
return BreakTimeTypeValueConverter.ToJsonValue(breakTimeType);
if (obj is BudgetPlanningType budgetPlanningType)
Expand Down
12 changes: 12 additions & 0 deletions sdk/dotnet/Timr.Api/Client/HostConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ internal HostConfiguration(IServiceCollection services)
jsonOptions.Converters.Add(new DateOnlyJsonConverter());
jsonOptions.Converters.Add(new DateOnlyNullableJsonConverter());
jsonOptions.Converters.Add(new AccountsJsonConverter());
jsonOptions.Converters.Add(new AttachmentJsonConverter());
jsonOptions.Converters.Add(new AttachmentDownloadJsonConverter());
jsonOptions.Converters.Add(new AttachmentMetadataJsonConverter());
jsonOptions.Converters.Add(new AttachmentUploadJsonConverter());
jsonOptions.Converters.Add(new AttachmentUploadResponseJsonConverter());
jsonOptions.Converters.Add(new AttachmentsPageJsonConverter());
jsonOptions.Converters.Add(new AttachmentsSortColumnJsonConverter());
jsonOptions.Converters.Add(new AttachmentsSortColumnNullableJsonConverter());
jsonOptions.Converters.Add(new BreakTimeJsonConverter());
jsonOptions.Converters.Add(new BreakTimeAutomaticJsonConverter());
jsonOptions.Converters.Add(new BreakTimeBaseJsonConverter());
Expand Down Expand Up @@ -222,7 +230,9 @@ internal HostConfiguration(IServiceCollection services)
_services.AddSingleton<DriveLogCategoryApiEvents>();
_services.AddSingleton<HolidayCalendarApiEvents>();
_services.AddSingleton<ProjectTimeApiEvents>();
_services.AddSingleton<ProjectTimeAttachmentApiEvents>();
_services.AddSingleton<TaskApiEvents>();
_services.AddSingleton<TaskAttachmentApiEvents>();
_services.AddSingleton<TaskToLeaderAssignmentApiEvents>();
_services.AddSingleton<TaskToTeamAssignmentApiEvents>();
_services.AddSingleton<TaskToUserAssignmentApiEvents>();
Expand Down Expand Up @@ -282,7 +292,9 @@ internal void Register()
builders.Add(_services.AddHttpClient<IDriveLogCategoryApi, DriveLogCategoryApi>("Timr.Api.Endpoints.IDriveLogCategoryApi", configureClient));
builders.Add(_services.AddHttpClient<IHolidayCalendarApi, HolidayCalendarApi>("Timr.Api.Endpoints.IHolidayCalendarApi", configureClient));
builders.Add(_services.AddHttpClient<IProjectTimeApi, ProjectTimeApi>("Timr.Api.Endpoints.IProjectTimeApi", configureClient));
builders.Add(_services.AddHttpClient<IProjectTimeAttachmentApi, ProjectTimeAttachmentApi>("Timr.Api.Endpoints.IProjectTimeAttachmentApi", configureClient));
builders.Add(_services.AddHttpClient<ITaskApi, TaskApi>("Timr.Api.Endpoints.ITaskApi", configureClient));
builders.Add(_services.AddHttpClient<ITaskAttachmentApi, TaskAttachmentApi>("Timr.Api.Endpoints.ITaskAttachmentApi", configureClient));
builders.Add(_services.AddHttpClient<ITaskToLeaderAssignmentApi, TaskToLeaderAssignmentApi>("Timr.Api.Endpoints.ITaskToLeaderAssignmentApi", configureClient));
builders.Add(_services.AddHttpClient<ITaskToTeamAssignmentApi, TaskToTeamAssignmentApi>("Timr.Api.Endpoints.ITaskToTeamAssignmentApi", configureClient));
builders.Add(_services.AddHttpClient<ITaskToUserAssignmentApi, TaskToUserAssignmentApi>("Timr.Api.Endpoints.ITaskToUserAssignmentApi", configureClient));
Expand Down
2,003 changes: 2,003 additions & 0 deletions sdk/dotnet/Timr.Api/Endpoints/ProjectTimeAttachmentApi.cs

Large diffs are not rendered by default.

1,947 changes: 1,947 additions & 0 deletions sdk/dotnet/Timr.Api/Endpoints/TaskAttachmentApi.cs

Large diffs are not rendered by default.

268 changes: 268 additions & 0 deletions sdk/dotnet/Timr.Api/Model/Attachment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
// <auto-generated>
/*
* timr API
*
* REST API for the timr time tracking service. It exposes the recordings a user makes (working times, project times, drive logs) together with the master data they refer to (users, teams, tasks, cars, working time types, work schedule models, holiday calendars).
*
* Contact: info@timr.com
* Generated by: https://github.com/openapitools/openapi-generator.git
*/

#nullable enable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using Timr.Api.Client;

namespace Timr.Api.Model
{
/// <summary>
/// A file attached to an entity, such as a Task or a Project Time. Only attachments whose upload has completed are returned.
/// </summary>
public partial class Attachment : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="Attachment" /> class.
/// </summary>
/// <param name="id">Unique identifier. Treat it as an opaque string.</param>
/// <param name="metadata">metadata</param>
/// <param name="uploadedAt">When the upload of the file completed. RFC 3339 date-time (ISO-8601) </param>
/// <param name="download">Temporary URL to download the file, or null if the file cannot be downloaded. Clients have to handle null, as future versions may also return attachments whose upload has not completed yet. </param>
/// <param name="uploadedBy">The User who uploaded the file, or null if that User no longer exists.</param>
[JsonConstructor]
public Attachment(Guid id, AttachmentMetadata metadata, DateTimeOffset uploadedAt, AttachmentDownload? download = default, UserPartial? uploadedBy = default)
{
Id = id;
Metadata = metadata;
UploadedAt = uploadedAt;
Download = download;
UploadedBy = uploadedBy;
OnCreated();
}

partial void OnCreated();

/// <summary>
/// Unique identifier. Treat it as an opaque string.
/// </summary>
/// <value>Unique identifier. Treat it as an opaque string.</value>
/* <example>01972ff0-14a2-7814-926c-11d07a1dc20b</example> */
[JsonPropertyName("id")]
public Guid Id { get; set; }

/// <summary>
/// Gets or Sets Metadata
/// </summary>
[JsonPropertyName("metadata")]
public AttachmentMetadata Metadata { get; set; }

/// <summary>
/// When the upload of the file completed. RFC 3339 date-time (ISO-8601)
/// </summary>
/// <value>When the upload of the file completed. RFC 3339 date-time (ISO-8601) </value>
/* <example>2021-07-16T08:20Z</example> */
[JsonPropertyName("uploaded_at")]
public DateTimeOffset UploadedAt { get; set; }

/// <summary>
/// Temporary URL to download the file, or null if the file cannot be downloaded. Clients have to handle null, as future versions may also return attachments whose upload has not completed yet.
/// </summary>
/// <value>Temporary URL to download the file, or null if the file cannot be downloaded. Clients have to handle null, as future versions may also return attachments whose upload has not completed yet. </value>
[JsonPropertyName("download")]
public AttachmentDownload? Download { get; set; }

/// <summary>
/// The User who uploaded the file, or null if that User no longer exists.
/// </summary>
/// <value>The User who uploaded the file, or null if that User no longer exists.</value>
[JsonPropertyName("uploaded_by")]
public UserPartial? UploadedBy { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class Attachment {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Metadata: ").Append(Metadata).Append("\n");
sb.Append(" UploadedAt: ").Append(UploadedAt).Append("\n");
sb.Append(" Download: ").Append(Download).Append("\n");
sb.Append(" UploadedBy: ").Append(UploadedBy).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}

/// <summary>
/// A Json converter for type <see cref="Attachment" />
/// </summary>
public partial class AttachmentJsonConverter : JsonConverter<Attachment>
{
partial void OnCreated();

/// <summary>
/// Initializes a new instance of the <see cref="AttachmentJsonConverter" /> class.
/// </summary>
public AttachmentJsonConverter()
{
OnCreated();
}

/// <summary>
/// The format to use to serialize UploadedAt
/// </summary>
public string UploadedAtFormat { get; private set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK";

/// <summary>
/// Deserializes json to <see cref="Attachment" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public override Attachment Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
{
int currentDepth = utf8JsonReader.CurrentDepth;

if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();

JsonTokenType startingTokenType = utf8JsonReader.TokenType;

Option<Guid?> id = default;
Option<AttachmentMetadata?> metadata = default;
Option<DateTimeOffset?> uploadedAt = default;
Option<AttachmentDownload?> download = default;
Option<UserPartial?> uploadedBy = default;

while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;

if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;

if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string? localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();

switch (localVarJsonPropertyName)
{
case "id":
id = new Option<Guid?>(utf8JsonReader.TokenType == JsonTokenType.Null ? (Guid?)null : utf8JsonReader.GetGuid());
break;
case "metadata":
metadata = new Option<AttachmentMetadata?>(JsonSerializer.Deserialize<AttachmentMetadata>(ref utf8JsonReader, jsonSerializerOptions)!);
break;
case "uploaded_at":
uploadedAt = new Option<DateTimeOffset?>(JsonSerializer.Deserialize<DateTimeOffset>(ref utf8JsonReader, jsonSerializerOptions));
break;
case "download":
download = new Option<AttachmentDownload?>(JsonSerializer.Deserialize<AttachmentDownload>(ref utf8JsonReader, jsonSerializerOptions));
break;
case "uploaded_by":
uploadedBy = new Option<UserPartial?>(JsonSerializer.Deserialize<UserPartial>(ref utf8JsonReader, jsonSerializerOptions));
break;
default:
break;
}
}
}

if (!id.IsSet)
throw new JsonException("Property is required for class Attachment: id.");

if (!metadata.IsSet)
throw new JsonException("Property is required for class Attachment: metadata.");

if (!uploadedAt.IsSet)
throw new JsonException("Property is required for class Attachment: uploaded_at.");

if (!download.IsSet)
throw new JsonException("Property is required for class Attachment: download.");

if (!uploadedBy.IsSet)
throw new JsonException("Property is required for class Attachment: uploaded_by.");

if (id.IsSet && id.Value == null)
throw new JsonException("Property is not nullable for class Attachment: id.");

if (metadata.IsSet && metadata.Value == null)
throw new JsonException("Property is not nullable for class Attachment: metadata.");

if (uploadedAt.IsSet && uploadedAt.Value == null)
throw new JsonException("Property is not nullable for class Attachment: uploaded_at.");

return new Attachment(id.Value!.Value!, metadata.Value!, uploadedAt.Value!.Value!, download.Value!, uploadedBy.Value!);
}

/// <summary>
/// Serializes a <see cref="Attachment" />
/// </summary>
/// <param name="writer"></param>
/// <param name="attachment"></param>
/// <param name="jsonSerializerOptions"></param>
public override void Write(Utf8JsonWriter writer, Attachment attachment, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();

WriteProperties(writer, attachment, jsonSerializerOptions);
writer.WriteEndObject();
}

/// <summary>
/// Serializes the properties of <see cref="Attachment" />
/// </summary>
/// <param name="writer"></param>
/// <param name="attachment"></param>
/// <param name="jsonSerializerOptions"></param>
public void WriteProperties(Utf8JsonWriter writer, Attachment attachment, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteString("id", attachment.Id);

writer.WritePropertyName("metadata");
JsonSerializer.Serialize(writer, attachment.Metadata, jsonSerializerOptions);
writer.WriteString("uploaded_at", attachment.UploadedAt.ToString(UploadedAtFormat));

if (attachment.Download != null)
{
writer.WritePropertyName("download");
JsonSerializer.Serialize(writer, attachment.Download, jsonSerializerOptions);
}
else
writer.WriteNull("download");
if (attachment.UploadedBy != null)
{
writer.WritePropertyName("uploaded_by");
JsonSerializer.Serialize(writer, attachment.UploadedBy, jsonSerializerOptions);
}
else
writer.WriteNull("uploaded_by");
}
}
}
Loading
Loading