Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Referencing Files Object in Item Class #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
45 changes: 45 additions & 0 deletions OnePassword.NET/Items/File.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using OnePassword.Common;

namespace OnePassword.Items;

/// <summary>Represents a file object.</summary>
public sealed class File : ITracked
{
/// <summary>The file section.</summary>
[JsonInclude]
[JsonPropertyName("section")]
public Section? Section { get; internal set; }

/// <summary>The file ID.</summary>
[JsonInclude]
[JsonPropertyName("id")]
public string Id { get; internal set; } = "";

/// <summary>The name of file.</summary>
[JsonInclude]
[JsonPropertyName("name")]
public string Name { get; internal set; } = "";

/// <summary>The file size.</summary>
[JsonInclude]
[JsonPropertyName("size")]
public int Size { get; internal set; }

/// <summary>The content path.</summary>
[JsonInclude]
[JsonPropertyName("content_path")]
public string ContentPath { get; internal set; } = "";

/// <inheritdoc />
public bool Changed => false;

/// <summary>Initializes a new instance of <see cref="File" />.</summary>
public File()
{
}

/// <inheritdoc />
void ITracked.AcceptChanges()
{
}
}
7 changes: 7 additions & 0 deletions OnePassword.NET/Items/ItemBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public string CategoryId
[JsonPropertyName("tags")]
public TrackedList<string> Tags { get; internal set; } = [];

/// <summary>
/// The files associated with the item.
/// </summary>
[JsonInclude]
[JsonPropertyName("files")]
public TrackedList<File> Files { get; internal set; } = [];

/// <summary>
/// Returns <see langword="true" /> when the title has changed, <see langword="false" /> otherwise.
/// </summary>
Expand Down