Пример #1
0
        public JObject ToJson()
        {
            JObject json = new JObject();

            json["operation_identifier"] = OperationIdentifier.ToJson();
            if (RelatedOperations != null)
            {
                json["related_operations"] = RelatedOperations.Select(p => p.ToJson()).ToArray();
            }
            json["type"]   = Type;
            json["status"] = Status;
            if (Account != null)
            {
                json["account"] = Account.ToJson();
            }
            if (Amount != null)
            {
                json["amount"] = Amount.ToJson();
            }
            if (CoinChange != null)
            {
                json["coin_change"] = CoinChange.ToJson();
            }
            if (Metadata != null && Metadata.ToJson() != null)
            {
                json["metadata"] = Metadata.ToJson();
            }
            return(json);
        }
Пример #2
0
 public static Operation FromJson(JObject json)
 {
     return(new Operation(OperationIdentifier.FromJson(json["operation_identifier"]),
                          json["type"].AsString(),
                          json["status"].AsString(),
                          json.ContainsProperty("related_operations") ? (json["related_operations"] as JArray).Select(p => OperationIdentifier.FromJson(p)).ToArray() : null,
                          json.ContainsProperty("account") ? AccountIdentifier.FromJson(json["account"]) : null,
                          json.ContainsProperty("amount") ? Amount.FromJson(json["amount"]) : null,
                          json.ContainsProperty("coin_change") ? CoinChange.FromJson(json["coin_change"]) : null,
                          json.ContainsProperty("metadata") ? Metadata.FromJson(json["metadata"]) : null));
 }
Пример #3
0
 public Operation(OperationIdentifier operationIdentifier, string type, string status,
                  OperationIdentifier[] relatedOperations = null, AccountIdentifier account = null,
                  Amount amount = null, CoinChange coinChange = null, Metadata metadata = null)
 {
     OperationIdentifier = operationIdentifier;
     RelatedOperations   = relatedOperations;
     Type       = type;
     Status     = status;
     Account    = account;
     Amount     = amount;
     CoinChange = coinChange;
     Metadata   = metadata;
 }