Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 86 additions & 0 deletions src/libs/Writer/Generated/Writer.AutoSDKHttpResponse.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

#nullable enable

namespace Writer
{
/// <summary>
/// Represents a successful HTTP response with status code and headers.
/// </summary>
public partial class AutoSDKHttpResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers)
{
StatusCode = statusCode;
Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers));
}

/// <summary>
/// Gets the HTTP status code.
/// </summary>
public global::System.Net.HttpStatusCode StatusCode { get; }
/// <summary>
/// Gets the response headers.
/// </summary>
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> Headers { get; }

internal static global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> CreateHeaders(
global::System.Net.Http.HttpResponseMessage response)
{
response = response ?? throw new global::System.ArgumentNullException(nameof(response));

var headers = global::System.Linq.Enumerable.ToDictionary(
response.Headers,
static header => header.Key,
static header => (global::System.Collections.Generic.IEnumerable<string>)global::System.Linq.Enumerable.ToArray(header.Value),
global::System.StringComparer.OrdinalIgnoreCase);

if (response.Content?.Headers == null)
{
return headers;
}

foreach (var header in response.Content.Headers)
{
if (headers.TryGetValue(header.Key, out var existingValues))
{
headers[header.Key] = global::System.Linq.Enumerable.ToArray(
global::System.Linq.Enumerable.Concat(existingValues, header.Value));
}
else
{
headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value);
}
}

return headers;
}
}

/// <summary>
/// Represents a successful HTTP response with status code, headers, and body.
/// </summary>
public partial class AutoSDKHttpResponse<T> : AutoSDKHttpResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
T body)
: base(statusCode, headers)
{
Body = body;
}

/// <summary>
/// Gets the response body.
/// </summary>
public T Body { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ partial void ProcessGatewayDownloadFileResponseContent(
public async global::System.Threading.Tasks.Task<byte[]> GatewayDownloadFileAsync(
string fileId,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __response = await GatewayDownloadFileAsResponseAsync(
fileId: fileId,
cancellationToken: cancellationToken
).ConfigureAwait(false);

return __response.Body;
}
/// <summary>
/// Download file<br/>
/// Download the binary content of a file. The response will contain the file data in the appropriate MIME type.
/// </summary>
/// <param name="fileId"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Writer.ApiException"></exception>
/// <remarks>
/// curl --location --request GET https://api.writer.com/v1/files/{file_id}/download \<br/>
/// --header "Authorization: Bearer &lt;token&gt;"
/// </remarks>
public async global::System.Threading.Tasks.Task<global::Writer.AutoSDKHttpResponse<byte[]>> GatewayDownloadFileAsResponseAsync(
string fileId,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
Expand Down Expand Up @@ -107,7 +129,10 @@ partial void ProcessGatewayDownloadFileResponseContent(
{
__response.EnsureSuccessStatusCode();

return __content;
return new global::Writer.AutoSDKHttpResponse<byte[]>(
statusCode: __response.StatusCode,
headers: global::Writer.AutoSDKHttpResponse.CreateHeaders(__response),
body: __content);
}
catch (global::System.Exception __ex)
{
Expand Down Expand Up @@ -135,7 +160,10 @@ partial void ProcessGatewayDownloadFileResponseContent(
#endif
).ConfigureAwait(false);

return __content;
return new global::Writer.AutoSDKHttpResponse<byte[]>(
statusCode: __response.StatusCode,
headers: global::Writer.AutoSDKHttpResponse.CreateHeaders(__response),
body: __content);
}
catch (global::System.Exception __ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,19 @@ public partial interface IFileApiClient
global::System.Threading.Tasks.Task<byte[]> GatewayDownloadFileAsync(
string fileId,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Download file<br/>
/// Download the binary content of a file. The response will contain the file data in the appropriate MIME type.
/// </summary>
/// <param name="fileId"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Writer.ApiException"></exception>
/// <remarks>
/// curl --location --request GET https://api.writer.com/v1/files/{file_id}/download \<br/>
/// --header "Authorization: Bearer &lt;token&gt;"
/// </remarks>
global::System.Threading.Tasks.Task<global::Writer.AutoSDKHttpResponse<byte[]>> GatewayDownloadFileAsResponseAsync(
string fileId,
global::System.Threading.CancellationToken cancellationToken = default);
}
}