Initial BinaryLane v2 API client

This commit is contained in:
2026-08-16 21:52:42 +10:00
commit fcd0d22b0d
91 changed files with 18691 additions and 0 deletions
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Net;
namespace BinaryLane.Api.V2.Errors;
/// <summary>Base exception for an unsuccessful BinaryLane API response.</summary>
public class BinaryLaneApiException : Exception
{
internal BinaryLaneApiException(
string message,
HttpStatusCode statusCode,
Uri requestUri,
BinaryLaneApiProblem? problem,
string? responseBody,
IReadOnlyDictionary<string, IReadOnlyList<string>> headers)
: base(message)
{
StatusCode = statusCode;
RequestUri = requestUri;
Problem = problem;
ResponseBody = responseBody;
Headers = headers;
}
/// <summary>HTTP status code returned by BinaryLane.</summary>
public HttpStatusCode StatusCode { get; }
/// <summary>The request URI which produced the response.</summary>
public Uri RequestUri { get; }
/// <summary>Structured problem details, when BinaryLane supplied them.</summary>
public BinaryLaneApiProblem? Problem { get; }
/// <summary>
/// Bounded raw response text for diagnostics. It omits request headers, but can contain
/// provider-supplied or user-provided data; avoid logging it indiscriminately.
/// </summary>
public string? ResponseBody { get; }
/// <summary>Response and content headers.</summary>
public IReadOnlyDictionary<string, IReadOnlyList<string>> Headers { get; }
}
@@ -0,0 +1,17 @@
namespace BinaryLane.Api.V2.Errors;
/// <summary>A structured problem response returned by BinaryLane.</summary>
public sealed class BinaryLaneApiProblem
{
/// <summary>Problem type URI, if supplied.</summary>
public string? Type { get; internal set; }
/// <summary>Short problem title, if supplied.</summary>
public string? Title { get; internal set; }
/// <summary>Human-readable problem detail, if supplied.</summary>
public string? Detail { get; internal set; }
/// <summary>Provider-supplied status code, if supplied.</summary>
public int? Status { get; internal set; }
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Net;
namespace BinaryLane.Api.V2.Errors;
/// <summary>Thrown when the current account is not authorized for an operation.</summary>
public sealed class BinaryLaneForbiddenException : BinaryLaneApiException
{
internal BinaryLaneForbiddenException(string message, Uri requestUri, BinaryLaneApiProblem? problem, string? responseBody, IReadOnlyDictionary<string, IReadOnlyList<string>> headers)
: base(message, HttpStatusCode.Forbidden, requestUri, problem, responseBody, headers)
{
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Net;
namespace BinaryLane.Api.V2.Errors;
/// <summary>Thrown when BinaryLane cannot find a requested resource.</summary>
public sealed class BinaryLaneNotFoundException : BinaryLaneApiException
{
internal BinaryLaneNotFoundException(string message, Uri requestUri, BinaryLaneApiProblem? problem, string? responseBody, IReadOnlyDictionary<string, IReadOnlyList<string>> headers)
: base(message, HttpStatusCode.NotFound, requestUri, problem, responseBody, headers)
{
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Net;
namespace BinaryLane.Api.V2.Errors;
/// <summary>Thrown when BinaryLane rejects credentials.</summary>
public sealed class BinaryLaneUnauthorizedException : BinaryLaneApiException
{
internal BinaryLaneUnauthorizedException(string message, Uri requestUri, BinaryLaneApiProblem? problem, string? responseBody, IReadOnlyDictionary<string, IReadOnlyList<string>> headers)
: base(message, HttpStatusCode.Unauthorized, requestUri, problem, responseBody, headers)
{
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Net;
namespace BinaryLane.Api.V2.Errors;
/// <summary>Thrown when BinaryLane rejects a malformed or invalid request.</summary>
public sealed class BinaryLaneValidationException : BinaryLaneApiException
{
internal BinaryLaneValidationException(string message, HttpStatusCode statusCode, Uri requestUri, BinaryLaneApiProblem? problem, string? responseBody, IReadOnlyDictionary<string, IReadOnlyList<string>> headers)
: base(message, statusCode, requestUri, problem, responseBody, headers)
{
}
}