summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Clients/Pastebin/PasteInfo.cs
blob: 7f40e7132d89a671239fb2d3ea4d8f6a9f337393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Diagnostics.CodeAnalysis;

namespace StardewModdingAPI.Web.Framework.Clients.Pastebin
{
    /// <summary>The response for a get-paste request.</summary>
    internal class PasteInfo
    {
        /*********
        ** Accessors
        *********/
        /// <summary>Whether the log was successfully fetched.</summary>
        [MemberNotNullWhen(true, nameof(PasteInfo.Content))]
        [MemberNotNullWhen(false, nameof(PasteInfo.Error))]
        public bool Success => this.Error == null || this.Content != null;

        /// <summary>The fetched paste content (if <see cref="Success"/> is <c>true</c>).</summary>
        public string? Content { get; internal set; }

        /// <summary>The error message (if <see cref="Success"/> is <c>false</c>).</summary>
        public string? Error { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="content">The fetched paste content.</param>
        /// <param name="error">The error message, if it failed.</param>
        public PasteInfo(string? content, string? error)
        {
            this.Content = content;
            this.Error = error;
        }
    }
}