Skip to content

Commit

Permalink
Formatted cs files with vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihz committed Apr 18, 2020
1 parent d1325eb commit b3bb5ab
Show file tree
Hide file tree
Showing 7 changed files with 596 additions and 885 deletions.
18 changes: 7 additions & 11 deletions SibcheStoreKit/Models/SibcheError.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
using SimpleJSON;

namespace SibcheStoreKit
{
public class SibcheError
{
namespace SibcheStoreKit {
public class SibcheError {
public string message;
public int errorCode;
public int statusCode;

public SibcheError(string json)
{
if (!string.IsNullOrEmpty(json) && json.Length > 0)
{
JSONNode node = JSON.Parse(json);
public SibcheError (string json) {
if (!string.IsNullOrEmpty (json) && json.Length > 0) {
JSONNode node = JSON.Parse (json);
message = node["message"].Value;
errorCode = int.Parse(node["errorCode"]);
statusCode = int.Parse(node["statusCode"].Value);
errorCode = int.Parse (node["errorCode"]);
statusCode = int.Parse (node["statusCode"].Value);
}
}
}
Expand Down
17 changes: 5 additions & 12 deletions SibcheStoreKit/Models/SibchePackage.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using SimpleJSON;

namespace SibcheStoreKit
{
public abstract class SibchePackage
{
namespace SibcheStoreKit {
public abstract class SibchePackage {
public string packageId;
public string type;
public string code;
Expand All @@ -14,16 +12,11 @@ public abstract class SibchePackage
public int discount;
}

public class SibcheConsumablePackage : SibchePackage
{
}
public class SibcheConsumablePackage : SibchePackage { }

public class SibcheNonConsumablePackage : SibchePackage
{
}
public class SibcheNonConsumablePackage : SibchePackage { }

public class SibcheSubscriptionPackage : SibchePackage
{
public class SibcheSubscriptionPackage : SibchePackage {
public int duration;
public string group;
}
Expand Down
72 changes: 32 additions & 40 deletions SibcheStoreKit/Models/SibchePackageFactory.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,46 @@
using SimpleJSON;

namespace SibcheStoreKit
{
class SibchePackageFactory
{
public static SibchePackage GetSibchePackage(string json)
{
if (!string.IsNullOrEmpty(json) && json.Length > 0)
{
JSONNode node = JSON.Parse(json);
namespace SibcheStoreKit {
class SibchePackageFactory {
public static SibchePackage GetSibchePackage (string json) {
if (!string.IsNullOrEmpty (json) && json.Length > 0) {
JSONNode node = JSON.Parse (json);
var type = node["type"].Value;
switch (type)
{
switch (type) {
case "ConsumableInAppPackage":
return new SibcheConsumablePackage
{
return new SibcheConsumablePackage {
packageId = node["packageId"].Value,
type = "SibcheConsumablePackage",
code = node["code"].Value,
name = node["name"].Value,
packageDescription = node["packageDescription"].Value,
price = int.Parse(node["price"].Value),
totalPrice = int.Parse(node["totalPrice"].Value),
discount = int.Parse(node["discount"].Value)
type = "SibcheConsumablePackage",
code = node["code"].Value,
name = node["name"].Value,
packageDescription = node["packageDescription"].Value,
price = int.Parse (node["price"].Value),
totalPrice = int.Parse (node["totalPrice"].Value),
discount = int.Parse (node["discount"].Value)
};
case "NonConsumableInAppPackage":
return new SibcheNonConsumablePackage
{
return new SibcheNonConsumablePackage {
packageId = node["packageId"].Value,
type = "SibcheNonConsumablePackage",
code = node["code"].Value,
name = node["name"].Value,
packageDescription = node["packageDescription"].Value,
price = int.Parse(node["price"].Value),
totalPrice = int.Parse(node["totalPrice"].Value),
discount = int.Parse(node["discount"].Value)
type = "SibcheNonConsumablePackage",
code = node["code"].Value,
name = node["name"].Value,
packageDescription = node["packageDescription"].Value,
price = int.Parse (node["price"].Value),
totalPrice = int.Parse (node["totalPrice"].Value),
discount = int.Parse (node["discount"].Value)
};
case "SubscriptionInAppPackage":
return new SibcheSubscriptionPackage
{
return new SibcheSubscriptionPackage {
packageId = node["packageId"].Value,
type = "SibcheSubscriptionPackage",
code = node["code"].Value,
name = node["name"].Value,
packageDescription = node["packageDescription"].Value,
price = int.Parse(node["price"].Value),
totalPrice = int.Parse(node["totalPrice"].Value),
discount = int.Parse(node["discount"].Value),
duration = int.Parse(node["duration"].Value),
group = node["group"].Value
type = "SibcheSubscriptionPackage",
code = node["code"].Value,
name = node["name"].Value,
packageDescription = node["packageDescription"].Value,
price = int.Parse (node["price"].Value),
totalPrice = int.Parse (node["totalPrice"].Value),
discount = int.Parse (node["discount"].Value),
duration = int.Parse (node["duration"].Value),
group = node["group"].Value
};
}
}
Expand Down
30 changes: 13 additions & 17 deletions SibcheStoreKit/Models/SibchePurchasePackage.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
using System;
using System;
using SimpleJSON;

namespace SibcheStoreKit
{
public class SibchePurchasePackage
{
namespace SibcheStoreKit {
public class SibchePurchasePackage {
public string purchasePackageId;
public string type;
public string code;
public DateTime expireAt;
public DateTime createdAt;
public SibchePackage package;

public SibchePurchasePackage(string json)
{
if (!string.IsNullOrEmpty(json) && json.Length > 0)
{
JSONNode node = JSON.Parse(json);
public SibchePurchasePackage (string json) {
if (!string.IsNullOrEmpty (json) && json.Length > 0) {
JSONNode node = JSON.Parse (json);
purchasePackageId = node["purchasePackageId"].Value;
type = node["type"].Value;
code = node["code"].Value;
var expireAtSecs = long.Parse(node["expireAt"].Value);
var createdAtSecs = long.Parse(node["createdAt"].Value);
var expireAtSecs = long.Parse (node["expireAt"].Value);
var createdAtSecs = long.Parse (node["createdAt"].Value);

expireAt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Local);
expireAt = expireAt.AddSeconds(expireAtSecs);
createdAt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Local);
createdAt = createdAt.AddSeconds(createdAtSecs);
package = SibchePackageFactory.GetSibchePackage(node["package"].Value);
expireAt = new DateTime (1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Local);
expireAt = expireAt.AddSeconds (expireAtSecs);
createdAt = new DateTime (1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Local);
createdAt = createdAt.AddSeconds (createdAtSecs);
package = SibchePackageFactory.GetSibchePackage (node["package"].Value);
}
}
}
Expand Down
Loading

0 comments on commit b3bb5ab

Please sign in to comment.