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

Improvements #18

Merged
merged 32 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e7602e7
Fix build of library.
gizdatullin Oct 31, 2024
d5b323a
As always
gizdatullin Oct 31, 2024
25bb91e
Fix some api
gizdatullin Nov 4, 2024
6606467
Some changes
gizdatullin Nov 4, 2024
31d7ab0
Compile all the stuff
gizdatullin Nov 4, 2024
fb699b0
Fix the shit
gizdatullin Nov 4, 2024
5820347
Fix
gizdatullin Nov 5, 2024
6710c47
fix one todo
gizdatullin Nov 5, 2024
ee47158
Fix one more todo
gizdatullin Nov 5, 2024
b2a2250
Fix one more todo
gizdatullin Nov 5, 2024
0b17000
Fix one more
gizdatullin Nov 5, 2024
b3db86c
No
gizdatullin Nov 5, 2024
7ba55ce
Final resolve
gizdatullin Nov 5, 2024
38b5117
Small
gizdatullin Nov 5, 2024
972e91d
Bump
gizdatullin Nov 5, 2024
ca72029
Merge branch 'main' into gizdatullin/great
gizdatullin Nov 5, 2024
6eda6f2
Fix master?
gizdatullin Nov 5, 2024
a9270ec
Remove remaining contracts
gizdatullin Nov 5, 2024
7d863d6
Fix build
gizdatullin Nov 5, 2024
c2cbf03
Return one test
gizdatullin Nov 5, 2024
282d2eb
Must fix
gizdatullin Nov 6, 2024
5119c9d
Fix
gizdatullin Nov 6, 2024
ed24576
Fixes
gizdatullin Nov 6, 2024
8279b1b
Fix 1
gizdatullin Nov 6, 2024
c581280
Rework collections
gizdatullin Nov 6, 2024
50307d7
Fix nullables
gizdatullin Nov 6, 2024
dae5f27
TryGet pattern
gizdatullin Nov 7, 2024
7d9d021
Return cache
gizdatullin Nov 7, 2024
b8c91cb
Fix one
gizdatullin Nov 7, 2024
58785cf
Make request collection nullable
gizdatullin Nov 7, 2024
1ed9b16
Added passing Yandex.Tracker options to tests via env variables
Markeli Nov 7, 2024
d1ab78d
Enabled tests
Markeli Nov 7, 2024
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
10 changes: 8 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
YandexTrackerOptions__OAuthToken: ${{ secrets.YANDEXTRACKER_OAUTHTOKEN }}
YandexTrackerOptions__Organization: ${{ secrets.YANDEXTRACKER_ORGANIZATION }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -22,9 +25,12 @@ jobs:

- name: Build
run: dotnet build ./Mindbox.YandexTracker.sln --configuration Release --no-restore


- name: Test
run: dotnet test --no-restore

- name: Pack
run: dotnet pack ./Mindbox.YandexTracker.sln -c Release -p:BuildNumber=${{ github.run_number }}

- name: Publish
run: dotnet nuget push **/*.nupkg -k ${{secrets.MINDBOX_NUGET_AUTH_TOKEN}} -s https://api.nuget.org/v3/index.json
run: dotnet nuget push **/*.nupkg -k ${{secrets.MINDBOX_NUGET_AUTH_TOKEN}} -s https://api.nuget.org/v3/index.json
6 changes: 6 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on: pull_request
jobs:
build:
runs-on: ubuntu-latest
env:
YandexTrackerOptions__OAuthToken: ${{ secrets.YANDEXTRACKER_OAUTHTOKEN }}
YandexTrackerOptions__Organization: ${{ secrets.YANDEXTRACKER_ORGANIZATION }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -26,3 +29,6 @@ jobs:

- name: Build
run: dotnet build ./Mindbox.YandexTracker.sln --configuration Release --no-restore

- name: Test
run: dotnet test --no-restore
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
<PropertyGroup>
<VersionMajor>2</VersionMajor>
<VersionMinor>1</VersionMinor>
<VersionMajor>3</VersionMajor>
<VersionMinor>0</VersionMinor>
<BuildNumber>$(BuildNumber)</BuildNumber>
<BuildNumber Condition="'$(BuildNumber)' == ''">0</BuildNumber>
<PackageVersion>$(VersionMajor).$(VersionMinor).$(BuildNumber)$(VersionTag)</PackageVersion>
Expand Down
9 changes: 9 additions & 0 deletions Mindbox.YandexTracker.Abstractions/Dtos/CheckListItemDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Mindbox.YandexTracker;

public sealed record CheckListItemDto
{
public required string Id { get; init; }
public string? Text { get; init; }
public bool Checked { get; init; }
public ChecklistItemType ChecklistItemType { get; set; }
}
62 changes: 62 additions & 0 deletions Mindbox.YandexTracker.Abstractions/Dtos/CustomFieldDtos.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Mindbox.YandexTracker;

public record CustomFieldsRequest
{
[JsonExtensionData]
[JsonInclude]
private Dictionary<string, JsonElement> Fields { get; init; } = [];

/// <remarks>
/// Необходимо передавать id кастомного поля, из-за того, что локальные поля очереди будут иметь префикс в своем
/// названии, которое будет совпадать с id
/// </remarks>
public bool TryGetCustomField<T>(string customFieldId, out T? value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(customFieldId);
return CustomFieldsHelper.TryGetCustomField(Fields, customFieldId, out value);
}

public T GetCustomField<T>(string customFieldId)
{
ArgumentException.ThrowIfNullOrWhiteSpace(customFieldId);
return CustomFieldsHelper.GetCustomField<T>(Fields, customFieldId);
}

/// <remarks>
/// Необходимо передавать id кастомного поля, из-за того, что локальные поля очереди будут иметь префикс в своем
/// названии, которое будет совпадать с id
/// </remarks>
public void SetCustomField<T>(string customFieldId, T value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(customFieldId);
CustomFieldsHelper.SetCustomField(Fields, customFieldId, value);
}
}

public record CustomFieldsResponse
{
[JsonExtensionData]
[JsonInclude]
private Dictionary<string, JsonElement> Fields { get; init; } = [];

/// <remarks>
/// Необходимо передавать id кастомного поля, из-за того, что локальные поля очереди будут иметь префикс в своем
/// названии, которое будет совпадать с id
/// </remarks>
public bool TryGetCustomField<T>(string customFieldId, out T? value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(customFieldId);
return CustomFieldsHelper.TryGetCustomField(Fields, customFieldId, out value);
}

public T GetCustomField<T>(string customFieldId)
{
ArgumentException.ThrowIfNullOrWhiteSpace(customFieldId);
return CustomFieldsHelper.GetCustomField<T>(Fields, customFieldId);
}
}
42 changes: 42 additions & 0 deletions Mindbox.YandexTracker.Abstractions/Dtos/CustomFieldsHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Text.Json;

namespace Mindbox.YandexTracker;

internal static class CustomFieldsHelper
{
public static bool TryGetCustomField<T>(
IDictionary<string, JsonElement> fields,
string customFieldId,
out T? customField)
{
ArgumentException.ThrowIfNullOrWhiteSpace(customFieldId);

customField = default;
if (fields.TryGetValue(customFieldId, out var value))
{
if (value.ValueKind is JsonValueKind.Null or JsonValueKind.Undefined)
return false;

customField = value.Deserialize<T>();
return true;
}

return false;
}

public static T GetCustomField<T>(IDictionary<string, JsonElement> fields, string customFieldId)
{
return TryGetCustomField<T>(fields, customFieldId, out var value)
? value!
: throw new KeyNotFoundException($"Key '{customFieldId}' not found in custom fields.");
}

public static void SetCustomField<T>(IDictionary<string, JsonElement> fields, string customFieldId, T value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(customFieldId);

fields[customFieldId] = JsonSerializer.SerializeToElement(value);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Mindbox.YandexTracker;

internal sealed record FieldInfo
public sealed record FieldInfo
{
public required string Id { get; init; }

Expand Down
12 changes: 12 additions & 0 deletions Mindbox.YandexTracker.Abstractions/Dtos/IssueTypeConfigDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;

namespace Mindbox.YandexTracker;

public sealed record IssueTypeConfigDto
{
public required FieldInfo IssueType { get; init; }

public required FieldInfo Workflow { get; init; }

public required IReadOnlyCollection<FieldInfo> Resolutions { get; init; } = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;

namespace Mindbox.YandexTracker;

public sealed record CreateCommentRequest
{
public required string Text { get; init; }

public IReadOnlyCollection<string>? AttachmentIds { get; init; }

public IReadOnlyCollection<string>? Summonees { get; init; }

public IReadOnlyCollection<string>? MaillistSummonees { get; init; }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Mindbox.YandexTracker;

internal sealed record CreateComponentRequest
public sealed record CreateComponentRequest
{
public required string Name { get; init; }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;

namespace Mindbox.YandexTracker;

public sealed record CreateIssueRequest : CustomFieldsRequest
Markeli marked this conversation as resolved.
Show resolved Hide resolved
{
public required string Summary { get; init; }

public required string Queue { get; init; }

public IReadOnlyCollection<string>? Followers { get; init; }

public string? Type { get; init; }

public string? Description { get; init; }

public string? Parent { get; init; }

public DateOnly? Start { get; init; }
public DateOnly? End { get; init; }
public DateOnly? DueDate { get; init; }

public string? Author { get; init; }

public string? QaEngineer { get; init; }

public IReadOnlyCollection<string>? Access { get; init; }

public int? PossibleSpam { get; init; }

public string? Unique { get; init; }

public IReadOnlyCollection<string>? AttachmentIds { get; init; }

public IReadOnlyCollection<string>? Sprint { get; init; }

public Priority? Priority { get; init; }

public string? Assignee { get; init; }

public IReadOnlyCollection<string>? Tags { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;

namespace Mindbox.YandexTracker;

public sealed record CreateProjectRequest
{
public required ProjectFieldsDto Fields { get; init; }
}

public sealed record ProjectFieldsDto
{
public required string Summary { get; init; }

public bool? TeamAccess { get; init; }

public string? Description { get; init; }

public string? Author { get; init; }
Markeli marked this conversation as resolved.
Show resolved Hide resolved

public string? Lead { get; init; }

public IReadOnlyCollection<string>? TeamUsers { get; init; }

public IReadOnlyCollection<string>? Clients { get; init; }

public IReadOnlyCollection<string>? Followers { get; init; }

public DateOnly? Start { get; init; }

public DateOnly? End { get; init; }

public IReadOnlyCollection<string>? Tags { get; init; }

public int? ParentEntity { get; init; }

public ProjectEntityStatus? EntityStatus { get; init; }
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System.Text.Json.Serialization;
namespace Mindbox.YandexTracker;

namespace Mindbox.YandexTracker;

internal sealed record CreateQueueLocalFieldRequest
public sealed record CreateQueueLocalFieldRequest
{
public required string Id { get; init; }

public required QueueLocalFieldName Name { get; init; }

[JsonPropertyName("category")]
public required string CategoryId { get; init; }
public required string Category { get; init; }

public QueueLocalFieldType Type { get; init; }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;

namespace Mindbox.YandexTracker;

public sealed record CreateQueueRequest
{
public required string Key { get; init; }

public required string Name { get; init; }

public required string Lead { get; init; }

public required string DefaultType { get; init; }

public Priority DefaultPriority { get; init; }

public IReadOnlyCollection<CreateIssueTypeConfigDto>? IssueTypesConfig { get; init; }
}

public sealed record CreateIssueTypeConfigDto
{
public required string IssueType { get; init; }

public required string Workflow { get; init; }

public IReadOnlyCollection<string>? Resolutions { get; init; }
}
Loading
Loading