Skip to content

Commit

Permalink
Add API v2 specs
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Guldborg committed Apr 15, 2024
1 parent 8dafdfa commit 205c4bd
Show file tree
Hide file tree
Showing 2 changed files with 255 additions and 0 deletions.
151 changes: 151 additions & 0 deletions Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,105 @@ public virtual async System.Threading.Tasks.Task<UserSearchResponse> ApiV2Accoun
}
}

/// <summary>
/// Sum unused clip cards within a given period per productId
/// </summary>
/// <param name="unusedClipsRequest">Request object containing start and end date of the query</param>
/// <returns>Products with tickets that match the criteria</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<UnusedClipsResponse>> ApiV2StatisticsUnusedClipsAsync(UnusedClipsRequest unusedClipsRequest)
{
return ApiV2StatisticsUnusedClipsAsync(unusedClipsRequest, System.Threading.CancellationToken.None);
}

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <summary>
/// Sum unused clip cards within a given period per productId
/// </summary>
/// <param name="unusedClipsRequest">Request object containing start and end date of the query</param>
/// <returns>Products with tickets that match the criteria</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<UnusedClipsResponse>> ApiV2StatisticsUnusedClipsAsync(UnusedClipsRequest unusedClipsRequest, System.Threading.CancellationToken cancellationToken)
{
if (unusedClipsRequest == null)
throw new System.ArgumentNullException("unusedClipsRequest");

var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append("api/v2/statistics/unused-clips");

var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(unusedClipsRequest, _settings.Value);
var content_ = new System.Net.Http.StringContent(json_);
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));

PrepareRequest(client_, request_, urlBuilder_);

var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);

PrepareRequest(client_, request_, url_);

var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}

ProcessResponse(client_, response_);

var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<UnusedClipsResponse>>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
if (status_ == 401)
{
var objectResponse_ = await ReadObjectResponseAsync<ApiError>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
throw new ApiException<ApiError>(" Invalid credentials ", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}

/// <summary>
/// Get app configuration
/// </summary>
Expand Down Expand Up @@ -3363,6 +3462,58 @@ public enum UserState

}

/// <summary>
/// Initialize a response with unused clips data
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")]
public partial class UnusedClipsResponse
{
/// <summary>
/// The id of the product
/// </summary>
[Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int ProductId { get; set; }

/// <summary>
/// The name of the product
/// </summary>
[Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string ProductName { get; set; }

/// <summary>
/// The number of tickets unused in a purchase
/// </summary>
[Newtonsoft.Json.JsonProperty("ticketsLeft", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int TicketsLeft { get; set; }

/// <summary>
/// The value of the unused purchases of a given product
/// </summary>
[Newtonsoft.Json.JsonProperty("unusedPurchasesValue", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public decimal UnusedPurchasesValue { get; set; }

}

/// <summary>
/// Initialize a request for data with unused clips.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")]
public partial class UnusedClipsRequest
{
/// <summary>
/// The start date of unused tickets query.
/// </summary>
[Newtonsoft.Json.JsonProperty("startDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset StartDate { get; set; }

/// <summary>
/// The end date of unused tickets query.
/// </summary>
[Newtonsoft.Json.JsonProperty("endDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset EndDate { get; set; }

}

/// <summary>
/// App Configuration
/// </summary>
Expand Down
104 changes: 104 additions & 0 deletions Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV2.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,61 @@
]
}
},
"/api/v2/statistics/unused-clips": {
"post": {
"tags": [
"AdminStatistics"
],
"summary": "Sum unused clip cards within a given period per productId",
"operationId": "AdminStatistics_GetUnusedClips",
"requestBody": {
"x-name": "unusedClipsRequest",
"description": "Request object containing start and end date of the query",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UnusedClipsRequest"
}
}
},
"required": true,
"x-position": 1
},
"responses": {
"200": {
"description": " Products with tickets that match the criteria ",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/UnusedClipsResponse"
}
}
}
}
},
"401": {
"description": " Invalid credentials ",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiError"
}
}
}
}
},
"security": [
{
"jwt": []
},
{
"apikey": []
}
]
}
},
"/api/v2/appconfig": {
"get": {
"tags": ["AppConfig"],
Expand Down Expand Up @@ -1737,6 +1792,55 @@
"x-enumNames": ["Active", "Deleted", "PendingActivition"],
"enum": ["Active", "Deleted", "PendingActivition"]
},
"UnusedClipsResponse": {
"type": "object",
"description": "Initialize a response with unused clips data",
"additionalProperties": false,
"properties": {
"productId": {
"type": "integer",
"description": "The id of the product",
"format": "int32",
"example": 1
},
"productName": {
"type": "string",
"description": "The name of the product",
"example": "Americano "
},
"ticketsLeft": {
"type": "integer",
"description": "The number of tickets unused in a purchase",
"format": "int32",
"example": 8
},
"unusedPurchasesValue": {
"type": "number",
"description": "The value of the unused purchases of a given product",
"format": "decimal",
"example": 40.2
}
}
},
"UnusedClipsRequest": {
"type": "object",
"description": "Initialize a request for data with unused clips.",
"additionalProperties": false,
"properties": {
"startDate": {
"type": "string",
"description": "The start date of unused tickets query.",
"format": "date-time",
"example": "2021-02-08"
},
"endDate": {
"type": "string",
"description": "The end date of unused tickets query.",
"format": "date-time",
"example": "2024-02-08"
}
}
},
"AppConfig": {
"type": "object",
"description": "App Configuration",
Expand Down

0 comments on commit 205c4bd

Please sign in to comment.