From c26d14ce96a9d909b4056fdad592ca535c8a58e7 Mon Sep 17 00:00:00 2001 From: Thomas Andersen Date: Mon, 15 Apr 2024 20:47:41 +0200 Subject: [PATCH] Added generation of strongly typed http client on build - Removed project for manual generation of client - AnalogCore clients are now automatically generated on build --- .../Generated/AnalogCoreV1/AnalogCoreV1.cs | 2513 ---------- .../Generated/AnalogCoreV2/AnalogCoreV2.cs | 4446 ----------------- Shifty.Api/Shifty.Api.csproj | 24 - Shifty.App/Shifty.App.csproj | 2 +- Shifty.GenerateApi/Program.cs | 67 - Shifty.GenerateApi/Shifty.GenerateApi.csproj | 16 - Shifty.GenerateApi/Shifty.GenerateApi.sln | 25 - .../OpenApiSpecs/AnalogCoreV1.json | 0 .../OpenApiSpecs/AnalogCoreV2.json | 0 Shifty.Generated.ApiClient/README.md | 12 + .../Shifty.Generated.ApiClient.csproj | 30 + Shifty.sln | 8 +- 12 files changed, 44 insertions(+), 7099 deletions(-) delete mode 100644 Shifty.Api/Generated/AnalogCoreV1/AnalogCoreV1.cs delete mode 100644 Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs delete mode 100644 Shifty.Api/Shifty.Api.csproj delete mode 100644 Shifty.GenerateApi/Program.cs delete mode 100644 Shifty.GenerateApi/Shifty.GenerateApi.csproj delete mode 100644 Shifty.GenerateApi/Shifty.GenerateApi.sln rename {Shifty.GenerateApi => Shifty.Generated.ApiClient}/OpenApiSpecs/AnalogCoreV1.json (100%) rename {Shifty.GenerateApi => Shifty.Generated.ApiClient}/OpenApiSpecs/AnalogCoreV2.json (100%) create mode 100644 Shifty.Generated.ApiClient/README.md create mode 100644 Shifty.Generated.ApiClient/Shifty.Generated.ApiClient.csproj diff --git a/Shifty.Api/Generated/AnalogCoreV1/AnalogCoreV1.cs b/Shifty.Api/Generated/AnalogCoreV1/AnalogCoreV1.cs deleted file mode 100644 index 1194070..0000000 --- a/Shifty.Api/Generated/AnalogCoreV1/AnalogCoreV1.cs +++ /dev/null @@ -1,2513 +0,0 @@ -//---------------------- -// -// Generated using the NSwag toolchain v13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0)) (http://NSwag.org) -// -//---------------------- - -#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." -#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." -#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' -#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... -#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." -#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'" -#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant" -#pragma warning disable 8603 // Disable "CS8603 Possible null reference return" - -namespace Shifty.Api.Generated.AnalogCoreV1 -{ - using System = global::System; - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class AnalogCoreV1 - { - private System.Net.Http.HttpClient _httpClient; - private System.Lazy _settings; - - public AnalogCoreV1(System.Net.Http.HttpClient httpClient) - { - _httpClient = httpClient; - _settings = new System.Lazy(CreateSerializerSettings); - } - - private Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() - { - var settings = new Newtonsoft.Json.JsonSerializerSettings(); - UpdateJsonSerializerSettings(settings); - return settings; - } - - protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } } - - partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); - - partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); - partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); - partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); - - /// - /// Register a new account. A account is required to verify its email before logging in - /// - /// Register data object - /// Successful account creation - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1AccountRegisterAsync(RegisterDto registerDto) - { - return ApiV1AccountRegisterAsync(registerDto, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Register a new account. A account is required to verify its email before logging in - /// - /// Register data object - /// Successful account creation - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1AccountRegisterAsync(RegisterDto registerDto, System.Threading.CancellationToken cancellationToken) - { - if (registerDto == null) - throw new System.ArgumentNullException("registerDto"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Account/register"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(registerDto, _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_ == 201) - { - 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_ == 409) - { - 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("Email already registered", 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(); - } - } - - /// - /// Returns a token that is used to identify the account - /// - /// Login data object - /// Successful account login - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1AccountLoginAsync(LoginDto loginDto) - { - return ApiV1AccountLoginAsync(loginDto, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a token that is used to identify the account - /// - /// Login data object - /// Successful account login - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1AccountLoginAsync(LoginDto loginDto, System.Threading.CancellationToken cancellationToken) - { - if (loginDto == null) - throw new System.ArgumentNullException("loginDto"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Account/login"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(loginDto, _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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 403) - { - 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("Account email not verified", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 429) - { - 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("A server side error occurred.", 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(); - } - } - - /// - /// Returns basic data about the account - /// - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1AccountGetAsync() - { - return ApiV1AccountGetAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns basic data about the account - /// - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1AccountGetAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Account"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - - 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_ == 410) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Deprecated", status_, responseText_, headers_, null); - } - else - - if (status_ == 200 || status_ == 204) - { - - return; - } - 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(); - } - } - - /// - /// Updates the account and returns the updated values. - ///
Only properties which are present in the UpdateUserDto will be updated - ///
- /// Update account information request. All properties are optional as the server only - ///
updates the values of the properties which are present - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1AccountPutAsync(UpdateUserDto updateUserDto) - { - return ApiV1AccountPutAsync(updateUserDto, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Updates the account and returns the updated values. - ///
Only properties which are present in the UpdateUserDto will be updated - ///
- /// Update account information request. All properties are optional as the server only - ///
updates the values of the properties which are present - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1AccountPutAsync(UpdateUserDto updateUserDto, System.Threading.CancellationToken cancellationToken) - { - if (updateUserDto == null) - throw new System.ArgumentNullException("updateUserDto"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Account"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(updateUserDto, _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("PUT"); - - 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_ == 410) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Deprecated", status_, responseText_, headers_, null); - } - else - - if (status_ == 200 || status_ == 204) - { - - return; - } - 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(); - } - } - - /// Account email - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1AccountForgotpasswordAsync(EmailDto emailDTO) - { - return ApiV1AccountForgotpasswordAsync(emailDTO, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// Account email - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1AccountForgotpasswordAsync(EmailDto emailDTO, System.Threading.CancellationToken cancellationToken) - { - if (emailDTO == null) - throw new System.ArgumentNullException("emailDTO"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Account/forgotpassword"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(emailDTO, _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_ == 404) - { - 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("E-mail not found", 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 - /// - /// A server side error occurred. - [System.Obsolete] - public virtual System.Threading.Tasks.Task ApiV1AppConfigAsync() - { - return ApiV1AppConfigAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get app configuration - /// - /// A server side error occurred. - [System.Obsolete] - public virtual async System.Threading.Tasks.Task ApiV1AppConfigAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/AppConfig"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - - 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_ == 410) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Deprecated", status_, responseText_, headers_, null); - } - else - - if (status_ == 200 || status_ == 204) - { - - return; - } - 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(); - } - } - - /// - /// Retrieve the coffee cards of the account - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1CoffeeCardsAsync() - { - return ApiV1CoffeeCardsAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Retrieve the coffee cards of the account - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1CoffeeCardsAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/CoffeeCards"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Gets the leaderboard by the specified preset - /// - /// Leaderboard preset. 0 - Monthly, 1 - Semester and 2 - Total - /// Number of results to return - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1LeaderboardAsync(int? preset, int? top) - { - return ApiV1LeaderboardAsync(preset, top, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Gets the leaderboard by the specified preset - /// - /// Leaderboard preset. 0 - Monthly, 1 - Semester and 2 - Total - /// Number of results to return - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1LeaderboardAsync(int? preset, int? top, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Leaderboard?"); - if (preset != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("preset") + "=").Append(System.Uri.EscapeDataString(ConvertToString(preset, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - if (top != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("top") + "=").Append(System.Uri.EscapeDataString(ConvertToString(top, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - urlBuilder_.Length--; - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - - 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_ == 410) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Deprecated", status_, responseText_, headers_, null); - } - else - - if (status_ == 200 || status_ == 204) - { - - return; - } - 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(); - } - } - - /// - /// Initiates a purchase from the given productId and returns an orderId - /// - /// Initiate purchase request - /// A server side error occurred. - [System.Obsolete] - public virtual System.Threading.Tasks.Task ApiV1MobilePayInitiateAsync(InitiatePurchaseDto initiatePurchaseDto) - { - return ApiV1MobilePayInitiateAsync(initiatePurchaseDto, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Initiates a purchase from the given productId and returns an orderId - /// - /// Initiate purchase request - /// A server side error occurred. - [System.Obsolete] - public virtual async System.Threading.Tasks.Task ApiV1MobilePayInitiateAsync(InitiatePurchaseDto initiatePurchaseDto, System.Threading.CancellationToken cancellationToken) - { - if (initiatePurchaseDto == null) - throw new System.ArgumentNullException("initiatePurchaseDto"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/MobilePay/initiate"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(initiatePurchaseDto, _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"); - - 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_ == 410) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Deprecated", status_, responseText_, headers_, null); - } - else - - if (status_ == 200 || status_ == 204) - { - - return; - } - 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(); - } - } - - /// - /// Validates the purchase against MobilePay and delivers the tickets if succeeded - /// - /// Complete purchase request with MobilePay reference - /// A server side error occurred. - [System.Obsolete] - public virtual System.Threading.Tasks.Task ApiV1MobilePayCompleteAsync(CompletePurchaseDto dto) - { - return ApiV1MobilePayCompleteAsync(dto, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Validates the purchase against MobilePay and delivers the tickets if succeeded - /// - /// Complete purchase request with MobilePay reference - /// A server side error occurred. - [System.Obsolete] - public virtual async System.Threading.Tasks.Task ApiV1MobilePayCompleteAsync(CompletePurchaseDto dto, System.Threading.CancellationToken cancellationToken) - { - if (dto == null) - throw new System.ArgumentNullException("dto"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/MobilePay/complete"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(dto, _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"); - - 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_ == 410) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Deprecated", status_, responseText_, headers_, null); - } - else - - if (status_ == 200 || status_ == 204) - { - - return; - } - 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(); - } - } - - /// - /// Ping - /// - /// Successful request - /// A server side error occurred. - [System.Obsolete] - public virtual System.Threading.Tasks.Task ApiV1PingAsync() - { - return ApiV1PingAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Ping - /// - /// Successful request - /// A server side error occurred. - [System.Obsolete] - public virtual async System.Threading.Tasks.Task ApiV1PingAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Ping"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - { - 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(); - } - } - - /// - /// Returns a list of available products based on a account's user group - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV1ProductsAsync() - { - return ApiV1ProductsAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of available products based on a account's user group - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV1ProductsAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Products"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - { - 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(); - } - } - - /// - /// Returns a list of available products based on a account's user group - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV1ProductsAppAsync() - { - return ApiV1ProductsAppAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of available products based on a account's user group - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV1ProductsAppAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Products/app"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Returns a list of available programmes - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV1ProgrammesAsync() - { - return ApiV1ProgrammesAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of available programmes - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV1ProgrammesAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Programmes"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - { - 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(); - } - } - - /// - /// Returns a list of purchases for the given user via the supplied token in the header - /// - /// A server side error occurred. - [System.Obsolete] - public virtual System.Threading.Tasks.Task ApiV1PurchasesAsync() - { - return ApiV1PurchasesAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of purchases for the given user via the supplied token in the header - /// - /// A server side error occurred. - [System.Obsolete] - public virtual async System.Threading.Tasks.Task ApiV1PurchasesAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Purchases"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - - 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_ == 410) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Deprecated", status_, responseText_, headers_, null); - } - else - - if (status_ == 200 || status_ == 204) - { - - return; - } - 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(); - } - } - - /// - /// Redeems the voucher supplied as parameter in the path - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1PurchasesRedeemvoucherAsync(string voucherCode) - { - return ApiV1PurchasesRedeemvoucherAsync(voucherCode, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Redeems the voucher supplied as parameter in the path - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1PurchasesRedeemvoucherAsync(string voucherCode, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Purchases/redeemvoucher?"); - if (voucherCode != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("voucherCode") + "=").Append(System.Uri.EscapeDataString(ConvertToString(voucherCode, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - urlBuilder_.Length--; - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); - 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_ == 409) - { - 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("Voucher code already used", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 401) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 404) - { - 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("Voucher code not found", 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(); - } - } - - /// - /// Issue purchase used by the ipad in the cafe - /// - /// A server side error occurred. - [System.Obsolete] - public virtual System.Threading.Tasks.Task ApiV1PurchasesIssueproductAsync(IssueProductDto issueProduct) - { - return ApiV1PurchasesIssueproductAsync(issueProduct, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Issue purchase used by the ipad in the cafe - /// - /// A server side error occurred. - [System.Obsolete] - public virtual async System.Threading.Tasks.Task ApiV1PurchasesIssueproductAsync(IssueProductDto issueProduct, System.Threading.CancellationToken cancellationToken) - { - if (issueProduct == null) - throw new System.ArgumentNullException("issueProduct"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Purchases/issueproduct"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(issueProduct, _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"); - - 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_ == 410) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Deprecated", status_, responseText_, headers_, null); - } - else - - if (status_ == 200 || status_ == 204) - { - - return; - } - 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(); - } - } - - /// - /// Returns a list of tickets - /// - /// Include already used tickets - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV1TicketsAsync(bool? used) - { - return ApiV1TicketsAsync(used, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of tickets - /// - /// Include already used tickets - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV1TicketsAsync(bool? used, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Tickets?"); - if (used != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("used") + "=").Append(System.Uri.EscapeDataString(ConvertToString(used, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - urlBuilder_.Length--; - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Uses the tickets supplied via product ids in the body - /// - /// Use multiple tickets request - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV1TicketsUseMultipleAsync(UseMultipleTicketDto dto) - { - return ApiV1TicketsUseMultipleAsync(dto, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Uses the tickets supplied via product ids in the body - /// - /// Use multiple tickets request - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV1TicketsUseMultipleAsync(UseMultipleTicketDto dto, System.Threading.CancellationToken cancellationToken) - { - if (dto == null) - throw new System.ArgumentNullException("dto"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Tickets/useMultiple"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(dto, _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_ == 400) - { - 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("Bad Request, not enough tickets. See explanation", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 401) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Use ticket request - /// - /// Use ticket request - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV1TicketsUseAsync(UseTicketDTO dto) - { - return ApiV1TicketsUseAsync(dto, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Use ticket request - /// - /// Use ticket request - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV1TicketsUseAsync(UseTicketDTO dto, System.Threading.CancellationToken cancellationToken) - { - if (dto == null) - throw new System.ArgumentNullException("dto"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v1/Tickets/use"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(dto, _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_ == 400) - { - 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("Bad Request, not enough tickets. See explanation", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 401) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - protected struct ObjectResponseResult - { - public ObjectResponseResult(T responseObject, string responseText) - { - this.Object = responseObject; - this.Text = responseText; - } - - public T Object { get; } - - public string Text { get; } - } - - public bool ReadResponseAsString { get; set; } - - protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Threading.CancellationToken cancellationToken) - { - if (response == null || response.Content == null) - { - return new ObjectResponseResult(default(T), string.Empty); - } - - if (ReadResponseAsString) - { - var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); - return new ObjectResponseResult(typedBody, responseText); - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; - throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception); - } - } - else - { - try - { - using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) - using (var streamReader = new System.IO.StreamReader(responseStream)) - using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) - { - var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); - var typedBody = serializer.Deserialize(jsonTextReader); - return new ObjectResponseResult(typedBody, string.Empty); - } - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; - throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception); - } - } - } - - private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) - { - if (value == null) - { - return ""; - } - - if (value is System.Enum) - { - var name = System.Enum.GetName(value.GetType(), value); - if (name != null) - { - var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); - if (field != null) - { - var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) - as System.Runtime.Serialization.EnumMemberAttribute; - if (attribute != null) - { - return attribute.Value != null ? attribute.Value : name; - } - } - - var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo)); - return converted == null ? string.Empty : converted; - } - } - else if (value is bool) - { - return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant(); - } - else if (value is byte[]) - { - return System.Convert.ToBase64String((byte[]) value); - } - else if (value.GetType().IsArray) - { - var array = System.Linq.Enumerable.OfType((System.Array) value); - return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo))); - } - - var result = System.Convert.ToString(value, cultureInfo); - return result == null ? "" : result; - } - } - - /// - /// Simple response class with a string message - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class MessageResponseDto - { - /// - /// Message with API response - /// - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Message { get; set; } - - } - - /// - /// Register a new user data object - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class RegisterDto - { - /// - /// Full Name of user - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Email Address of user - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Email { get; set; } - - /// - /// Pin Code as first UTF8 encoded, then SHA256 hashed, and then Base64 encoded string - /// - [Newtonsoft.Json.JsonProperty("password", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Password { get; set; } - - } - - /// - /// Login response with Bearer JWT Token - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class TokenDto - { - /// - /// Bearer JWT token used for authentication - /// - [Newtonsoft.Json.JsonProperty("token", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Token { get; set; } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ApiError - { - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Message { get; set; } - - } - - /// - /// Login data object - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class LoginDto - { - /// - /// Email Address of user - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Email { get; set; } - - /// - /// Pin Code as first UTF8 encoded, then SHA256 hashed, and then Base64 encoded string - /// - [Newtonsoft.Json.JsonProperty("password", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Password { get; set; } - - /// - /// App version of device logging in - /// - [Newtonsoft.Json.JsonProperty("version", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Version { get; set; } - - } - - /// - /// Update User information request object. All properties are optional as the server only updates the values of the properties which are present - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UpdateUserDto - { - /// - /// Full Name of user - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - /// - /// Email of user - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Email { get; set; } - - /// - /// Privacy Activated - /// - [Newtonsoft.Json.JsonProperty("privacyActivated", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public bool? PrivacyActivated { get; set; } - - /// - /// Study Programme Id of user - /// - [Newtonsoft.Json.JsonProperty("programmeId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int? ProgrammeId { get; set; } - - /// - /// Pin Code as first UTF8 encoded, then SHA256 hashed, and then Base64 encoded string - /// - [Newtonsoft.Json.JsonProperty("password", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Password { get; set; } - - } - - /// - /// User email data object - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class EmailDto - { - /// - /// User Email - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Email { get; set; } - - } - - /// - /// A CoffeeCard is a union datatype of a product and unused tickets associated with the product. - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class CoffeeCardDto - { - /// - /// Id of product - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// Name of product - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Remaining (if any) unused tickets left for product - /// - [Newtonsoft.Json.JsonProperty("ticketsLeft", Required = Newtonsoft.Json.Required.Always)] - public int TicketsLeft { get; set; } - - /// - /// Price of product - /// - [Newtonsoft.Json.JsonProperty("price", Required = Newtonsoft.Json.Required.Always)] - public int Price { get; set; } - - /// - /// Quantity of tickets in product - /// - [Newtonsoft.Json.JsonProperty("quantity", Required = Newtonsoft.Json.Required.Always)] - public int Quantity { get; set; } - - } - - /// - /// Initiate a new purchase request - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class InitiatePurchaseDto - { - /// - /// Id of product for purchase request - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - } - - /// - /// Represents a request to complete a purchase - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class CompletePurchaseDto - { - /// - /// Order Id for purchase - /// - [Newtonsoft.Json.JsonProperty("orderId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string OrderId { get; set; } - - /// - /// Transaction Id at external payment provider - /// - [Newtonsoft.Json.JsonProperty("transactionId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string TransactionId { get; set; } - - } - - /// - /// Represents a purchasable product - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ProductDto - { - /// - /// Id of product - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Product price - /// - [Newtonsoft.Json.JsonProperty("price", Required = Newtonsoft.Json.Required.Always)] - public int Price { get; set; } - - /// - /// Number of tickets in product - /// - [Newtonsoft.Json.JsonProperty("numberOfTickets", Required = Newtonsoft.Json.Required.Always)] - public int NumberOfTickets { get; set; } - - /// - /// Name of product - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Description of products - /// - [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Description { get; set; } - - } - - /// - /// Represents a study programme - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ProgrammeDto - { - /// - /// Id of study programme - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Short name of study programme - /// - [Newtonsoft.Json.JsonProperty("shortName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ShortName { get; set; } - - /// - /// Full name of study programme - /// - [Newtonsoft.Json.JsonProperty("fullName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string FullName { get; set; } - - } - - /// - /// Represents a purchase - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class PurchaseDto - { - /// - /// Id of purchase - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Name of purchased product - /// - [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ProductName { get; set; } - - /// - /// Id of purchased product - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// Total purchase price in Danish Kroner (kr) - /// - [Newtonsoft.Json.JsonProperty("price", Required = Newtonsoft.Json.Required.Always)] - public int Price { get; set; } - - /// - /// Number of tickets issued in purchase - /// - [Newtonsoft.Json.JsonProperty("numberOfTickets", Required = Newtonsoft.Json.Required.Always)] - public int NumberOfTickets { get; set; } - - /// - /// Date time for purchase in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateCreated", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateCreated { get; set; } - - /// - /// Is purchase completed (with MobilePay) - /// - [Newtonsoft.Json.JsonProperty("completed", Required = Newtonsoft.Json.Required.Always)] - public bool Completed { get; set; } - - /// - /// Order Id - /// - [Newtonsoft.Json.JsonProperty("orderId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string OrderId { get; set; } - - /// - /// Transaction id at external payment provider - /// - [Newtonsoft.Json.JsonProperty("transactionId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string TransactionId { get; set; } - - } - - /// - /// Issue product request - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class IssueProductDto - { - /// - /// Name/Initials of person who issued purchase - /// - [Newtonsoft.Json.JsonProperty("issuedBy", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string IssuedBy { get; set; } - - /// - /// User id who should receive the product - /// - [Newtonsoft.Json.JsonProperty("userId", Required = Newtonsoft.Json.Required.Always)] - public int UserId { get; set; } - - /// - /// Id of Product to issue - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - } - - /// - /// Representing a ticket for a product - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class TicketDto - { - /// - /// Ticket Id - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Issuing date time for ticket in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateCreated", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateCreated { get; set; } - - /// - /// Used date time for ticket in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateUsed", Required = Newtonsoft.Json.Required.AllowNull)] - public System.DateTimeOffset? DateUsed { get; set; } - - /// - /// Name of product a ticket is for - /// - [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ProductName { get; set; } - - } - - /// - /// Use multiple tickets request - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UseMultipleTicketDto - { - /// - /// List of products ids to use a ticket for - /// - [Newtonsoft.Json.JsonProperty("productIds", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection ProductIds { get; set; } = new System.Collections.ObjectModel.Collection(); - - } - - /// - /// Representing a used ticket for a product - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UsedTicketResponse - { - /// - /// Ticket Id - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Issuing date time for ticket in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateCreated", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateCreated { get; set; } - - /// - /// Used date time for ticket in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateUsed", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateUsed { get; set; } - - /// - /// Name of product a ticket is for - /// - [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ProductName { get; set; } - - } - - /// - /// Use ticket request - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UseTicketDTO - { - /// - /// Id of product to use a ticket for - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - } - - - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ApiException : System.Exception - { - public int StatusCode { get; private set; } - - public string Response { get; private set; } - - public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } - - public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) - : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException) - { - StatusCode = statusCode; - Response = response; - Headers = headers; - } - - public override string ToString() - { - return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); - } - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ApiException : ApiException - { - public TResult Result { get; private set; } - - public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) - : base(message, statusCode, response, headers, innerException) - { - Result = result; - } - } - -} - -#pragma warning restore 1591 -#pragma warning restore 1573 -#pragma warning restore 472 -#pragma warning restore 114 -#pragma warning restore 108 -#pragma warning restore 3016 -#pragma warning restore 8603 \ No newline at end of file diff --git a/Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs b/Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs deleted file mode 100644 index c551eb7..0000000 --- a/Shifty.Api/Generated/AnalogCoreV2/AnalogCoreV2.cs +++ /dev/null @@ -1,4446 +0,0 @@ -//---------------------- -// -// Generated using the NSwag toolchain v13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0)) (http://NSwag.org) -// -//---------------------- - -#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." -#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." -#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' -#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... -#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." -#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'" -#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant" -#pragma warning disable 8603 // Disable "CS8603 Possible null reference return" - -namespace Shifty.Api.Generated.AnalogCoreV2 -{ - using System = global::System; - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class AnalogCoreV2 - { - private System.Net.Http.HttpClient _httpClient; - private System.Lazy _settings; - - public AnalogCoreV2(System.Net.Http.HttpClient httpClient) - { - _httpClient = httpClient; - _settings = new System.Lazy(CreateSerializerSettings); - } - - private Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() - { - var settings = new Newtonsoft.Json.JsonSerializerSettings(); - UpdateJsonSerializerSettings(settings); - return settings; - } - - protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } } - - partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); - - partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); - partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); - partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); - - /// - /// Register data request. An account is required to verify its email before logging in - /// - /// Register data object - /// Successful account creation. Verification request email sent to provided email - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AccountPostAsync(RegisterAccountRequest registerRequest) - { - return ApiV2AccountPostAsync(registerRequest, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Register data request. An account is required to verify its email before logging in - /// - /// Register data object - /// Successful account creation. Verification request email sent to provided email - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AccountPostAsync(RegisterAccountRequest registerRequest, System.Threading.CancellationToken cancellationToken) - { - if (registerRequest == null) - throw new System.ArgumentNullException("registerRequest"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/account"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(registerRequest, _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_ == 201) - { - 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_ == 409) - { - 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("Email already registered", 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(); - } - } - - /// - /// Request the deletion of the user coupled to the provided token - /// - /// Successful initiation of account deletion process - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AccountDeleteAsync() - { - return ApiV2AccountDeleteAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Request the deletion of the user coupled to the provided token - /// - /// Successful initiation of account deletion process - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AccountDeleteAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/account"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("DELETE"); - - 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_ == 202) - { - return; - } - else - if (status_ == 401) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 429) - { - 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("A server side error occurred.", 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(); - } - } - - /// - /// Returns basic data about the account - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AccountGetAsync() - { - return ApiV2AccountGetAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns basic data about the account - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AccountGetAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/account"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Updates the account and returns the updated values. - ///
Only properties which are present in the UpdateUserRequest will be updated - ///
- /// Update account information request. All properties are optional as the server only - ///
updates the values of the properties which are present - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AccountPutAsync(UpdateUserRequest updateUserRequest) - { - return ApiV2AccountPutAsync(updateUserRequest, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Updates the account and returns the updated values. - ///
Only properties which are present in the UpdateUserRequest will be updated - ///
- /// Update account information request. All properties are optional as the server only - ///
updates the values of the properties which are present - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AccountPutAsync(UpdateUserRequest updateUserRequest, System.Threading.CancellationToken cancellationToken) - { - if (updateUserRequest == null) - throw new System.ArgumentNullException("updateUserRequest"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/account"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(updateUserRequest, _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("PUT"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Check if a given email is in use - /// - /// The email that should be checked - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AccountEmailExistsAsync(EmailExistsRequest request) - { - return ApiV2AccountEmailExistsAsync(request, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Check if a given email is in use - /// - /// The email that should be checked - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AccountEmailExistsAsync(EmailExistsRequest request, System.Threading.CancellationToken cancellationToken) - { - if (request == null) - throw new System.ArgumentNullException("request"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/account/email-exists"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(request, _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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Updates the user group of a user - /// - /// id of the user whose userGroup will be updated - /// Update User Group information request - /// The update was processed - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AccountUserGroupAsync(int id, UpdateUserGroupRequest updateUserGroupRequest) - { - return ApiV2AccountUserGroupAsync(id, updateUserGroupRequest, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Updates the user group of a user - /// - /// id of the user whose userGroup will be updated - /// Update User Group information request - /// The update was processed - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AccountUserGroupAsync(int id, UpdateUserGroupRequest updateUserGroupRequest, System.Threading.CancellationToken cancellationToken) - { - if (id == null) - throw new System.ArgumentNullException("id"); - - if (updateUserGroupRequest == null) - throw new System.ArgumentNullException("updateUserGroupRequest"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/account/{id}/user-group"); - urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(updateUserGroupRequest, _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("PATCH"); - - 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_ == 204) - { - return; - } - 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 - if (status_ == 404) - { - 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(" User not found ", 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(); - } - } - - /// - /// Resend account verification email if account is not already verified - /// - /// Email to be verified - /// Email has been sent - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AccountResendVerificationEmailAsync(ResendAccountVerificationEmailRequest request) - { - return ApiV2AccountResendVerificationEmailAsync(request, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Resend account verification email if account is not already verified - /// - /// Email to be verified - /// Email has been sent - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AccountResendVerificationEmailAsync(ResendAccountVerificationEmailRequest request, System.Threading.CancellationToken cancellationToken) - { - if (request == null) - throw new System.ArgumentNullException("request"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/account/resend-verification-email"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(request, _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"); - - 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) - { - return; - } - else - if (status_ == 404) - { - 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("Email not found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 409) - { - 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("Account already verified", 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(); - } - } - - /// - /// Searches a user in the database - /// - /// The page number - /// A filter to search by Id, Name or Email. When an empty string is given, all users will be returned - /// The length of a page - /// Users, possible with filter applied - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AccountSearchAsync(int? pageNum, string filter, int? pageLength) - { - return ApiV2AccountSearchAsync(pageNum, filter, pageLength, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Searches a user in the database - /// - /// The page number - /// A filter to search by Id, Name or Email. When an empty string is given, all users will be returned - /// The length of a page - /// Users, possible with filter applied - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AccountSearchAsync(int? pageNum, string filter, int? pageLength, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/account/search?"); - if (pageNum != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("pageNum") + "=").Append(System.Uri.EscapeDataString(ConvertToString(pageNum, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - if (filter != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("filter") + "=").Append(System.Uri.EscapeDataString(ConvertToString(filter, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - if (pageLength != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("pageLength") + "=").Append(System.Uri.EscapeDataString(ConvertToString(pageLength, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - urlBuilder_.Length--; - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2AppconfigAsync() - { - return ApiV2AppconfigAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get app configuration - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2AppconfigAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/appconfig"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - { - 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(); - } - } - - /// - /// Ping - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2HealthPingAsync() - { - return ApiV2HealthPingAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Ping - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2HealthPingAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/health/ping"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - { - 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(); - } - } - - /// - /// Check service health - /// - /// Healthy service - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2HealthCheckAsync() - { - return ApiV2HealthCheckAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Check service health - /// - /// Healthy service - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2HealthCheckAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/health/check"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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_ == 503) - { - 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("Unhealthy service", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("A server side error occurred.", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - - /// - /// Gets the top leaderboard by the specified preset - /// - /// Leaderboard preset for date filtering. See LeaderboardPreset for possible values - /// Number of top results to return - /// Top leader board entries - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV2LeaderboardTopAsync(LeaderboardPreset? preset, int? top) - { - return ApiV2LeaderboardTopAsync(preset, top, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Gets the top leaderboard by the specified preset - /// - /// Leaderboard preset for date filtering. See LeaderboardPreset for possible values - /// Number of top results to return - /// Top leader board entries - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV2LeaderboardTopAsync(LeaderboardPreset? preset, int? top, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/leaderboard/top?"); - if (preset != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("preset") + "=").Append(System.Uri.EscapeDataString(ConvertToString(preset, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - if (top != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("top") + "=").Append(System.Uri.EscapeDataString(ConvertToString(top, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - urlBuilder_.Length--; - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - { - 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 leaderboard stats for authenticated user. A user will have rank 0 if they do not have any valid swipes - /// - /// Leaderboard preset for date filtering. See LeaderboardPreset for possible values - /// Leaderboard entry for user - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2LeaderboardAsync(LeaderboardPreset? preset) - { - return ApiV2LeaderboardAsync(preset, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get leaderboard stats for authenticated user. A user will have rank 0 if they do not have any valid swipes - /// - /// Leaderboard preset for date filtering. See LeaderboardPreset for possible values - /// Leaderboard entry for user - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2LeaderboardAsync(LeaderboardPreset? preset, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/leaderboard?"); - if (preset != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("preset") + "=").Append(System.Uri.EscapeDataString(ConvertToString(preset, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - urlBuilder_.Length--; - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Returns a list of all menu items - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV2MenuitemsGetAsync() - { - return ApiV2MenuitemsGetAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of all menu items - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV2MenuitemsGetAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/menuitems"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - { - 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(); - } - } - - /// - /// Adds a menu item - /// - /// Menu item to add - /// Menu item successfully added - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2MenuitemsPostAsync(AddMenuItemRequest menuItem) - { - return ApiV2MenuitemsPostAsync(menuItem, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Adds a menu item - /// - /// Menu item to add - /// Menu item successfully added - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2MenuitemsPostAsync(AddMenuItemRequest menuItem, System.Threading.CancellationToken cancellationToken) - { - if (menuItem == null) - throw new System.ArgumentNullException("menuItem"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/menuitems"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(menuItem, _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_ == 201) - { - 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 - { - 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(); - } - } - - /// - /// Updates a menu item - /// - /// Menu item id to update - /// Menu item to update - /// Menu item successfully updated - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2MenuitemsPutAsync(int id, UpdateMenuItemRequest menuItem) - { - return ApiV2MenuitemsPutAsync(id, menuItem, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Updates a menu item - /// - /// Menu item id to update - /// Menu item to update - /// Menu item successfully updated - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2MenuitemsPutAsync(int id, UpdateMenuItemRequest menuItem, System.Threading.CancellationToken cancellationToken) - { - if (id == null) - throw new System.ArgumentNullException("id"); - - if (menuItem == null) - throw new System.ArgumentNullException("menuItem"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/menuitems/{id}"); - urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(menuItem, _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("PUT"); - 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 - { - 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(); - } - } - - /// - /// Webhook to be invoked by MobilePay backend - /// - /// Webhook signature - /// Webhook request - /// Webhook processed - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2MobilepayWebhookAsync(string mpSignatureHeader, MobilePayWebhook request) - { - return ApiV2MobilepayWebhookAsync(mpSignatureHeader, request, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Webhook to be invoked by MobilePay backend - /// - /// Webhook signature - /// Webhook request - /// Webhook processed - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2MobilepayWebhookAsync(string mpSignatureHeader, MobilePayWebhook request, System.Threading.CancellationToken cancellationToken) - { - if (request == null) - throw new System.ArgumentNullException("request"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/mobilepay/webhook"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - - if (mpSignatureHeader != null) - request_.Headers.TryAddWithoutValidation("x-mobilepay-signature", ConvertToString(mpSignatureHeader, System.Globalization.CultureInfo.InvariantCulture)); - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(request, _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"); - - 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_ == 204) - { - return; - } - else - if (status_ == 400) - { - 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("Signature is not valid", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("A server side error occurred.", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - - /// - /// Adds a new product - /// - /// The request containing the details of the product to be added and allowed user groups - /// The newly added product - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2ProductsPostAsync(AddProductRequest addProductRequest) - { - return ApiV2ProductsPostAsync(addProductRequest, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Adds a new product - /// - /// The request containing the details of the product to be added and allowed user groups - /// The newly added product - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2ProductsPostAsync(AddProductRequest addProductRequest, System.Threading.CancellationToken cancellationToken) - { - if (addProductRequest == null) - throw new System.ArgumentNullException("addProductRequest"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/products"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(addProductRequest, _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_ == 201) - { - 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 - { - 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(); - } - } - - /// - /// Returns a list of available products based on a account's user group. - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV2ProductsGetAsync() - { - return ApiV2ProductsGetAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of available products based on a account's user group. - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV2ProductsGetAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/products"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Updates a product with the specified changes. - /// - /// Product Id - /// The request containing the changes to be applied to the product - /// The product was updated - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2ProductsPutAsync(int productId, UpdateProductRequest product) - { - return ApiV2ProductsPutAsync(productId, product, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Updates a product with the specified changes. - /// - /// Product Id - /// The request containing the changes to be applied to the product - /// The product was updated - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2ProductsPutAsync(int productId, UpdateProductRequest product, System.Threading.CancellationToken cancellationToken) - { - if (productId == null) - throw new System.ArgumentNullException("productId"); - - if (product == null) - throw new System.ArgumentNullException("product"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/products/{id}"); - urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(productId, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(product, _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("PUT"); - 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 - { - 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(); - } - } - - /// - /// Returns a product with the specified id - /// - /// The id of the product to be returned - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2ProductsGetAsync(int productId) - { - return ApiV2ProductsGetAsync(productId, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a product with the specified id - /// - /// The id of the product to be returned - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2ProductsGetAsync(int productId, System.Threading.CancellationToken cancellationToken) - { - if (productId == null) - throw new System.ArgumentNullException("productId"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/products/{id}"); - urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(productId, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 404) - { - 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("The product with the specified id could not be found", 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(); - } - } - - /// - /// Returns a list of all products - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV2ProductsAllAsync() - { - return ApiV2ProductsAllAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of all products - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV2ProductsAllAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/products/all"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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 - { - 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 all purchases - /// - /// Purchases - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV2PurchasesGetAsync() - { - return ApiV2PurchasesGetAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get all purchases - /// - /// Purchases - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV2PurchasesGetAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/purchases"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("A server side error occurred.", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - - /// - /// Initiate a new payment. - /// - /// Initiate request - /// Purchased initiated - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2PurchasesPostAsync(InitiatePurchaseRequest initiateRequest) - { - return ApiV2PurchasesPostAsync(initiateRequest, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Initiate a new payment. - /// - /// Initiate request - /// Purchased initiated - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2PurchasesPostAsync(InitiatePurchaseRequest initiateRequest, System.Threading.CancellationToken cancellationToken) - { - if (initiateRequest == null) - throw new System.ArgumentNullException("initiateRequest"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/purchases"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(initiateRequest, _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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 403) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("User not allowed to purchase given product", status_, responseText_, headers_, 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 purchase - /// - /// Purchase Id - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2PurchasesGetAsync(int id) - { - return ApiV2PurchasesGetAsync(id, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get purchase - /// - /// Purchase Id - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2PurchasesGetAsync(int id, System.Threading.CancellationToken cancellationToken) - { - if (id == null) - throw new System.ArgumentNullException("id"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/purchases/{id}"); - urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 404) - { - 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("No purchase found with purchase-id", 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(); - } - } - - /// - /// Returns a list of tickets - /// - /// Include already used tickets - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV2TicketsAsync(bool? includeUsed) - { - return ApiV2TicketsAsync(includeUsed, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Returns a list of tickets - /// - /// Include already used tickets - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV2TicketsAsync(bool? includeUsed, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/tickets?"); - if (includeUsed != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("includeUsed") + "=").Append(System.Uri.EscapeDataString(ConvertToString(includeUsed, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - urlBuilder_.Length--; - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - 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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Uses a ticket (for the given product) on the given menu item - /// - /// The product id and menu item id to use a ticket for - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2TicketsUseAsync(UseTicketRequest request) - { - return ApiV2TicketsUseAsync(request, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Uses a ticket (for the given product) on the given menu item - /// - /// The product id and menu item id to use a ticket for - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2TicketsUseAsync(UseTicketRequest request, System.Threading.CancellationToken cancellationToken) - { - if (request == null) - throw new System.ArgumentNullException("request"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/tickets/use"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(request, _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) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 403) - { - 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("User has no tickets for the product or the menu item is not eligible for the ticket", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 404) - { - 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("The product or menu item could not be found", 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(); - } - } - - /// - /// Issue voucher codes, that can later be redeemed - /// - /// Use ticket request - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task> ApiV2VouchersIssueVouchersAsync(IssueVoucherRequest request) - { - return ApiV2VouchersIssueVouchersAsync(request, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Issue voucher codes, that can later be redeemed - /// - /// Use ticket request - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> ApiV2VouchersIssueVouchersAsync(IssueVoucherRequest request, System.Threading.CancellationToken cancellationToken) - { - if (request == null) - throw new System.ArgumentNullException("request"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/vouchers/issue-vouchers"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(request, _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_ == 400) - { - 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("Bad Request. See explanation", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 401) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 403) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid role in credentials", status_, responseText_, headers_, 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(); - } - } - - /// - /// Redeems the voucher supplied as parameter in the path - /// - /// Successful request - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2VouchersRedeemAsync(string voucherCode) - { - return ApiV2VouchersRedeemAsync(voucherCode, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Redeems the voucher supplied as parameter in the path - /// - /// Successful request - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2VouchersRedeemAsync(string voucherCode, System.Threading.CancellationToken cancellationToken) - { - if (voucherCode == null) - throw new System.ArgumentNullException("voucherCode"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/vouchers/{voucher-code}/redeem"); - urlBuilder_.Replace("{voucher-code}", System.Uri.EscapeDataString(ConvertToString(voucherCode, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); - 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_ == 400) - { - 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("Voucher code already used", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 401) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, null); - } - else - if (status_ == 404) - { - 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("Voucher code not found", 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(); - } - } - - /// - /// Update user groups in bulk - /// - /// The request containing the new user groups - /// The user groups were updated - /// A server side error occurred. - public virtual System.Threading.Tasks.Task ApiV2WebhooksAccountsUserGroupAsync(WebhookUpdateUserGroupRequest request) - { - return ApiV2WebhooksAccountsUserGroupAsync(request, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Update user groups in bulk - /// - /// The request containing the new user groups - /// The user groups were updated - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task ApiV2WebhooksAccountsUserGroupAsync(WebhookUpdateUserGroupRequest request, System.Threading.CancellationToken cancellationToken) - { - if (request == null) - throw new System.ArgumentNullException("request"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append("api/v2/webhooks/accounts/user-group"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(request, _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("PUT"); - - 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_ == 204) - { - return; - } - else - if (status_ == 400) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Bad request. See explanation", status_, responseText_, headers_, null); - } - else - if (status_ == 401) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("Invalid credentials", status_, responseText_, headers_, 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(); - } - } - - protected struct ObjectResponseResult - { - public ObjectResponseResult(T responseObject, string responseText) - { - this.Object = responseObject; - this.Text = responseText; - } - - public T Object { get; } - - public string Text { get; } - } - - public bool ReadResponseAsString { get; set; } - - protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Threading.CancellationToken cancellationToken) - { - if (response == null || response.Content == null) - { - return new ObjectResponseResult(default(T), string.Empty); - } - - if (ReadResponseAsString) - { - var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); - return new ObjectResponseResult(typedBody, responseText); - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; - throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception); - } - } - else - { - try - { - using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) - using (var streamReader = new System.IO.StreamReader(responseStream)) - using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) - { - var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); - var typedBody = serializer.Deserialize(jsonTextReader); - return new ObjectResponseResult(typedBody, string.Empty); - } - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; - throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception); - } - } - } - - private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) - { - if (value == null) - { - return ""; - } - - if (value is System.Enum) - { - var name = System.Enum.GetName(value.GetType(), value); - if (name != null) - { - var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); - if (field != null) - { - var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) - as System.Runtime.Serialization.EnumMemberAttribute; - if (attribute != null) - { - return attribute.Value != null ? attribute.Value : name; - } - } - - var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo)); - return converted == null ? string.Empty : converted; - } - } - else if (value is bool) - { - return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant(); - } - else if (value is byte[]) - { - return System.Convert.ToBase64String((byte[]) value); - } - else if (value.GetType().IsArray) - { - var array = System.Linq.Enumerable.OfType((System.Array) value); - return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo))); - } - - var result = System.Convert.ToString(value, cultureInfo); - return result == null ? "" : result; - } - } - - /// - /// Simple response class with a string message - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class MessageResponseDto - { - /// - /// Message with API response - /// - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Message { get; set; } - - } - - /// - /// Register a new user - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class RegisterAccountRequest - { - /// - /// Full Name of user - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Email Address of user - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Email { get; set; } - - /// - /// Pin Code as first UTF8 encoded, then SHA256 hashed, and then Base64 encoded string - /// - [Newtonsoft.Json.JsonProperty("password", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Password { get; set; } - - /// - /// Programme of user - /// - [Newtonsoft.Json.JsonProperty("programmeId", Required = Newtonsoft.Json.Required.Always)] - public int ProgrammeId { get; set; } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ApiError - { - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Message { get; set; } - - } - - /// - /// User information - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UserResponse - { - /// - /// User Id - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Full Name of user - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Email of user - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Email { get; set; } - - /// - /// Privacy Activated - /// - [Newtonsoft.Json.JsonProperty("privacyActivated", Required = Newtonsoft.Json.Required.Always)] - public bool PrivacyActivated { get; set; } - - /// - /// User's role - /// - [Newtonsoft.Json.JsonProperty("role", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public UserRole Role { get; set; } - - /// - /// Study Programme Id of user - /// - [Newtonsoft.Json.JsonProperty("programme", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public ProgrammeResponse Programme { get; set; } = new ProgrammeResponse(); - - /// - /// User's Rank all time - /// - [Newtonsoft.Json.JsonProperty("rankAllTime", Required = Newtonsoft.Json.Required.Always)] - public int RankAllTime { get; set; } - - /// - /// User's rank current semester - /// - [Newtonsoft.Json.JsonProperty("rankSemester", Required = Newtonsoft.Json.Required.Always)] - public int RankSemester { get; set; } - - /// - /// User's rank current month - /// - [Newtonsoft.Json.JsonProperty("rankMonth", Required = Newtonsoft.Json.Required.Always)] - public int RankMonth { get; set; } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public enum UserRole - { - - [System.Runtime.Serialization.EnumMember(Value = @"Customer")] - Customer = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"Barista")] - Barista = 1, - - [System.Runtime.Serialization.EnumMember(Value = @"Manager")] - Manager = 2, - - [System.Runtime.Serialization.EnumMember(Value = @"Board")] - Board = 3, - - } - - /// - /// Represents a study programme - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ProgrammeResponse - { - /// - /// Id of study programme - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Short name of study programme - /// - [Newtonsoft.Json.JsonProperty("shortName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ShortName { get; set; } - - /// - /// Full name of study programme - /// - [Newtonsoft.Json.JsonProperty("fullName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string FullName { get; set; } - - } - - /// - /// Update User information request object. All properties are optional as the server only updates the values of the properties which are present - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UpdateUserRequest - { - /// - /// Full Name of user - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - /// - /// Email of user - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Email { get; set; } - - /// - /// Privacy Activated - /// - [Newtonsoft.Json.JsonProperty("privacyActivated", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public bool? PrivacyActivated { get; set; } - - /// - /// Study Programme Id of user - /// - [Newtonsoft.Json.JsonProperty("programmeId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int? ProgrammeId { get; set; } - - /// - /// Pin Code as first UTF8 encoded, then SHA256 hashed, and then Base64 encoded string - /// - [Newtonsoft.Json.JsonProperty("password", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Password { get; set; } - - } - - /// - /// Contains information about an email being in use - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class EmailExistsResponse - { - /// - /// Contains information about an email being in use - /// - [Newtonsoft.Json.JsonProperty("emailExists", Required = Newtonsoft.Json.Required.Always)] - public bool EmailExists { get; set; } - - } - - /// - /// An email that should be checked if it already exists - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class EmailExistsRequest - { - /// - /// Email - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Email { get; set; } - - } - - /// - /// Update the UserGroup property of a user - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UpdateUserGroupRequest - { - /// - /// The UserGroup of a user - /// - [Newtonsoft.Json.JsonProperty("userGroup", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public UserGroup UserGroup { get; set; } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public enum UserGroup - { - - [System.Runtime.Serialization.EnumMember(Value = @"Customer")] - Customer = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"Barista")] - Barista = 1, - - [System.Runtime.Serialization.EnumMember(Value = @"Manager")] - Manager = 2, - - [System.Runtime.Serialization.EnumMember(Value = @"Board")] - Board = 3, - - } - - /// - /// Resend Invite email request - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ResendAccountVerificationEmailRequest - { - /// - /// User email - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Email { get; set; } - - } - - /// - /// Represents a search result - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UserSearchResponse - { - /// - /// The number of users that match the query - /// - [Newtonsoft.Json.JsonProperty("totalUsers", Required = Newtonsoft.Json.Required.Always)] - public int TotalUsers { get; set; } - - /// - /// The users that match the query - /// - [Newtonsoft.Json.JsonProperty("users", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection Users { get; set; } = new System.Collections.ObjectModel.Collection(); - - } - - /// - /// Basic User details - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class SimpleUserResponse - { - /// - /// User Id - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int Id { get; set; } - - /// - /// User's Display Name - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - /// - /// User's Email - /// - [Newtonsoft.Json.JsonProperty("email", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Email { get; set; } - - /// - /// User's User group relationship - /// - [Newtonsoft.Json.JsonProperty("userGroup", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public UserGroup UserGroup { get; set; } - - /// - /// User's State - /// - [Newtonsoft.Json.JsonProperty("state", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public UserState State { get; set; } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public enum UserState - { - - [System.Runtime.Serialization.EnumMember(Value = @"Active")] - Active = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"Deleted")] - Deleted = 1, - - [System.Runtime.Serialization.EnumMember(Value = @"PendingActivition")] - PendingActivition = 2, - - } - - /// - /// App Configuration - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class AppConfig - { - /// - /// Environment type for indicating production or test system - /// - [Newtonsoft.Json.JsonProperty("environmentType", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public EnvironmentType EnvironmentType { get; set; } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public enum EnvironmentType - { - - [System.Runtime.Serialization.EnumMember(Value = @"Production")] - Production = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"Test")] - Test = 1, - - [System.Runtime.Serialization.EnumMember(Value = @"LocalDevelopment")] - LocalDevelopment = 2, - - } - - /// - /// Service Health - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ServiceHealthResponse - { - /// - /// MobilePay connected - /// - [Newtonsoft.Json.JsonProperty("mobilePay", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public bool MobilePay { get; set; } - - /// - /// Database connected - /// - [Newtonsoft.Json.JsonProperty("database", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public bool Database { get; set; } - - } - - /// - /// A user on the leaderboard - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class LeaderboardEntry - { - /// - /// Account Id - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int Id { get; set; } - - /// - /// Account name - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - /// - /// Leaderboard rank - /// - [Newtonsoft.Json.JsonProperty("rank", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int Rank { get; set; } - - /// - /// Account score - /// - [Newtonsoft.Json.JsonProperty("score", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int Score { get; set; } - - } - - /// - /// Preset for filtering Leaderboard based on date range - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public enum LeaderboardPreset - { - - [System.Runtime.Serialization.EnumMember(Value = @"Month")] - Month = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"Semester")] - Semester = 1, - - [System.Runtime.Serialization.EnumMember(Value = @"Total")] - Total = 2, - - } - - /// - /// Represents a menu item that can be redeemed with a ticket - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class MenuItemResponse - { - /// - /// Id of menu item - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Name of menu item - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Whether or not this menu item is active - /// - [Newtonsoft.Json.JsonProperty("active", Required = Newtonsoft.Json.Required.Always)] - public bool Active { get; set; } - - } - - /// - /// Initiate a new menuitem add request. - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class AddMenuItemRequest - { - /// - /// Gets or sets the name of the product. - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - } - - /// - /// Initiate an update product request. - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UpdateMenuItemRequest - { - /// - /// Gets or sets the updated name of the product. - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Gets or sets the updated active status of the product. - /// - [Newtonsoft.Json.JsonProperty("active", Required = Newtonsoft.Json.Required.Always)] - public bool Active { get; set; } - - } - - /// - /// MobilePay webhook invocation request - ///
Code documentation based on MobilePay Developer: Webhooks - ///
- [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class MobilePayWebhook - { - /// - /// Internal MobilePay Id for Webhook invocation - /// - [Newtonsoft.Json.JsonProperty("notificationId", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string NotificationId { get; set; } - - /// - /// Type of event - ///
- ///
- ///
payment.reserved - ///
Published when payment has been approved by MobilePay user and is ready to be captured - ///
- ///
- ///
payment.cancelled_by_user - ///
Published when payment has been cancelled by user inside MobilePay app - ///
- ///
- ///
payment.expired - ///
Published when either initiated payment didn't have any user interactions for 5-10 minutes or payment was reserved, but 7 days have passed and the reservation has expired. - ///
- ///
- [Newtonsoft.Json.JsonProperty("eventType", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string EventType { get; set; } - - /// - /// Date time of event dispatch - /// - [Newtonsoft.Json.JsonProperty("eventDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset EventDate { get; set; } - - /// - /// Event data, e.g. payment id - /// - [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public EventData Data { get; set; } - - } - - /// - /// Event Data - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class EventData - { - /// - /// MobilePay payment id - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Id { get; set; } - - /// - /// Internal MobilePay representation of a type. - /// - [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Type { get; set; } - - } - - /// - /// Represents a purchasable product - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ProductResponse - { - /// - /// Id of product - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Product price - /// - [Newtonsoft.Json.JsonProperty("price", Required = Newtonsoft.Json.Required.Always)] - public int Price { get; set; } - - /// - /// Number of tickets in product - /// - [Newtonsoft.Json.JsonProperty("numberOfTickets", Required = Newtonsoft.Json.Required.Always)] - public int NumberOfTickets { get; set; } - - /// - /// Name of product - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Description of products - /// - [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Description { get; set; } - - /// - /// Eligible due to a user perk privilege - /// - [Newtonsoft.Json.JsonProperty("isPerk", Required = Newtonsoft.Json.Required.Always)] - public bool IsPerk { get; set; } - - /// - /// Visibility of products for users - /// - [Newtonsoft.Json.JsonProperty("visible", Required = Newtonsoft.Json.Required.Always)] - public bool Visible { get; set; } - - /// - /// Decides the user groups that can access the product. - /// - [Newtonsoft.Json.JsonProperty("allowedUserGroups", Required = Newtonsoft.Json.Required.Always, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection AllowedUserGroups { get; set; } = new System.Collections.ObjectModel.Collection(); - - /// - /// The menu items that this product can be used on. - /// - [Newtonsoft.Json.JsonProperty("eligibleMenuItems", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection EligibleMenuItems { get; set; } - - } - - /// - /// Initiate a new product add request. - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class AddProductRequest - { - /// - /// Gets or sets the price of the product. - /// - [Newtonsoft.Json.JsonProperty("price", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Range(0, 2147483647)] - public int Price { get; set; } - - /// - /// Gets or sets the number of tickets associated with the product. - /// - [Newtonsoft.Json.JsonProperty("numberOfTickets", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Range(0, 2147483647)] - public int NumberOfTickets { get; set; } - - /// - /// Gets or sets the name of the product. - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Gets or sets the description of the product. - /// - [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Description { get; set; } - - /// - /// Gets or sets the visibility of the product. Default is true. - /// - [Newtonsoft.Json.JsonProperty("visible", Required = Newtonsoft.Json.Required.Always)] - public bool Visible { get; set; } = true; - - /// - /// Gets or sets the user groups that can access the product. - /// - [Newtonsoft.Json.JsonProperty("allowedUserGroups", Required = Newtonsoft.Json.Required.Always, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection AllowedUserGroups { get; set; } = new System.Collections.ObjectModel.Collection(); - - /// - /// Gets or sets the menu items that are eligible for the product. - /// - [Newtonsoft.Json.JsonProperty("menuItemIds", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection MenuItemIds { get; set; } = new System.Collections.ObjectModel.Collection(); - - } - - /// - /// Initiate an update product request. - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UpdateProductRequest - { - /// - /// Gets or sets the updated price of the product. - /// - [Newtonsoft.Json.JsonProperty("price", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Range(0, 2147483647)] - public int Price { get; set; } - - /// - /// Gets or sets the updated number of tickets associated with the product. - /// - [Newtonsoft.Json.JsonProperty("numberOfTickets", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Range(0, 2147483647)] - public int NumberOfTickets { get; set; } - - /// - /// Gets or sets the updated name of the product. - /// - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Name { get; set; } - - /// - /// Gets or sets the updated description of the product. - /// - [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Description { get; set; } - - /// - /// Gets or sets the updated visibility of the product. Default is true. - /// - [Newtonsoft.Json.JsonProperty("visible", Required = Newtonsoft.Json.Required.Always)] - public bool Visible { get; set; } = true; - - /// - /// Gets or sets the user groups that can access the product. - /// - [Newtonsoft.Json.JsonProperty("allowedUserGroups", Required = Newtonsoft.Json.Required.Always, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection AllowedUserGroups { get; set; } = new System.Collections.ObjectModel.Collection(); - - /// - /// Gets or sets the eligible menu items for the product. - /// - [Newtonsoft.Json.JsonProperty("menuItemIds", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection MenuItemIds { get; set; } = new System.Collections.ObjectModel.Collection(); - - } - - /// - /// Represents a purchase - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class SimplePurchaseResponse - { - /// - /// Id of purchase - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Date time for purchase in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateCreated", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateCreated { get; set; } - - /// - /// Id of purchased product - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// Name of purchased product - /// - [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ProductName { get; set; } - - /// - /// Number of tickets issued in purchase - /// - [Newtonsoft.Json.JsonProperty("numberOfTickets", Required = Newtonsoft.Json.Required.Always)] - public int NumberOfTickets { get; set; } - - /// - /// Total purchase price in Danish Kroner (kr) - /// - [Newtonsoft.Json.JsonProperty("totalAmount", Required = Newtonsoft.Json.Required.Always)] - public int TotalAmount { get; set; } - - /// - /// Status of the purchase - /// - [Newtonsoft.Json.JsonProperty("purchaseStatus", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PurchaseStatus PurchaseStatus { get; set; } - - } - - /// - /// Status of purchase - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public enum PurchaseStatus - { - - [System.Runtime.Serialization.EnumMember(Value = @"Completed")] - Completed = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"Cancelled")] - Cancelled = 1, - - [System.Runtime.Serialization.EnumMember(Value = @"PendingPayment")] - PendingPayment = 2, - - [System.Runtime.Serialization.EnumMember(Value = @"Refunded")] - Refunded = 3, - - } - - /// - /// Represents a purchase - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class SinglePurchaseResponse - { - /// - /// Id of purchase - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Date time for purchase in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateCreated", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateCreated { get; set; } - - /// - /// Id of purchased product - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// Total purchase price in Danish Kroner (kr) - /// - [Newtonsoft.Json.JsonProperty("totalAmount", Required = Newtonsoft.Json.Required.Always)] - public int TotalAmount { get; set; } - - /// - /// Status of the purchase - /// - [Newtonsoft.Json.JsonProperty("purchaseStatus", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PurchaseStatus PurchaseStatus { get; set; } - - /// - /// Details about the payment. The details object is specific to the Payment Type - /// - [Newtonsoft.Json.JsonProperty("paymentDetails", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public PaymentDetails PaymentDetails { get; set; } = new PaymentDetails(); - - } - - [Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), "discriminator")] - [JsonInheritanceAttribute("MobilePayPaymentDetails", typeof(MobilePayPaymentDetails))] - [JsonInheritanceAttribute("FreePurchasePaymentDetails", typeof(FreePurchasePaymentDetails))] - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class PaymentDetails - { - /// - /// Payment type - /// - [Newtonsoft.Json.JsonProperty("paymentType", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PaymentType PaymentType { get; set; } - - /// - /// Order id of purchase - /// - [Newtonsoft.Json.JsonProperty("orderId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string OrderId { get; set; } - - } - - /// - /// PaymentType represents the type of Payment which is used to fulfill a purchase - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public enum PaymentType - { - - [System.Runtime.Serialization.EnumMember(Value = @"MobilePay")] - MobilePay = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"FreePurchase")] - FreePurchase = 1, - - } - - /// - /// MobilePay Payment details - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class MobilePayPaymentDetails : PaymentDetails - { - /// - /// App deeplink for a MobilePay payment - /// - [Newtonsoft.Json.JsonProperty("mobilePayAppRedirectUri", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string MobilePayAppRedirectUri { get; set; } - - /// - /// MobilePay Id for a payment - /// - [Newtonsoft.Json.JsonProperty("paymentId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string PaymentId { get; set; } - - } - - /// - /// Payment details for a free purchase - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class FreePurchasePaymentDetails : PaymentDetails - { - - } - - /// - /// Response object to a purchase request containing purchase information and reference to payment provider - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class InitiatePurchaseResponse - { - /// - /// Id of the purchase - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Date time for purchase in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateCreated", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateCreated { get; set; } - - /// - /// Id of the product to be purchased - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// Name of the product to be purchased - /// - [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ProductName { get; set; } - - /// - /// The amount of money to be collected by the purchase. - ///
A positive integer representing how much to charge in the smallest currency unit (e.g., 100 ører to charge 1.00 Danish kroner). - ///
- [Newtonsoft.Json.JsonProperty("totalAmount", Required = Newtonsoft.Json.Required.Always)] - public int TotalAmount { get; set; } - - /// - /// Status of the purchase - /// - [Newtonsoft.Json.JsonProperty("purchaseStatus", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PurchaseStatus PurchaseStatus { get; set; } - - /// - /// Details about the payment. The details object is specific to the Payment Type - /// - [Newtonsoft.Json.JsonProperty("paymentDetails", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public PaymentDetails PaymentDetails { get; set; } = new PaymentDetails(); - - } - - /// - /// Initiate a new purchase request - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class InitiatePurchaseRequest - { - /// - /// Id of product to be purchased - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// Payment Type used to fulfill purchase - /// - [Newtonsoft.Json.JsonProperty("paymentType", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PaymentType PaymentType { get; set; } - - } - - /// - /// Representing a ticket for a product - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class TicketResponse - { - /// - /// Ticket Id - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Issuing date time for ticket in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateCreated", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateCreated { get; set; } - - /// - /// Used date time for ticket in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateUsed", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset? DateUsed { get; set; } - - /// - /// The Id of product a ticket is for - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// Name of product a ticket is for - /// - [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ProductName { get; set; } - - /// - /// The name of the menu item that this ticket was used on - /// - [Newtonsoft.Json.JsonProperty("usedOnMenuItemName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string UsedOnMenuItemName { get; set; } - - } - - /// - /// Representing a used ticket for a product - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UsedTicketResponse - { - /// - /// Ticket Id - /// - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - public int Id { get; set; } - - /// - /// Issuing date time for ticket in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateCreated", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateCreated { get; set; } - - /// - /// Used date time for ticket in Utc format - /// - [Newtonsoft.Json.JsonProperty("dateUsed", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset DateUsed { get; set; } - - /// - /// Name of product a ticket is for - /// - [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ProductName { get; set; } - - /// - /// Name of the menu item that this ticket was used on - /// - [Newtonsoft.Json.JsonProperty("menuItemName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string MenuItemName { get; set; } - - } - - /// - /// Represents a request to use a ticket. - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class UseTicketRequest - { - /// - /// The id of the product the ticket is for. - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// The id of the menu item to use the ticket on. - /// - [Newtonsoft.Json.JsonProperty("menuItemId", Required = Newtonsoft.Json.Required.Always)] - public int MenuItemId { get; set; } - - } - - /// - /// Response object for creating voucher codes - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class IssueVoucherResponse - { - /// - /// Voucher code to be redeemed in the app - /// - [Newtonsoft.Json.JsonProperty("voucherCode", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string VoucherCode { get; set; } - - /// - /// The id of the product the voucher code is for - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// The name of the product the voucher code is for - /// - [Newtonsoft.Json.JsonProperty("productName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string ProductName { get; set; } - - /// - /// The date the voucher code was created - /// - [Newtonsoft.Json.JsonProperty("issuedAt", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTimeOffset IssuedAt { get; set; } - - } - - /// - /// Request object for creating voucher codes - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class IssueVoucherRequest - { - /// - /// Id of the product to create voucher codes for - /// - [Newtonsoft.Json.JsonProperty("productId", Required = Newtonsoft.Json.Required.Always)] - public int ProductId { get; set; } - - /// - /// The amount of vouchers to be issued - /// - [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.Always)] - public int Amount { get; set; } - - /// - /// A 3 character long user defined prefix for every voucher code - /// - [Newtonsoft.Json.JsonProperty("voucherPrefix", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - [System.ComponentModel.DataAnnotations.StringLength(3, MinimumLength = 3)] - public string VoucherPrefix { get; set; } - - /// - /// Description of the purpose for the creation of vouchers - /// - [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Description { get; set; } - - /// - /// The requester of the voucher codes - /// - [Newtonsoft.Json.JsonProperty("requester", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Requester { get; set; } - - } - - /// - /// Represents a request to update user groups in bulk - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class WebhookUpdateUserGroupRequest - { - /// - /// List of accounts and their new user groups - /// - [Newtonsoft.Json.JsonProperty("privilegedUsers", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection PrivilegedUsers { get; set; } = new System.Collections.ObjectModel.Collection(); - - } - - /// - /// Represents an account user group update - /// - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class AccountUserGroup - { - /// - /// The account id - /// - [Newtonsoft.Json.JsonProperty("accountId", Required = Newtonsoft.Json.Required.Always)] - public int AccountId { get; set; } - - /// - /// The user group - /// - [Newtonsoft.Json.JsonProperty("userGroup", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public UserGroup UserGroup { get; set; } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple = true)] - internal class JsonInheritanceAttribute : System.Attribute - { - public JsonInheritanceAttribute(string key, System.Type type) - { - Key = key; - Type = type; - } - - public string Key { get; } - - public System.Type Type { get; } - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public class JsonInheritanceConverter : Newtonsoft.Json.JsonConverter - { - internal static readonly string DefaultDiscriminatorName = "discriminator"; - - private readonly string _discriminatorName; - - [System.ThreadStatic] - private static bool _isReading; - - [System.ThreadStatic] - private static bool _isWriting; - - public JsonInheritanceConverter() - { - _discriminatorName = DefaultDiscriminatorName; - } - - public JsonInheritanceConverter(string discriminatorName) - { - _discriminatorName = discriminatorName; - } - - public string DiscriminatorName { get { return _discriminatorName; } } - - public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) - { - try - { - _isWriting = true; - - var jObject = Newtonsoft.Json.Linq.JObject.FromObject(value, serializer); - jObject.AddFirst(new Newtonsoft.Json.Linq.JProperty(_discriminatorName, GetSubtypeDiscriminator(value.GetType()))); - writer.WriteToken(jObject.CreateReader()); - } - finally - { - _isWriting = false; - } - } - - public override bool CanWrite - { - get - { - if (_isWriting) - { - _isWriting = false; - return false; - } - return true; - } - } - - public override bool CanRead - { - get - { - if (_isReading) - { - _isReading = false; - return false; - } - return true; - } - } - - public override bool CanConvert(System.Type objectType) - { - return true; - } - - public override object ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) - { - var jObject = serializer.Deserialize(reader); - if (jObject == null) - return null; - - var discriminatorValue = jObject.GetValue(_discriminatorName); - var discriminator = discriminatorValue != null ? Newtonsoft.Json.Linq.Extensions.Value(discriminatorValue) : null; - var subtype = GetObjectSubtype(objectType, discriminator); - - var objectContract = serializer.ContractResolver.ResolveContract(subtype) as Newtonsoft.Json.Serialization.JsonObjectContract; - if (objectContract == null || System.Linq.Enumerable.All(objectContract.Properties, p => p.PropertyName != _discriminatorName)) - { - jObject.Remove(_discriminatorName); - } - - try - { - _isReading = true; - return serializer.Deserialize(jObject.CreateReader(), subtype); - } - finally - { - _isReading = false; - } - } - - private System.Type GetObjectSubtype(System.Type objectType, string discriminator) - { - foreach (var attribute in System.Reflection.CustomAttributeExtensions.GetCustomAttributes(System.Reflection.IntrospectionExtensions.GetTypeInfo(objectType), true)) - { - if (attribute.Key == discriminator) - return attribute.Type; - } - - return objectType; - } - - private string GetSubtypeDiscriminator(System.Type objectType) - { - foreach (var attribute in System.Reflection.CustomAttributeExtensions.GetCustomAttributes(System.Reflection.IntrospectionExtensions.GetTypeInfo(objectType), true)) - { - if (attribute.Type == objectType) - return attribute.Key; - } - - return objectType.Name; - } - } - - - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ApiException : System.Exception - { - public int StatusCode { get; private set; } - - public string Response { get; private set; } - - public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } - - public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) - : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException) - { - StatusCode = statusCode; - Response = response; - Headers = headers; - } - - public override string ToString() - { - return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); - } - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))")] - public partial class ApiException : ApiException - { - public TResult Result { get; private set; } - - public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) - : base(message, statusCode, response, headers, innerException) - { - Result = result; - } - } - -} - -#pragma warning restore 1591 -#pragma warning restore 1573 -#pragma warning restore 472 -#pragma warning restore 114 -#pragma warning restore 108 -#pragma warning restore 3016 -#pragma warning restore 8603 \ No newline at end of file diff --git a/Shifty.Api/Shifty.Api.csproj b/Shifty.Api/Shifty.Api.csproj deleted file mode 100644 index 2bc7eaf..0000000 --- a/Shifty.Api/Shifty.Api.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - netstandard2.1 - enable - enable - 10 - - - - - - - - - - - - - - - - - diff --git a/Shifty.App/Shifty.App.csproj b/Shifty.App/Shifty.App.csproj index 11c3bdd..58df70b 100755 --- a/Shifty.App/Shifty.App.csproj +++ b/Shifty.App/Shifty.App.csproj @@ -33,7 +33,7 @@ <_ContentIncludedByDefault Remove="wwwroot\sample-data\weather.json" /> - + diff --git a/Shifty.GenerateApi/Program.cs b/Shifty.GenerateApi/Program.cs deleted file mode 100644 index 4b1e50e..0000000 --- a/Shifty.GenerateApi/Program.cs +++ /dev/null @@ -1,67 +0,0 @@ -using NSwag; -using NSwag.CodeGeneration.CSharp; -using NSwag.CodeGeneration.OperationNameGenerators; - -namespace Shifty.GenerateAp{ - /// - /// Generate ShiftPlanning Api client from OpenApi specification files in the 'OpenApiSpecs' directory - /// and stores the C# files in 'Shifty\GeneratedApi\' - /// - public static class Program - { - /// - /// Generate ShiftPlanning Api - /// Expected to be run in the project folder - /// - /// OpenApi specification file could not be found - public static async Task Main(string[] args) - { - await GenerateApi(apiName: "AnalogCoreV1"); - await GenerateApi(apiName: "AnalogCoreV2"); - } - - private static async Task GenerateApi(string apiName){ - var openApiSpecDirectory = Directory.GetCurrentDirectory() + "/OpenApiSpecs/"; - var outputDirectory = Directory.GetParent(Directory.GetCurrentDirectory()) + - "/Shifty.Api/Generated/"; - - await GenerateApiHelper( - new CSharpClientGeneratorSettings - { - ClassName = apiName, - CSharpGeneratorSettings = - { - Namespace = $"Shifty.Api.Generated.{apiName}" - }, - UseBaseUrl = false, - OperationNameGenerator = new SingleClientFromPathSegmentsOperationNameGenerator() - }, - openApiSpecDirectory + apiName + ".json", - outputDirectory + $"{apiName}", - outputDirectory + $"{apiName}/" + apiName + ".cs" - ); - } - - private static async Task GenerateApiHelper(CSharpClientGeneratorSettings settings, string inputFile, string outputDirectory, string outputFile) - { - CheckFileExists(inputFile); - - var document = await OpenApiDocument.FromFileAsync(inputFile); - - var generator = new CSharpClientGenerator(document, settings); - var code = generator.GenerateFile(); - - System.IO.Directory.CreateDirectory(outputDirectory); - await File.WriteAllTextAsync(outputFile, code); - } - - private static void CheckFileExists(string inputFile) - { - var file = new FileInfo(inputFile); - if (!file.Exists) - { - throw new FileNotFoundException(inputFile); - } - } - } -} \ No newline at end of file diff --git a/Shifty.GenerateApi/Shifty.GenerateApi.csproj b/Shifty.GenerateApi/Shifty.GenerateApi.csproj deleted file mode 100644 index 7fe5144..0000000 --- a/Shifty.GenerateApi/Shifty.GenerateApi.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - Exe - net8.0 - enable - enable - Shifty.GenerateApi - - - - - - - - - \ No newline at end of file diff --git a/Shifty.GenerateApi/Shifty.GenerateApi.sln b/Shifty.GenerateApi/Shifty.GenerateApi.sln deleted file mode 100644 index 552ae41..0000000 --- a/Shifty.GenerateApi/Shifty.GenerateApi.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.002.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shifty.GenerateApi", "Shifty.GenerateApi.csproj", "{18DB7F30-D5ED-4D0D-9AD8-72DDA96A8C76}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {18DB7F30-D5ED-4D0D-9AD8-72DDA96A8C76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {18DB7F30-D5ED-4D0D-9AD8-72DDA96A8C76}.Debug|Any CPU.Build.0 = Debug|Any CPU - {18DB7F30-D5ED-4D0D-9AD8-72DDA96A8C76}.Release|Any CPU.ActiveCfg = Release|Any CPU - {18DB7F30-D5ED-4D0D-9AD8-72DDA96A8C76}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B7EDFCBA-40BE-469E-A800-4D1C9260CEA5} - EndGlobalSection -EndGlobal diff --git a/Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV1.json b/Shifty.Generated.ApiClient/OpenApiSpecs/AnalogCoreV1.json similarity index 100% rename from Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV1.json rename to Shifty.Generated.ApiClient/OpenApiSpecs/AnalogCoreV1.json diff --git a/Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV2.json b/Shifty.Generated.ApiClient/OpenApiSpecs/AnalogCoreV2.json similarity index 100% rename from Shifty.GenerateApi/OpenApiSpecs/AnalogCoreV2.json rename to Shifty.Generated.ApiClient/OpenApiSpecs/AnalogCoreV2.json diff --git a/Shifty.Generated.ApiClient/README.md b/Shifty.Generated.ApiClient/README.md new file mode 100644 index 0000000..7b7c6ae --- /dev/null +++ b/Shifty.Generated.ApiClient/README.md @@ -0,0 +1,12 @@ +# Auto generated strongly typed http client for Core Api +This project only contains the configuration required to generate strongly typed http clients that we use to test the Api. The clients are outputted in /obj folder, whenever this project is build. + +This is set up by configuring the OpenApiReference to point to the versioned openApi specs of the Core Api committed in this repository . + +The clients that are out putted are: +- AnalogCoreV1 +- AnalogCoreV2 + +See the following for more info in how to set up, and configure clients +- [Microsoft reference](https://learn.microsoft.com/en-us/aspnet/core/web-api/microsoft.dotnet-openapi?view=aspnetcore-8.0) +- [Blog explaining in detail](https://stevetalkscode.co.uk/openapireference-commands) ([Backup archive.org](https://web.archive.org/web/20240415183726/https://stevetalkscode.co.uk/openapireference-commands)) \ No newline at end of file diff --git a/Shifty.Generated.ApiClient/Shifty.Generated.ApiClient.csproj b/Shifty.Generated.ApiClient/Shifty.Generated.ApiClient.csproj new file mode 100644 index 0000000..0eb2e0e --- /dev/null +++ b/Shifty.Generated.ApiClient/Shifty.Generated.ApiClient.csproj @@ -0,0 +1,30 @@ + + + + netstandard2.1 + enable + enable + 10 + Shifty.Api + + + + + + + + + + + AnalogCoreV1 + Shifty.Api.Generated.AnalogCoreV1 + /UseBaseUrl:false /OperationGenerationMode:SingleClientFromPathSegments + + + AnalogCoreV2 + Shifty.Api.Generated.AnalogCoreV2 + /AdditionalNamespaceUsages:Shifty.Api.Generated.AnalogCoreV1 /UseBaseUrl:false /OperationGenerationMode:SingleClientFromPathSegments + + + + diff --git a/Shifty.sln b/Shifty.sln index 672a450..05ae7c7 100644 --- a/Shifty.sln +++ b/Shifty.sln @@ -3,12 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shifty.Api", "Shifty.Api\Shifty.Api.csproj", "{BEDEC57C-E274-4F0A-B82C-9EBBCD8C67F6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shifty.Generated.ApiClient", "Shifty.Generated.ApiClient\Shifty.Generated.ApiClient.csproj", "{BEDEC57C-E274-4F0A-B82C-9EBBCD8C67F6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shifty.App", "Shifty.App\Shifty.App.csproj", "{A27A55FD-8B36-48DA-9EC5-2FC45E2D89C5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shifty.GenerateApi", "Shifty.GenerateApi\Shifty.GenerateApi.csproj", "{45CCCE83-B163-4DDF-9826-61413C85BF4F}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,9 +24,5 @@ Global {A27A55FD-8B36-48DA-9EC5-2FC45E2D89C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {A27A55FD-8B36-48DA-9EC5-2FC45E2D89C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {A27A55FD-8B36-48DA-9EC5-2FC45E2D89C5}.Release|Any CPU.Build.0 = Release|Any CPU - {45CCCE83-B163-4DDF-9826-61413C85BF4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {45CCCE83-B163-4DDF-9826-61413C85BF4F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {45CCCE83-B163-4DDF-9826-61413C85BF4F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {45CCCE83-B163-4DDF-9826-61413C85BF4F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal