- login by token - save account info - logout remove accout info - iOS SKU list parser - iOS Pay
145 lines
3.5 KiB
C#
145 lines
3.5 KiB
C#
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace tysdk
|
|
{
|
|
public enum EAccoutType
|
|
{
|
|
hwGoogle,
|
|
hwFacebook,
|
|
hwGuest,
|
|
none
|
|
}
|
|
|
|
public interface ITYSdkCallback { }
|
|
|
|
public class LoginInfo : ITYSdkCallback
|
|
{
|
|
public bool isSuccess;
|
|
public int userId;
|
|
public string StrUserId => userId.ToString();
|
|
public string msg;
|
|
public int code;
|
|
}
|
|
|
|
public class PaymentInfo : ITYSdkCallback
|
|
{
|
|
public bool isSuccess => code == "0";
|
|
public int count;
|
|
public string orderId;
|
|
public string productId;
|
|
public string price;
|
|
|
|
public string code;
|
|
public string msg;
|
|
|
|
public override string ToString()
|
|
{
|
|
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
|
}
|
|
}
|
|
|
|
public class ProductListInfo: ITYSdkCallback
|
|
{
|
|
public int code = 1;
|
|
public string msg = string.Empty;
|
|
public List<SKUDetail> products;
|
|
|
|
#if UNITY_IOS && !UNITY_EDITOR
|
|
public void ReadSKUFromJson(string json)
|
|
{
|
|
var prodList = Newtonsoft.Json.Linq.JArray.Parse(json).Select(x => {
|
|
return new SKUDetail() {
|
|
price = x["price"].ToString(),
|
|
productId = x["productId"].ToString(),
|
|
LocaleCurrencyCode = x["LocaleCurrencyCode"].ToString(),
|
|
localeCurrencySymbol = x["localeCurrencySymbol"].ToString(),
|
|
localizedDescription = x["localizedDescription"].ToString(),
|
|
localizedTitle = x["localizedTitle"].ToString()
|
|
};
|
|
}).ToList();
|
|
products = prodList;
|
|
}
|
|
#endif
|
|
|
|
}
|
|
|
|
#if UNITY_ANDROID || UNITY_EDITOR
|
|
public class SKUDetail
|
|
{
|
|
public string description;
|
|
public string ourProductId;
|
|
public string price;
|
|
public string price_amount_micros;
|
|
public string price_currency_code;
|
|
public string productId;
|
|
public string title;
|
|
public string type;
|
|
|
|
public override string ToString()
|
|
{
|
|
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
|
}
|
|
}
|
|
#elif UNITY_IOS
|
|
public class SKUDetail
|
|
{
|
|
public string price;
|
|
public string productId;
|
|
public string LocaleCurrencyCode;
|
|
public string localeCurrencySymbol;
|
|
public string localizedDescription;
|
|
public string localizedTitle;
|
|
|
|
public override string ToString()
|
|
{
|
|
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
|
|
public class ATTInfo : ITYSdkCallback
|
|
{
|
|
public bool isAccepted;
|
|
}
|
|
|
|
public class ADLoadInfo
|
|
{
|
|
public bool isSuccess => code == "0";
|
|
public string code;
|
|
public string errStr;
|
|
|
|
public override string ToString()
|
|
{
|
|
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
|
}
|
|
}
|
|
|
|
public enum EShowAdState : byte
|
|
{
|
|
StartShow = 1,
|
|
Reward = 2,
|
|
Loading = 3,
|
|
LoadFaild = 4,
|
|
ShowFaild = 5,
|
|
Closed = 6,
|
|
Finished = 7,
|
|
TimeOut = 8
|
|
}
|
|
|
|
public class ShowADInfo
|
|
{
|
|
public string code;
|
|
public string message;
|
|
public string reward;
|
|
public EShowAdState state => (EShowAdState)int.Parse(code);
|
|
|
|
public override string ToString()
|
|
{
|
|
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
|
}
|
|
}
|
|
}
|