Commit 3716ef27 authored by Jose Hugo Torres's avatar Jose Hugo Torres
Browse files

Implementado subtotal e impuestos.

parent 173f8f39
......@@ -32,7 +32,7 @@ namespace GatewaySCO
/// <summary>
/// Obtener datos de entorno.
/// </summary>
public T getDatos()
public T get()
{
if (_datos == null)
{
......@@ -44,7 +44,7 @@ namespace GatewaySCO
/// <summary>
/// Fijar datos de entorno.
/// </summary>
public void setDatos(T datos)
public void set(T datos)
{
_datos = datos;
}
......
......@@ -7,5 +7,5 @@
/// <summary>
/// Dispensa un directorio de comandos inicializados.
/// </summary>
static abstract CreaDirectorioCmds Dispensa(Config config);
static abstract CreaDirectorioCmds Dispensa();
}
\ No newline at end of file
using System.Text.RegularExpressions;
using System.Xml;
namespace GatewaySCO
{
/// <summary>
/// Clase Utilistarios para operaciones sobre mensajes.
/// Clase Utilitarios para operaciones sobre mensajes.
/// </summary>
public class Util
{
......@@ -53,7 +54,7 @@ namespace GatewaySCO
/// <summary>
/// Lee valor long de entidad XML indicada por xpath..
/// </summary>
public static long LeeLongEnNodo(XmlNode nodo,string xpath)
public static long LeeLongEnNodo(XmlNode nodo, string xpath)
{
long valor = 0;
XmlNode? xnodo = nodo.SelectSingleNode(xpath);
......@@ -108,5 +109,32 @@ namespace GatewaySCO
throw new Exception($"Nodo '{xpath}' con contenido nulo.");
return valor;
}
/// <summary>
/// Remplaza contenido entre caracteres <| y |> por valores pasados como parémtros, en orden.
/// Si el número de conenidos y de parámetros no corresponde, lanza excepción.
/// Ejemplo: "Texto con <|o1|> para remplazar, junto con <|o2|>", si o1=123 y o2=true
/// da como resultado: "Texto con 123 para remplazar, junto con true"
/// </summary>
public static string ReplaceValuesInString(string inputString, params object[] values)
{
string pattern = @"<\|([^|]+)\|>";
Regex regex = new Regex(pattern);
MatchEvaluator evaluator = (match) =>
{
string variableName = match.Groups[1].Value;
int index = int.Parse(variableName.Substring(1));
if (index >= 0 && index < values.Length)
{
return Convert.ToString(values[index])
?? throw new ArgumentException($"ReplaceValuesInString: values {values}, index {index}");
}
return match.Value;
};
string result = regex.Replace(inputString, evaluator);
return result;
}
}
}
\ No newline at end of file
# Notas cambios al programa
## 2 Agosto 2023
- Url base de Gk Smart POS se mueve al entorno.
- Se crea clase ConfigGk.
## 4 agosto
- Manejar errores servicios web, ejemplo:
{"errorCode":{"errorCode":"GKR-POS-000001","message":"Invalid session","messageKey":"com.gk_software.pos.utils.error.ErrorCodeMessages.MSG_INVALID_SESSION","arguments":[]},"timestamp":"2023-08-04T07:16:57.066","additionalContextInfoMap":{}}
- El manejo de headers, la cookie no es obligatoria, para pasar la sessión este es obligatorio: request.AddHeader("_pos_session_", sessionId);
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace gatewayGK.POSGk
namespace gatewayGK.POSGk
{
using System.Text.Json.Serialization;
......
......@@ -5,45 +5,37 @@ namespace SCOGateway.POSGk
{
public class AuthenticateResp
{
[JsonPropertyName("primaryEntry")]
public PrimaryEntry primaryEntry { get; set; }
[JsonPropertyName("posSessionId")]
public PosSessionId posSessionId { get; set; }
[JsonPropertyName("primaryEntry")] public PrimaryEntry primaryEntry { get; set; }
[JsonPropertyName("posSessionId")] public PosSessionId posSessionId { get; set; }
}
public class PosSessionId
{
[JsonPropertyName("id")]
public string id { get; set; }
[JsonPropertyName("id")] public string id { get; set; }
}
public class PrimaryEntry
{
[JsonPropertyName("transaction")]
public Transaction transaction { get; set; }
[JsonPropertyName("transaction")] public Transaction transaction { get; set; }
}
public class Transaction
{
[JsonPropertyName("key")]
public Key key { get; set; }
[JsonPropertyName("operatorID")]
public string operatorID { get; set; }
[JsonPropertyName("posSessionId")]
public Id posSessionId { get; set; }
[JsonPropertyName("key")] public Key key { get; set; }
[JsonPropertyName("operatorID")] public string operatorID { get; set; }
[JsonPropertyName("posSessionId")] public Id posSessionId { get; set; }
[JsonPropertyName("success")] public bool success { get; set; }
}
public class Id
{
[JsonPropertyName("id")]
public string id { get; set; }
public string id { get; set; }
}
public class Key
{
[JsonPropertyName("transactionID")]
public string transactionID { get; set; }
[JsonPropertyName("businessUnitGroupID")]
public string businessUnitGroupID { get; set; }
[JsonPropertyName("transactionID")] public string transactionID { get; set; }
[JsonPropertyName("businessUnitGroupID")] public string businessUnitGroupID { get; set; }
}
}
\ No newline at end of file
......@@ -17,11 +17,42 @@ public class EntornoGK
public string TransactionID { get; set; } = "";
public string SeccionId { get; set; } = "";
public string SessionId { get; set; } = "";
public string posSessionId { get; set; } = "";
/// <summary>
/// Gk - BusinessUnitGroupID requerido para request a Smart Pos en transacciones
/// asociadas a venta.
/// </summary>
public string BusinessUnitGroupID { get; set; } = "";
/// <summary>
/// GK Language.
/// </summary>
public string Language { get; set; } = "en";
private string? _urlBase;
private ConfigGk? _configGk;
/// <summary>
/// Parámetros de configuración Gk Smart POS.
/// Inicializados desde el archivo de configuración.
/// </summary>
public ConfigGk ConfigGk
{
get => _configGk ?? throw new ApplicationException("ConfigGk no definido.");
set
{
_configGk = value;
_urlBase = $"https://{value.IpGkSmartPOS}:{value.PortGkSmartPOS}/smartpos-service/tenants/{value.TenantId}/services";
}
}
/// <summary>
/// Url base de servicios Gk Smart POS.
/// </summary>
public string UrlBase
{
get => _urlBase ?? throw new ApplicationException("UrlBase no inicializada.");
private set { }
}
}
\ No newline at end of file
using System.Text.Json.Serialization;
namespace SCOGateway.POSGk
{
/// <summary>
/// Registro para Logout a cliente Smart POS GK.
/// </summary>
public record LogoutReq
{
[JsonPropertyName("posSessionId")]
public PosSessionId PosSessionId { get; set; }
[JsonPropertyName("posGroupOperatorActive")]
public bool PosGroupOperatorActive { get; set; } = true;
}
}
\ No newline at end of file
using System.Text.Json.Serialization;
namespace SCOGateway.POSGk
{
/// <summary>
/// Registro para Logout a cliente Smart POS GK.
/// </summary>
public record LogoutResp
{
[JsonPropertyName("primaryEntry")] public PrimaryEntry primaryEntry { get; set; }
public bool success { get; set; }
}
}
\ No newline at end of file
namespace gatewayGK.POSGk
{
public record operationConfiguration
{
public bool forceQuantityInput { get; init; } = false;
public int pricePositionLimit { get; init; } = 10000; // TODO - controlar este valor, como sacarlo del Smart POS.
public bool pricePositionZeroAllowed { get; init; } = true;
public int priceTransactionLimit { get; init; } = -1;
public int priceDifferencePercentPositionLimit { get; init; } = 100;
public int priceDifferenceAbsolutePositionLimit { get; init; } = 999999;
public string priceDifferenceLimitExceedAction { get; init; } = "Warn";
public string priceNegDifferenceLimitExceedAction { get; init; } = "Warn";
public string closeCurrent { get; init; } = "Required";
public string closePrevious { get; init; } = "Required";
public bool filterResult { get; init; } = true;
public bool allowedWithWeight { get; init; } = true;
public bool allowedWithLength { get; init; } = true;
public bool allowedWithArea { get; init; } = true;
public bool allowedWithVolume { get; init; } = true;
public bool allowedWithMeasure { get; init; } = true;
public int maximumQuantity { get; init; } = 999999;
public int minimumQuantity { get; init; } = 1;
public string quantityInputOrder { get; init; } = "BeforeOrAfter";
public string priceInputOrder { get; init; } = "BeforeOrAfter";
public string quantityLimitExceedAction { get; init; } = "Warn";
public string amountLimitExceedAction { get; init; } = "Warn";
public int weightUnitFactor { get; init; } = 0;
public int measureUnitFactor { get; init; } = 0;
public string priceDeviationType { get; init; } = "All";
public string priceNegDeviationType { get; init; } = "All";
public string xXCustom08 { get; init; } = "string";
public string xXCustom10 { get; init; } = "string";
public string xXCustom09 { get; init; } = "string";
public string xXCustom07 { get; init; } = "string";
public string xXCustom05 { get; init; } = "string";
public string xXCustom06 { get; init; } = "string";
public string xXCustom11 { get; init; } = "string";
public string xXCustom12 { get; init; } = "string";
public string xXCustom13 { get; init; } = "string";
public string xXCustom14 { get; init; } = "string";
public string xXCustom15 { get; init; } = "string";
public string xXCustom03 { get; init; } = "string";
public string xXCustom02 { get; init; } = "string";
public string xXCustom04 { get; init; } = "string";
public string xXCustom01 { get; init; } = "string";
}
public record itemEntryConfig
{
public bool forceQuantityInput { get; init; } = true;
public int pricePositionLimit { get; init; } = 0;
public bool pricePositionZeroAllowed { get; init; } = true;
public int priceTransactionLimit { get; init; } = 0;
public int priceDifferencePercentPositionLimit { get; init; } = 0;
public int priceDifferenceAbsolutePositionLimit { get; init; } = 0;
public string priceDifferenceLimitExceedAction { get; init; } = "Warn";
public string priceNegDifferenceLimitExceedAction { get; init; } = "Warn";
public string closeCurrent { get; init; } = "Required";
public string closePrevious { get; init; } = "Required";
public bool filterResult { get; init; } = true;
public bool allowedWithWeight { get; init; } = true;
public bool allowedWithLength { get; init; } = true;
public bool allowedWithArea { get; init; } = true;
public bool allowedWithVolume { get; init; } = true;
public bool allowedWithMeasure { get; init; } = true;
public int maximumQuantity { get; init; } = 0;
public int minimumQuantity { get; init; } = 0;
public string quantityInputOrder { get; init; } = "BeforeOrAfter";
public string priceInputOrder { get; init; } = "BeforeOrAfter";
public string quantityLimitExceedAction { get; init; } = "Warn";
public int weightUnitFactor { get; init; } = 0;
public int measureUnitFactor { get; init; } = 0;
public string priceDeviationType { get; init; } = "All";
public string priceNegDeviationType { get; init; } = "All";
public string xXCustom01 { get; init; } = "string";
public string xXCustom02 { get; init; } = "string";
public string xXCustom03 { get; init; } = "string";
public string xXCustom04 { get; init; } = "string";
public string xXCustom05 { get; init; } = "string";
public string xXCustom06 { get; init; } = "string";
public string xXCustom07 { get; init; } = "string";
public string xXCustom08 { get; init; } = "string";
public string xXCustom09 { get; init; } = "string";
public string xXCustom10 { get; init; } = "string";
public string xXCustom11 { get; init; } = "string";
public string xXCustom12 { get; init; } = "string";
public string xXCustom13 { get; init; } = "string";
public string xXCustom14 { get; init; } = "string";
public string xXCustom15 { get; init; } = "string";
}
public record registerLineItemReq
{
public operationConfiguration operationConfiguration { get; init; } = new operationConfiguration();
public string barcode { get; init; } = "";
public bool salesRestrictionsCheckNeeded { get; init; } = false;
public string priceVariant { get; init; } = "Actual";
public itemEntryConfig itemEntryConfig { get; init; } = new itemEntryConfig();
public string entryMethodCode { get; init; } = "Keyed";
public bool keyedOnline { get; init; } = true;
}
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json;
using RestSharp;
namespace IO.Swagger.Client
{
/// <summary>
/// API client is mainly responsible for making the HTTP call to the API backend.
/// </summary>
public partial class ApiClient
{
private JsonSerializerSettings serializerSettings = new JsonSerializerSettings
{
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
};
/// <summary>
/// Allows for extending request processing for <see cref="ApiClient"/> generated code.
/// </summary>
/// <param name="request">The RestSharp request object</param>
partial void InterceptRequest(IRestRequest request);
/// <summary>
/// Allows for extending response processing for <see cref="ApiClient"/> generated code.
/// </summary>
/// <param name="request">The RestSharp request object</param>
/// <param name="response">The RestSharp response object</param>
partial void InterceptResponse(IRestRequest request, IRestResponse response);
/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" /> class
/// with default configuration.
/// </summary>
public ApiClient()
{
Configuration = IO.Swagger.Client.Configuration.Default;
RestClient = new RestClient("https://localhost:8080/pos-service/tenants/<tenant-id>/services/_**");
}
/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" /> class
/// with default base path (https://localhost:8080/pos-service/tenants/<tenant-id>/services/_**).
/// </summary>
/// <param name="config">An instance of Configuration.</param>
public ApiClient(Configuration config)
{
Configuration = config ?? IO.Swagger.Client.Configuration.Default;
RestClient = new RestClient(Configuration.BasePath);
}
/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" /> class
/// with default configuration.
/// </summary>
/// <param name="basePath">The base path.</param>
public ApiClient(String basePath = "https://localhost:8080/pos-service/tenants/<tenant-id>/services/_**")
{
if (String.IsNullOrEmpty(basePath))
throw new ArgumentException("basePath cannot be empty");
RestClient = new RestClient(basePath);
Configuration = Client.Configuration.Default;
}
/// <summary>
/// Gets or sets the default API client for making HTTP calls.
/// </summary>
/// <value>The default API client.</value>
[Obsolete("ApiClient.Default is deprecated, please use 'Configuration.Default.ApiClient' instead.")]
public static ApiClient Default;
/// <summary>
/// Gets or sets an instance of the IReadableConfiguration.
/// </summary>
/// <value>An instance of the IReadableConfiguration.</value>
/// <remarks>
/// <see cref="IReadableConfiguration"/> helps us to avoid modifying possibly global
/// configuration values from within a given client. It does not guarantee thread-safety
/// of the <see cref="Configuration"/> instance in any way.
/// </remarks>
public IReadableConfiguration Configuration { get; set; }
/// <summary>
/// Gets or sets the RestClient.
/// </summary>
/// <value>An instance of the RestClient</value>
public RestClient RestClient { get; set; }
// Creates and sets up a RestRequest prior to a call.
private RestRequest PrepareRequest(
String path, RestSharp.Method method, List<KeyValuePair<String, String>> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{
var request = new RestRequest(path, method);
// add path parameter, if any
foreach(var param in pathParams)
request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment);
// add header parameter, if any
foreach(var param in headerParams)
request.AddHeader(param.Key, param.Value);
// add query parameter, if any
foreach(var param in queryParams)
request.AddQueryParameter(param.Key, param.Value);
// add form parameter, if any
foreach(var param in formParams)
request.AddParameter(param.Key, param.Value);
// add file parameter, if any
foreach(var param in fileParams)
{
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
}
if (postBody != null) // http body (model or byte[]) parameter
{
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
}
return request;
}
/// <summary>
/// Makes the HTTP request (Sync).
/// </summary>
/// <param name="path">URL path.</param>
/// <param name="method">HTTP method.</param>
/// <param name="queryParams">Query parameters.</param>
/// <param name="postBody">HTTP body (POST request).</param>
/// <param name="headerParams">Header parameters.</param>
/// <param name="formParams">Form parameters.</param>
/// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content Type of the request</param>
/// <returns>Object</returns>
public Object CallApi(
String path, RestSharp.Method method, List<KeyValuePair<String, String>> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{
var request = PrepareRequest(
path, method, queryParams, postBody, headerParams, formParams, fileParams,
pathParams, contentType);
// set timeout
RestClient.Timeout = Configuration.Timeout;
// set user agent
RestClient.UserAgent = Configuration.UserAgent;
InterceptRequest(request);
var response = RestClient.Execute(request);
InterceptResponse(request, response);
return (Object) response;
}
/// <summary>
/// Makes the asynchronous HTTP request.
/// </summary>
/// <param name="path">URL path.</param>
/// <param name="method">HTTP method.</param>
/// <param name="queryParams">Query parameters.</param>
/// <param name="postBody">HTTP body (POST request).</param>
/// <param name="headerParams">Header parameters.</param>
/// <param name="formParams">Form parameters.</param>
/// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content type.</param>
/// <returns>The Task instance.</returns>
public async System.Threading.Tasks.Task<Object> CallApiAsync(
String path, RestSharp.Method method, List<KeyValuePair<String, String>> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{
var request = PrepareRequest(
path, method, queryParams, postBody, headerParams, formParams, fileParams,
pathParams, contentType);
InterceptRequest(request);
var response = await RestClient.ExecuteTaskAsync(request);
InterceptResponse(request, response);
return (Object)response;
}
/// <summary>
/// Escape string (url-encoded).
/// </summary>
/// <param name="str">String to be escaped.</param>
/// <returns>Escaped string.</returns>
public string EscapeString(string str)
{
return UrlEncode(str);
}
/// <summary>
/// Create FileParameter based on Stream.
/// </summary>
/// <param name="name">Parameter name.</param>
/// <param name="stream">Input stream.</param>
/// <returns>FileParameter.</returns>
public FileParameter ParameterToFile(string name, Stream stream)
{
if (stream is FileStream)
return FileParameter.Create(name, ReadAsBytes(stream), Path.GetFileName(((FileStream)stream).Name));
else
return FileParameter.Create(name, ReadAsBytes(stream), "no_file_name_provided");
}
/// <summary>
/// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime.
/// If parameter is a list, join the list with ",".
/// Otherwise just return the string.
/// </summary>
/// <param name="obj">The parameter (header, path, query, form).</param>
/// <returns>Formatted string.</returns>
public string ParameterToString(object obj)
{
if (obj is DateTime)
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return ((DateTime)obj).ToString (Configuration.DateTimeFormat);
else if (obj is DateTimeOffset)
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return ((DateTimeOffset)obj).ToString (Configuration.DateTimeFormat);
else if (obj is IList)
{
var flattenedString = new StringBuilder();
foreach (var param in (IList)obj)
{
if (flattenedString.Length > 0)
flattenedString.Append(",");
flattenedString.Append(param);
}
return flattenedString.ToString();
}
else
return Convert.ToString (obj);
}
/// <summary>
/// Deserialize the JSON string into a proper object.
/// </summary>
/// <param name="response">The HTTP response.</param>
/// <param name="type">Object type.</param>
/// <returns>Object representation of the JSON string.</returns>
public object Deserialize(IRestResponse response, Type type)
{
IList<Parameter> headers = response.Headers;
if (type == typeof(byte[])) // return byte array
{
return response.RawBytes;
}
// TODO: ? if (type.IsAssignableFrom(typeof(Stream)))
if (type == typeof(Stream))
{
if (headers != null)
{
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
? Path.GetTempPath()
: Configuration.TempFolderPath;
var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$");
foreach (var header in headers)
{
var match = regex.Match(header.ToString());
if (match.Success)
{
string fileName = filePath + SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", ""));
File.WriteAllBytes(fileName, response.RawBytes);
return new FileStream(fileName, FileMode.Open);
}
}
}
var stream = new MemoryStream(response.RawBytes);
return stream;
}
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
{
return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind);
}
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
{
return ConvertType(response.Content, type);
}
// at this point, it must be a model (json)
try
{
return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
}
catch (Exception e)
{
throw new ApiException(500, e.Message);
}
}
/// <summary>
/// Serialize an input (model) into JSON string
/// </summary>
/// <param name="obj">Object.</param>
/// <returns>JSON string.</returns>
public String Serialize(object obj)
{
try
{
return obj != null ? JsonConvert.SerializeObject(obj) : null;
}
catch (Exception e)
{
throw new ApiException(500, e.Message);
}
}
/// <summary>
///Check if the given MIME is a JSON MIME.
///JSON MIME examples:
/// application/json
/// application/json; charset=UTF8
/// APPLICATION/JSON
/// application/vnd.company+json
/// </summary>
/// <param name="mime">MIME</param>
/// <returns>Returns True if MIME type is json.</returns>
public bool IsJsonMime(String mime)
{
var jsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
return mime != null && (jsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"));
}
/// <summary>
/// Select the Content-Type header's value from the given content-type array:
/// if JSON type exists in the given array, use it;
/// otherwise use the first one defined in 'consumes'
/// </summary>
/// <param name="contentTypes">The Content-Type array to select from.</param>
/// <returns>The Content-Type header to use.</returns>
public String SelectHeaderContentType(String[] contentTypes)
{
if (contentTypes.Length == 0)
return "application/json";
foreach (var contentType in contentTypes)
{
if (IsJsonMime(contentType.ToLower()))
return contentType;
}
return contentTypes[0]; // use the first content type specified in 'consumes'
}
/// <summary>
/// Select the Accept header's value from the given accepts array:
/// if JSON exists in the given array, use it;
/// otherwise use all of them (joining into a string)
/// </summary>
/// <param name="accepts">The accepts array to select from.</param>
/// <returns>The Accept header to use.</returns>
public String SelectHeaderAccept(String[] accepts)
{
if (accepts.Length == 0)
return null;
if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase))
return "application/json";
return String.Join(",", accepts);
}
/// <summary>
/// Encode string in base64 format.
/// </summary>
/// <param name="text">String to be encoded.</param>
/// <returns>Encoded string.</returns>
public static string Base64Encode(string text)
{
return System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text));
}
/// <summary>
/// Dynamically cast the object into target type.
/// </summary>
/// <param name="fromObject">Object to be casted</param>
/// <param name="toObject">Target type</param>
/// <returns>Casted object</returns>
public static dynamic ConvertType(dynamic fromObject, Type toObject)
{
return Convert.ChangeType(fromObject, toObject);
}
/// <summary>
/// Convert stream to byte array
/// </summary>
/// <param name="inputStream">Input stream to be converted</param>
/// <returns>Byte array</returns>
public static byte[] ReadAsBytes(Stream inputStream)
{
byte[] buf = new byte[16*1024];
using (MemoryStream ms = new MemoryStream())
{
int count;
while ((count = inputStream.Read(buf, 0, buf.Length)) > 0)
{
ms.Write(buf, 0, count);
}
return ms.ToArray();
}
}
/// <summary>
/// URL encode a string
/// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50
/// </summary>
/// <param name="input">String to be URL encoded</param>
/// <returns>Byte array</returns>
public static string UrlEncode(string input)
{
const int maxLength = 32766;
if (input == null)
{
throw new ArgumentNullException("input");
}
if (input.Length <= maxLength)
{
return Uri.EscapeDataString(input);
}
StringBuilder sb = new StringBuilder(input.Length * 2);
int index = 0;
while (index < input.Length)
{
int length = Math.Min(input.Length - index, maxLength);
string subString = input.Substring(index, length);
sb.Append(Uri.EscapeDataString(subString));
index += subString.Length;
}
return sb.ToString();
}
/// <summary>
/// Sanitize filename by removing the path
/// </summary>
/// <param name="filename">Filename</param>
/// <returns>Filename</returns>
public static string SanitizeFilename(string filename)
{
Match match = Regex.Match(filename, @".*[/\\](.*)$");
if (match.Success)
{
return match.Groups[1].Value;
}
else
{
return filename;
}
}
/// <summary>
/// Convert params to key/value pairs.
/// Use collectionFormat to properly format lists and collections.
/// </summary>
/// <param name="name">Key name.</param>
/// <param name="value">Value object.</param>
/// <returns>A list of KeyValuePairs</returns>
public IEnumerable<KeyValuePair<string, string>> ParameterToKeyValuePairs(string collectionFormat, string name, object value)
{
var parameters = new List<KeyValuePair<string, string>>();
if (IsCollection(value) && collectionFormat == "multi")
{
var valueCollection = value as IEnumerable;
parameters.AddRange(from object item in valueCollection select new KeyValuePair<string, string>(name, ParameterToString(item)));
}
else
{
parameters.Add(new KeyValuePair<string, string>(name, ParameterToString(value)));
}
return parameters;
}
/// <summary>
/// Check if generic object is a collection.
/// </summary>
/// <param name="value"></param>
/// <returns>True if object is a collection type</returns>
private static bool IsCollection(object value)
{
return value is IList || value is ICollection;
}
}
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
namespace IO.Swagger.Client
{
/// <summary>
/// API Exception
/// </summary>
public class ApiException : Exception
{
/// <summary>
/// Gets or sets the error code (HTTP status code)
/// </summary>
/// <value>The error code (HTTP status code).</value>
public int ErrorCode { get; set; }
/// <summary>
/// Gets or sets the error content (body json object)
/// </summary>
/// <value>The error content (Http response body).</value>
public dynamic ErrorContent { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
public ApiException() {}
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
/// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param>
public ApiException(int errorCode, string message) : base(message)
{
this.ErrorCode = errorCode;
}
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
/// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param>
/// <param name="errorContent">Error content.</param>
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message)
{
this.ErrorCode = errorCode;
this.ErrorContent = errorContent;
}
}
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.Collections.Generic;
namespace IO.Swagger.Client
{
/// <summary>
/// API Response
/// </summary>
public class ApiResponse<T>
{
/// <summary>
/// Gets or sets the status code (HTTP status code)
/// </summary>
/// <value>The status code.</value>
public int StatusCode { get; private set; }
/// <summary>
/// Gets or sets the HTTP headers
/// </summary>
/// <value>HTTP headers</value>
public IDictionary<string, string> Headers { get; private set; }
/// <summary>
/// Gets or sets the data (parsed HTTP body)
/// </summary>
/// <value>The data.</value>
public T Data { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="ApiResponse&lt;T&gt;" /> class.
/// </summary>
/// <param name="statusCode">HTTP status code.</param>
/// <param name="headers">HTTP headers.</param>
/// <param name="data">Data (parsed HTTP body)</param>
public ApiResponse(int statusCode, IDictionary<string, string> headers, T data)
{
this.StatusCode= statusCode;
this.Headers = headers;
this.Data = data;
}
}
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.Reflection;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace IO.Swagger.Client
{
/// <summary>
/// Represents a set of configuration settings
/// </summary>
public class Configuration : IReadableConfiguration
{
#region Constants
/// <summary>
/// Version of the package.
/// </summary>
/// <value>Version of the package.</value>
public const string Version = "1.0.0";
/// <summary>
/// Identifier for ISO 8601 DateTime Format
/// </summary>
/// <remarks>See https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 for more information.</remarks>
// ReSharper disable once InconsistentNaming
public const string ISO8601_DATETIME_FORMAT = "o";
#endregion Constants
#region Static Members
private static readonly object GlobalConfigSync = new { };
private static Configuration _globalConfiguration;
/// <summary>
/// Default creation of exceptions for a given method name and response object
/// </summary>
public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) =>
{
var status = (int)response.StatusCode;
if (status >= 400)
{
return new ApiException(status,
string.Format("Error calling {0}: {1}", methodName, response.Content),
response.Content);
}
if (status == 0)
{
return new ApiException(status,
string.Format("Error calling {0}: {1}", methodName, response.ErrorMessage), response.ErrorMessage);
}
return null;
};
/// <summary>
/// Gets or sets the default Configuration.
/// </summary>
/// <value>Configuration.</value>
public static Configuration Default
{
get { return _globalConfiguration; }
set
{
lock (GlobalConfigSync)
{
_globalConfiguration = value;
}
}
}
#endregion Static Members
#region Private Members
/// <summary>
/// Gets or sets the API key based on the authentication name.
/// </summary>
/// <value>The API key.</value>
private IDictionary<string, string> _apiKey = null;
/// <summary>
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
/// </summary>
/// <value>The prefix of the API key.</value>
private IDictionary<string, string> _apiKeyPrefix = null;
private string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
private string _tempFolderPath = Path.GetTempPath();
#endregion Private Members
#region Constructors
static Configuration()
{
_globalConfiguration = new GlobalConfiguration();
}
/// <summary>
/// Initializes a new instance of the <see cref="Configuration" /> class
/// </summary>
public Configuration()
{
UserAgent = "Swagger-Codegen/1.0.0/csharp";
BasePath = "https://localhost:8080/pos-service/tenants/<tenant-id>/services/_**";
DefaultHeader = new ConcurrentDictionary<string, string>();
ApiKey = new ConcurrentDictionary<string, string>();
ApiKeyPrefix = new ConcurrentDictionary<string, string>();
// Setting Timeout has side effects (forces ApiClient creation).
Timeout = 100000;
}
/// <summary>
/// Initializes a new instance of the <see cref="Configuration" /> class
/// </summary>
public Configuration(
IDictionary<string, string> defaultHeader,
IDictionary<string, string> apiKey,
IDictionary<string, string> apiKeyPrefix,
string basePath = "https://localhost:8080/pos-service/tenants/<tenant-id>/services/_**") : this()
{
if (string.IsNullOrWhiteSpace(basePath))
throw new ArgumentException("The provided basePath is invalid.", "basePath");
if (defaultHeader == null)
throw new ArgumentNullException("defaultHeader");
if (apiKey == null)
throw new ArgumentNullException("apiKey");
if (apiKeyPrefix == null)
throw new ArgumentNullException("apiKeyPrefix");
BasePath = basePath;
foreach (var keyValuePair in defaultHeader)
{
DefaultHeader.Add(keyValuePair);
}
foreach (var keyValuePair in apiKey)
{
ApiKey.Add(keyValuePair);
}
foreach (var keyValuePair in apiKeyPrefix)
{
ApiKeyPrefix.Add(keyValuePair);
}
}
/// <summary>
/// Initializes a new instance of the <see cref="Configuration" /> class with different settings
/// </summary>
/// <param name="apiClient">Api client</param>
/// <param name="defaultHeader">Dictionary of default HTTP header</param>
/// <param name="username">Username</param>
/// <param name="password">Password</param>
/// <param name="accessToken">accessToken</param>
/// <param name="apiKey">Dictionary of API key</param>
/// <param name="apiKeyPrefix">Dictionary of API key prefix</param>
/// <param name="tempFolderPath">Temp folder path</param>
/// <param name="dateTimeFormat">DateTime format string</param>
/// <param name="timeout">HTTP connection timeout (in milliseconds)</param>
/// <param name="userAgent">HTTP user agent</param>
[Obsolete("Use explicit object construction and setting of properties.", true)]
public Configuration(
// ReSharper disable UnusedParameter.Local
ApiClient apiClient = null,
IDictionary<string, string> defaultHeader = null,
string username = null,
string password = null,
string accessToken = null,
IDictionary<string, string> apiKey = null,
IDictionary<string, string> apiKeyPrefix = null,
string tempFolderPath = null,
string dateTimeFormat = null,
int timeout = 100000,
string userAgent = "Swagger-Codegen/1.0.0/csharp"
// ReSharper restore UnusedParameter.Local
)
{
}
/// <summary>
/// Initializes a new instance of the Configuration class.
/// </summary>
/// <param name="apiClient">Api client.</param>
[Obsolete("This constructor caused unexpected sharing of static data. It is no longer supported.", true)]
// ReSharper disable once UnusedParameter.Local
public Configuration(ApiClient apiClient)
{
}
#endregion Constructors
#region Properties
private ApiClient _apiClient = null;
/// <summary>
/// Gets an instance of an ApiClient for this configuration
/// </summary>
public virtual ApiClient ApiClient
{
get
{
if (_apiClient == null) _apiClient = CreateApiClient();
return _apiClient;
}
}
private String _basePath = null;
/// <summary>
/// Gets or sets the base path for API access.
/// </summary>
public virtual string BasePath {
get { return _basePath; }
set {
_basePath = value;
// pass-through to ApiClient if it's set.
if(_apiClient != null) {
_apiClient.RestClient.BaseUrl = new Uri(_basePath);
}
}
}
/// <summary>
/// Gets or sets the default header.
/// </summary>
public virtual IDictionary<string, string> DefaultHeader { get; set; }
/// <summary>
/// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds.
/// </summary>
public virtual int Timeout
{
get { return ApiClient.RestClient.Timeout; }
set { ApiClient.RestClient.Timeout = value; }
}
/// <summary>
/// Gets or sets the HTTP user agent.
/// </summary>
/// <value>Http user agent.</value>
public virtual string UserAgent { get; set; }
/// <summary>
/// Gets or sets the username (HTTP basic authentication).
/// </summary>
/// <value>The username.</value>
public virtual string Username { get; set; }
/// <summary>
/// Gets or sets the password (HTTP basic authentication).
/// </summary>
/// <value>The password.</value>
public virtual string Password { get; set; }
/// <summary>
/// Gets the API key with prefix.
/// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns>
public string GetApiKeyWithPrefix(string apiKeyIdentifier)
{
var apiKeyValue = "";
ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
var apiKeyPrefix = "";
if (ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
return apiKeyPrefix + " " + apiKeyValue;
else
return apiKeyValue;
}
/// <summary>
/// Gets or sets the access token for OAuth2 authentication.
/// </summary>
/// <value>The access token.</value>
public virtual string AccessToken { get; set; }
/// <summary>
/// Gets or sets the temporary folder path to store the files downloaded from the server.
/// </summary>
/// <value>Folder path.</value>
public virtual string TempFolderPath
{
get { return _tempFolderPath; }
set
{
if (string.IsNullOrEmpty(value))
{
// Possible breaking change since swagger-codegen 2.2.1, enforce a valid temporary path on set.
_tempFolderPath = Path.GetTempPath();
return;
}
// create the directory if it does not exist
if (!Directory.Exists(value))
{
Directory.CreateDirectory(value);
}
// check if the path contains directory separator at the end
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
{
_tempFolderPath = value;
}
else
{
_tempFolderPath = value + Path.DirectorySeparatorChar;
}
}
}
/// <summary>
/// Gets or sets the date time format used when serializing in the ApiClient
/// By default, it's set to ISO 8601 - "o", for others see:
/// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx
/// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
/// No validation is done to ensure that the string you're providing is valid
/// </summary>
/// <value>The DateTimeFormat string</value>
public virtual string DateTimeFormat
{
get { return _dateTimeFormat; }
set
{
if (string.IsNullOrEmpty(value))
{
// Never allow a blank or null string, go back to the default
_dateTimeFormat = ISO8601_DATETIME_FORMAT;
return;
}
// Caution, no validation when you choose date time format other than ISO 8601
// Take a look at the above links
_dateTimeFormat = value;
}
}
/// <summary>
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
/// </summary>
/// <value>The prefix of the API key.</value>
public virtual IDictionary<string, string> ApiKeyPrefix
{
get { return _apiKeyPrefix; }
set
{
if (value == null)
{
throw new InvalidOperationException("ApiKeyPrefix collection may not be null.");
}
_apiKeyPrefix = value;
}
}
/// <summary>
/// Gets or sets the API key based on the authentication name.
/// </summary>
/// <value>The API key.</value>
public virtual IDictionary<string, string> ApiKey
{
get { return _apiKey; }
set
{
if (value == null)
{
throw new InvalidOperationException("ApiKey collection may not be null.");
}
_apiKey = value;
}
}
#endregion Properties
#region Methods
/// <summary>
/// Add default header.
/// </summary>
/// <param name="key">Header field name.</param>
/// <param name="value">Header field value.</param>
/// <returns></returns>
public void AddDefaultHeader(string key, string value)
{
DefaultHeader[key] = value;
}
/// <summary>
/// Creates a new <see cref="ApiClient" /> based on this <see cref="Configuration" /> instance.
/// </summary>
/// <returns></returns>
public ApiClient CreateApiClient()
{
return new ApiClient(BasePath) { Configuration = this };
}
/// <summary>
/// Returns a string with essential information for debugging.
/// </summary>
public static String ToDebugReport()
{
String report = "C# SDK (IO.Swagger) Debug Report:\n";
report += " OS: " + System.Environment.OSVersion + "\n";
report += " .NET Framework Version: " + System.Environment.Version + "\n";
report += " Version of the API: 5.21.1-b03\n";
report += " SDK Package Version: 1.0.0\n";
return report;
}
/// <summary>
/// Add Api Key Header.
/// </summary>
/// <param name="key">Api Key name.</param>
/// <param name="value">Api Key value.</param>
/// <returns></returns>
public void AddApiKey(string key, string value)
{
ApiKey[key] = value;
}
/// <summary>
/// Sets the API key prefix.
/// </summary>
/// <param name="key">Api Key name.</param>
/// <param name="value">Api Key value.</param>
public void AddApiKeyPrefix(string key, string value)
{
ApiKeyPrefix[key] = value;
}
#endregion Methods
}
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using RestSharp;
namespace IO.Swagger.Client
{
/// <summary>
/// A delegate to ExceptionFactory method
/// </summary>
/// <param name="methodName">Method name</param>
/// <param name="response">Response</param>
/// <returns>Exceptions</returns>
public delegate Exception ExceptionFactory(string methodName, IRestResponse response);
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
namespace IO.Swagger.Client
{
/// <summary>
/// <see cref="GlobalConfiguration"/> provides a compile-time extension point for globally configuring
/// API Clients.
/// </summary>
/// <remarks>
/// A customized implementation via partial class may reside in another file and may
/// be excluded from automatic generation via a .swagger-codegen-ignore file.
/// </remarks>
public partial class GlobalConfiguration : Configuration
{
}
}
\ No newline at end of file
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using RestSharp;
namespace IO.Swagger.Client
{
/// <summary>
/// Represents configuration aspects required to interact with the API endpoints.
/// </summary>
public interface IApiAccessor
{
/// <summary>
/// Gets or sets the configuration object
/// </summary>
/// <value>An instance of the Configuration</value>
Configuration Configuration {get; set;}
/// <summary>
/// Gets the base path of the API client.
/// </summary>
/// <value>The base path</value>
String GetBasePath();
/// <summary>
/// Provides a factory method hook for the creation of exceptions.
/// </summary>
ExceptionFactory ExceptionFactory { get; set; }
}
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System.Collections.Generic;
namespace IO.Swagger.Client
{
/// <summary>
/// Represents a readable-only configuration contract.
/// </summary>
public interface IReadableConfiguration
{
/// <summary>
/// Gets the access token.
/// </summary>
/// <value>Access token.</value>
string AccessToken { get; }
/// <summary>
/// Gets the API key.
/// </summary>
/// <value>API key.</value>
IDictionary<string, string> ApiKey { get; }
/// <summary>
/// Gets the API key prefix.
/// </summary>
/// <value>API key prefix.</value>
IDictionary<string, string> ApiKeyPrefix { get; }
/// <summary>
/// Gets the base path.
/// </summary>
/// <value>Base path.</value>
string BasePath { get; }
/// <summary>
/// Gets the date time format.
/// </summary>
/// <value>Date time foramt.</value>
string DateTimeFormat { get; }
/// <summary>
/// Gets the default header.
/// </summary>
/// <value>Default header.</value>
IDictionary<string, string> DefaultHeader { get; }
/// <summary>
/// Gets the temp folder path.
/// </summary>
/// <value>Temp folder path.</value>
string TempFolderPath { get; }
/// <summary>
/// Gets the HTTP connection timeout (in milliseconds)
/// </summary>
/// <value>HTTP connection timeout.</value>
int Timeout { get; }
/// <summary>
/// Gets the user agent.
/// </summary>
/// <value>User agent.</value>
string UserAgent { get; }
/// <summary>
/// Gets the username.
/// </summary>
/// <value>Username.</value>
string Username { get; }
/// <summary>
/// Gets the password.
/// </summary>
/// <value>Password.</value>
string Password { get; }
/// <summary>
/// Gets the API key with prefix.
/// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns>
string GetApiKeyWithPrefix(string apiKeyIdentifier);
}
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using Newtonsoft.Json.Converters;
namespace IO.Swagger.Client
{
/// <summary>
/// Formatter for 'date' swagger formats ss defined by full-date - RFC3339
/// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
/// </summary>
public class SwaggerDateConverter : IsoDateTimeConverter
{
/// <summary>
/// Initializes a new instance of the <see cref="SwaggerDateConverter" /> class.
/// </summary>
public SwaggerDateConverter()
{
// full-date = date-fullyear "-" date-month "-" date-mday
DateTimeFormat = "yyyy-MM-dd";
}
}
}
/*
* GK application - OmniPOS Service API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 5.21.1-b03
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
/// <summary>
/// LayawayLineItem &lt;emph&gt;undocumented&lt;/emph&gt;
/// </summary>
[DataContract]
public partial class ComGkSoftwareGkrApiLayawayDtoLayawayLineItem : IEquatable<ComGkSoftwareGkrApiLayawayDtoLayawayLineItem>, IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="ComGkSoftwareGkrApiLayawayDtoLayawayLineItem" /> class.
/// </summary>
[JsonConstructorAttribute]
protected ComGkSoftwareGkrApiLayawayDtoLayawayLineItem() { }
/// <summary>
/// Initializes a new instance of the <see cref="ComGkSoftwareGkrApiLayawayDtoLayawayLineItem" /> class.
/// </summary>
/// <param name="retailTransactionLineItem">RetailTransactionLineItem (required).</param>
public ComGkSoftwareGkrApiLayawayDtoLayawayLineItem(ComGkSoftwareGkrApiTxpoolDtoRetailTransactionLineItem retailTransactionLineItem = default(ComGkSoftwareGkrApiTxpoolDtoRetailTransactionLineItem))
{
// to ensure "retailTransactionLineItem" is required (not null)
if (retailTransactionLineItem == null)
{
throw new InvalidDataException("retailTransactionLineItem is a required property for ComGkSoftwareGkrApiLayawayDtoLayawayLineItem and cannot be null");
}
else
{
this.RetailTransactionLineItem = retailTransactionLineItem;
}
}
/// <summary>
/// RetailTransactionLineItem
/// </summary>
/// <value>RetailTransactionLineItem</value>
[DataMember(Name="retailTransactionLineItem", EmitDefaultValue=false)]
public ComGkSoftwareGkrApiTxpoolDtoRetailTransactionLineItem RetailTransactionLineItem { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class ComGkSoftwareGkrApiLayawayDtoLayawayLineItem {\n");
sb.Append(" RetailTransactionLineItem: ").Append(RetailTransactionLineItem).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input)
{
return this.Equals(input as ComGkSoftwareGkrApiLayawayDtoLayawayLineItem);
}
/// <summary>
/// Returns true if ComGkSoftwareGkrApiLayawayDtoLayawayLineItem instances are equal
/// </summary>
/// <param name="input">Instance of ComGkSoftwareGkrApiLayawayDtoLayawayLineItem to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(ComGkSoftwareGkrApiLayawayDtoLayawayLineItem input)
{
if (input == null)
return false;
return
(
this.RetailTransactionLineItem == input.RetailTransactionLineItem ||
(this.RetailTransactionLineItem != null &&
this.RetailTransactionLineItem.Equals(input.RetailTransactionLineItem))
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
if (this.RetailTransactionLineItem != null)
hashCode = hashCode * 59 + this.RetailTransactionLineItem.GetHashCode();
return hashCode;
}
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment