Ejemplo n.º 1
0
            public payoutBatchHeader(JSONDataMap map)
            {
                PayoutBatchID = map["payout_batch_id"].AsString();
                if (PayoutBatchID.IsNullOrWhiteSpace())
                {
                    throw new PaymentException(GetType().Name + ".ctor(payout_batch_id is null)");
                }
                BatchStatus = map["batch_status"].AsEnum(payoutBatchStatus.UNDEFINED);
                if (BatchStatus == payoutBatchStatus.UNDEFINED)
                {
                    throw new PaymentException(GetType().Name + ".ctor(batch_status is UNDEFINED)");
                }
                TimeCreated   = map["time_created"].AsNullableDateTime();
                TimeCompleted = map["time_completed"].AsNullableDateTime();
                if (map.ContainsKey("sender_batch_header"))
                {
                    SenderBatchHeader = new payoutSenderBatchHeader(map["sender_batch_header"] as JSONDataMap);
                }
                else
                {
                    throw new PaymentException(GetType().Name + ".ctor(sender_batch_header is null)");
                }
                var errors = (map["errors"] as JSONDataArray) ?? Enumerable.Empty <object>();

                Errors = new List <error>(errors.Select(error => new error(error as JSONDataMap)));
            }
Ejemplo n.º 2
0
            public payoutBatch(JSONDataMap map)
            {
                if (map.ContainsKey("batch_header"))
                {
                    BatchHeader = new payoutBatchHeader(map["batch_header"] as JSONDataMap);
                }
                else
                {
                    throw new PaymentException(GetType().Name + ".ctor(batch_header is null)");
                }
                var items = (map["items"] as JSONDataArray) ?? Enumerable.Empty <object>();

                Items = new List <payoutItemDetails>(items.Select(item => new payoutItemDetails(item as JSONDataMap)));
            }
Ejemplo n.º 3
0
        private JSONDataMap doObject()
        {
            fetchPrimary();    // skip {

            var obj = new JSONDataMap();

            if (token.Type != JSONTokenType.tBraceClose) //empty object  {}
            {
                while (true)
                {
                    if (token.Type != JSONTokenType.tIdentifier && token.Type != JSONTokenType.tStringLiteral)
                    {
                        errorAndAbort(JSONMsgCode.eObjectKeyExpected);
                    }

                    var key = token.Text;

                    if (obj.ContainsKey(key))
                    {
                        errorAndAbort(JSONMsgCode.eDuplicateObjectKey);
                    }

                    fetchPrimary();
                    if (token.Type != JSONTokenType.tColon)
                    {
                        errorAndAbort(JSONMsgCode.eColonOperatorExpected);
                    }

                    fetchPrimary();

                    var value = doAny();

                    obj[key] = value;

                    fetchPrimary();
                    if (token.Type != JSONTokenType.tComma)
                    {
                        break;
                    }
                    fetchPrimary();
                }

                if (token.Type != JSONTokenType.tBraceClose)
                {
                    errorAndAbort(JSONMsgCode.eUnterminatedObject);
                }
            }
            return(obj);
        }
Ejemplo n.º 4
0
            public payoutItemDetails(JSONDataMap map)
            {
                PayoutItemID = map["payout_item_id"].AsString();
                if (PayoutItemID.IsNullOrWhiteSpace())
                {
                    throw new PaymentException(GetType().Name + ".ctor(payout_item_id is null)");
                }
                TransactionID     = map["transaction_id"].AsString();
                TransactionStatus = map["transaction_status"].AsEnum(payoutTransactionStatus.UNDEFINED);
                if (TransactionStatus == payoutTransactionStatus.UNDEFINED)
                {
                    throw new PaymentException(GetType().Name + ".ctor(transaction_status is UNDEFINED)");
                }
                var fee = parseAmount(map["payout_item_fee"] as JSONDataMap);

                if ([email protected])
                {
                    throw new PaymentException(GetType().Name + ".ctor(payout_item_fee is null)");
                }
                PayoutItemFee = fee.Value;
                PayoutBatchID = map["payout_batch_id"].AsString();
                SenderBatchID = map["sender_batch_id"].AsString();
                if (map.ContainsKey("payout_item"))
                {
                    PayoutItem = new payoutItem(map["payout_item"] as JSONDataMap);
                }
                else
                {
                    throw new PaymentException(GetType().Name + ".ctor(payout_item is null)");
                }
                TimeProcessed = map["time_processed"].AsNullableDateTime();
                if (map.ContainsKey("errors"))
                {
                    Error = new error(map["errors"] as JSONDataMap);
                }
            }