Skip to content

Commit

Permalink
Add support for new Curator object
Browse files Browse the repository at this point in the history
  • Loading branch information
ErisApps committed Jan 26, 2022
1 parent dbd60ae commit 036536c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
3 changes: 0 additions & 3 deletions BeatSaverSharp/BeatSaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,6 @@ private bool GetOrAddBeatmapToCache(Beatmap beatmap, out Beatmap cachedAndOrBeat
if (beatmap.Automapper != cachedBeatmap.Automapper)
cachedBeatmap.Automapper = beatmap.Automapper;

if (beatmap.Curator != cachedBeatmap.Curator)
cachedBeatmap.Curator = beatmap.Curator;

if (beatmap.Description != cachedBeatmap.Description)
cachedBeatmap.Description = beatmap.Description;

Expand Down
2 changes: 1 addition & 1 deletion BeatSaverSharp/Models/Beatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class Beatmap : BeatSaverObject, IEquatable<Beatmap>
/// The person who curated this map.
/// </summary>
[JsonProperty("curator")]
public string? Curator { get; internal set; }
public Curator? Curator { get; internal set; }

private BeatmapVersion? _latestVersion;

Expand Down
42 changes: 42 additions & 0 deletions BeatSaverSharp/Models/Curator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using Newtonsoft.Json;

namespace BeatSaverSharp.Models
{
public class Curator : IEquatable<Curator>
{
/// <summary>
/// Id of the curator.
/// </summary>
[JsonProperty("id")]
public int Id { get; internal set; }

/// <summary>
/// Name of the curator.
/// </summary>
[JsonProperty("name")]
public string Name { get; internal set; } = null!;

/// <summary>
/// Link of the avatar of the curator.
/// </summary>
[JsonProperty("avatar")]
public string Avatar { get; internal set; } = null!;

/// <summary>
/// User account type of the curator.
/// </summary>
[JsonProperty("type")]
public string Type { get; internal set; } = null!;

internal Curator() { }

// Equality Methods

public bool Equals(Curator? other) => Id == other?.Id;
public override int GetHashCode() => Id.GetHashCode();
public override bool Equals(object? obj) => Equals(obj as Curator);
public static bool operator ==(Curator left, Curator right) => Equals(left, right);
public static bool operator !=(Curator left, Curator right) => !Equals(left, right);
}
}

0 comments on commit 036536c

Please sign in to comment.