Esempio n. 1
0
 internal Operation(OperationIdentifier operationIdentifier, IList <OperationIdentifier> relatedOperations, string type, string status, AccountIdentifier account, Amount amount, CoinChange coinChange, object metadata)
 {
     OperationIdentifier = operationIdentifier;
     RelatedOperations   = relatedOperations;
     Type       = type;
     Status     = status;
     Account    = account;
     Amount     = amount;
     CoinChange = coinChange;
     Metadata   = metadata;
 }
Esempio n. 2
0
        internal static Operation DeserializeOperation(JsonElement element)
        {
            OperationIdentifier operationIdentifier = default;
            Optional <IList <OperationIdentifier> > relatedOperations = default;
            string                       type       = default;
            Optional <string>            status     = default;
            Optional <AccountIdentifier> account    = default;
            Optional <Amount>            amount     = default;
            Optional <CoinChange>        coinChange = default;
            Optional <object>            metadata   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("operation_identifier"))
                {
                    operationIdentifier = OperationIdentifier.DeserializeOperationIdentifier(property.Value);
                    continue;
                }
                if (property.NameEquals("related_operations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <OperationIdentifier> array = new List <OperationIdentifier>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(OperationIdentifier.DeserializeOperationIdentifier(item));
                    }
                    relatedOperations = array;
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("account"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    account = AccountIdentifier.DeserializeAccountIdentifier(property.Value);
                    continue;
                }
                if (property.NameEquals("amount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    amount = Amount.DeserializeAmount(property.Value);
                    continue;
                }
                if (property.NameEquals("coin_change"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    coinChange = CoinChange.DeserializeCoinChange(property.Value);
                    continue;
                }
                if (property.NameEquals("metadata"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    metadata = property.Value.GetObject();
                    continue;
                }
            }
            return(new Operation(operationIdentifier, Optional.ToList(relatedOperations), type, status.Value, account.Value, amount.Value, coinChange.Value, metadata.Value));
        }