Repository URL to install this package:
Version:
2025.8.2 ▾
|
/*
* Copyright 2016 Game Server Services, Inc. or its affiliates. All Rights
* Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Gs2.Core.Model;
using Gs2.Util.LitJson;
#if UNITY_2017_1_OR_NEWER
using UnityEngine.Scripting;
#endif
namespace Gs2.Gs2AdReward.Model
{
#if UNITY_2017_1_OR_NEWER
[Preserve]
#endif
public class History : IComparable
{
public string Provider { set; get; }
public string TransactionId { set; get; }
public long? CreatedAt { set; get; }
public long? Revision { set; get; }
public History WithProvider(string provider) {
this.Provider = provider;
return this;
}
public History WithTransactionId(string transactionId) {
this.TransactionId = transactionId;
return this;
}
public History WithCreatedAt(long? createdAt) {
this.CreatedAt = createdAt;
return this;
}
public History WithRevision(long? revision) {
this.Revision = revision;
return this;
}
#if UNITY_2017_1_OR_NEWER
[Preserve]
#endif
public static History FromJson(JsonData data)
{
if (data == null) {
return null;
}
return new History()
.WithProvider(!data.Keys.Contains("provider") || data["provider"] == null ? null : data["provider"].ToString())
.WithTransactionId(!data.Keys.Contains("transactionId") || data["transactionId"] == null ? null : data["transactionId"].ToString())
.WithCreatedAt(!data.Keys.Contains("createdAt") || data["createdAt"] == null ? null : (long?)long.Parse(data["createdAt"].ToString()))
.WithRevision(!data.Keys.Contains("revision") || data["revision"] == null ? null : (long?)long.Parse(data["revision"].ToString()));
}
public JsonData ToJson()
{
return new JsonData {
["provider"] = Provider,
["transactionId"] = TransactionId,
["createdAt"] = CreatedAt,
["revision"] = Revision,
};
}
public void WriteJson(JsonWriter writer)
{
writer.WriteObjectStart();
if (Provider != null) {
writer.WritePropertyName("provider");
writer.Write(Provider.ToString());
}
if (TransactionId != null) {
writer.WritePropertyName("transactionId");
writer.Write(TransactionId.ToString());
}
if (CreatedAt != null) {
writer.WritePropertyName("createdAt");
writer.Write(long.Parse(CreatedAt.ToString()));
}
if (Revision != null) {
writer.WritePropertyName("revision");
writer.Write(long.Parse(Revision.ToString()));
}
writer.WriteObjectEnd();
}
public int CompareTo(object obj)
{
var other = obj as History;
var diff = 0;
if (Provider == null && Provider == other.Provider)
{
// null and null
}
else
{
diff += Provider.CompareTo(other.Provider);
}
if (TransactionId == null && TransactionId == other.TransactionId)
{
// null and null
}
else
{
diff += TransactionId.CompareTo(other.TransactionId);
}
if (CreatedAt == null && CreatedAt == other.CreatedAt)
{
// null and null
}
else
{
diff += (int)(CreatedAt - other.CreatedAt);
}
if (Revision == null && Revision == other.Revision)
{
// null and null
}
else
{
diff += (int)(Revision - other.Revision);
}
return diff;
}
}
}