diff --git a/Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs b/Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs index c551eb7..6f5d5b3 100644 --- a/Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs +++ b/Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs @@ -834,6 +834,105 @@ public virtual async System.Threading.Tasks.Task ApiV2Accoun } } + /// + /// Sum unused clip cards within a given period per productId + /// + /// Request object containing start and end date of the query + /// Products with tickets that match the criteria + /// A server side error occurred. + public virtual System.Threading.Tasks.Task> ApiV2StatisticsUnusedClipsAsync(UnusedClipsRequest unusedClipsRequest) + { + return ApiV2StatisticsUnusedClipsAsync(unusedClipsRequest, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Sum unused clip cards within a given period per productId + /// + /// Request object containing start and end date of the query + /// Products with tickets that match the criteria + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task> 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>(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(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(" 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(); + } + } + /// /// Get app configuration /// @@ -3363,6 +3462,58 @@ public enum UserState } + /// + /// Initialize a response with unused clips data + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] + public partial class UnusedClipsResponse + { + /// + /// The id of the product + /// + [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int ProductId { get; set; } + + /// + /// The name of the product + /// + [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string ProductName { get; set; } + + /// + /// The number of tickets unused in a purchase + /// + [Newtonsoft.Json.JsonProperty("ticketsLeft", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int TicketsLeft { get; set; } + + /// + /// The value of the unused purchases of a given product + /// + [Newtonsoft.Json.JsonProperty("unusedPurchasesValue", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public decimal UnusedPurchasesValue { get; set; } + + } + + /// + /// Initialize a request for data with unused clips. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] + public partial class UnusedClipsRequest + { + /// + /// The start date of unused tickets query. + /// + [Newtonsoft.Json.JsonProperty("startDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset StartDate { get; set; } + + /// + /// The end date of unused tickets query. + /// + [Newtonsoft.Json.JsonProperty("endDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset EndDate { get; set; } + + } + /// /// App Configuration /// diff --git a/Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV2.json b/Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV2.json index 94a53fc..53463f8 100644 --- a/Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV2.json +++ b/Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV2.json @@ -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"], @@ -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",