Last active
January 20, 2022 07:06
-
-
Save fnicollier/57f5a1ce3a6dbd8e386dce3fadfd53ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// A DSL response. | |
/// </summary> | |
public sealed class ConnectorResponse | |
{ | |
/// <summary> | |
/// Creates a new empty DSL Connector Response. | |
/// </summary> | |
public ConnectorResponse(string errorMessage, string status) | |
{ | |
ErrorMessage = errorMessage; | |
Status = status; | |
} | |
/// <summary> | |
/// Creates a DSL Connector Response from a RestResponse. | |
/// </summary> | |
/// <param name="response"></param> | |
public ConnectorResponse(IRestResponse response) | |
{ | |
IsSuccessful = response.IsSuccessful; | |
ErrorMessage = response.ErrorMessage; | |
StatusCode = (int) response.StatusCode; | |
Status = response.StatusCode.ToString(); | |
Content = string.IsNullOrWhiteSpace(response.Content) ? null : JToken.Parse(response.Content); | |
} | |
/// <summary> | |
/// Construct response from a string. | |
/// </summary> | |
/// <param name="content">The string content of the response.</param> | |
public ConnectorResponse(string content) | |
{ | |
Content = JToken.Parse(content); | |
IsSuccessful = true; | |
} | |
public bool IsSuccessful { get; set; } | |
public string? ErrorMessage { get; set; } | |
public string? Status { get; set; } | |
public int StatusCode { get; set; } | |
public JToken? Content { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment