Beispiel #1
0
 public void Abs__Produces_Correct_Result(string a, string b)
 {
     Money18
     .Abs(Money18.Parse(a))
     .Should()
     .Be(b);
 }
 public IEnumerable <CustomerOperation> FromPartnersPayments(IEnumerable <PartnersPaymentResponse> source)
 {
     return(source.Select(item => new CustomerOperation
     {
         Timestamp = item.Timestamp,
         PartnerId = item.PartnerId,
         TransactionId = item.PaymentRequestId,
         TransactionType = CustomerOperationTransactionType.Burn,
         Amount = -1 * Money18.Abs(item.Amount),
         AssetSymbol = _tokenSymbol
     }));
 }
 public IEnumerable <CustomerOperation> FromPaymentTransfers(IEnumerable <PaymentTransferResponse> source)
 {
     return(source.Select(item => new CustomerOperation
     {
         Timestamp = item.Timestamp,
         PartnerId = item.TransferId,
         TransactionId = item.TransferId,
         TransactionType = CustomerOperationTransactionType.Burn,
         CampaignName = item.BurnRuleName,
         Amount = -1 * Money18.Abs(item.Amount),
         AssetSymbol = item.AssetSymbol
     }));
 }
 public IEnumerable <CustomerOperation> FromRefundedPartnersPayments(string customerId,
                                                                     IEnumerable <PartnersPaymentResponse> source)
 {
     return(source.Select(item => new CustomerOperation
     {
         Timestamp = item.Timestamp,
         PartnerId = item.PartnerId,
         TransactionId = item.PaymentRequestId,
         ReceiverCustomerId = customerId,
         TransactionType = CustomerOperationTransactionType.BurnCancelled,
         Amount = Money18.Abs(item.Amount),
         AssetSymbol = _tokenSymbol
     }));
 }
 public IEnumerable <CustomerOperation> FromRefundedPaymentTransfers(string customerId,
                                                                     IEnumerable <PaymentTransferResponse> source)
 {
     return(source.Select(item => new CustomerOperation
     {
         Timestamp = item.Timestamp,
         PartnerId = item.TransferId,
         TransactionId = item.TransferId,
         TransactionType = CustomerOperationTransactionType.BurnCancelled,
         ReceiverCustomerId = customerId,
         CampaignName = item.BurnRuleName,
         Amount = Money18.Abs(item.Amount),
         AssetSymbol = item.AssetSymbol
     }));
 }
 public IEnumerable <CustomerOperation> FromTransfers(string customerId, IEnumerable <TransferResponse> source)
 {
     return(source.Select(item => new CustomerOperation
     {
         Timestamp = item.Timestamp,
         PartnerId = item.TransactionId,
         TransactionId = item.TransactionId,
         TransactionType = CustomerOperationTransactionType.P2P,
         WalletAddress =
             item.ReceiverCustomerId == customerId ? item.WalletAddress : item.OtherSideWalletAddress,
         ReceiverCustomerId = item.ReceiverCustomerId,
         Amount = item.ReceiverCustomerId == customerId
             ? Money18.Abs(item.Amount)
             : -1 * Money18.Abs(item.Amount),
         AssetSymbol = item.AssetSymbol
     }));
 }
        public IEnumerable <CustomerOperation> FromFeeCollectedOperations(IEnumerable <FeeCollectedOperationResponse> source)
        {
            if (source != null)
            {
                return(source.Select(item => new CustomerOperation
                {
                    Timestamp = item.Timestamp,
                    TransactionId = item.OperationId,
                    TransactionType = CustomerOperationTransactionType.FeeCollected,
                    ReceiverCustomerId = item.CustomerId,
                    Amount = Money18.Abs(item.Fee),
                    AssetSymbol = item.AssetSymbol
                }));
            }

            return(new List <CustomerOperation>());
        }
        public IEnumerable <CustomerOperation> FromReleasedReferralStakes(IEnumerable <ReferralStakeResponse> source)
        {
            if (source != null)
            {
                return(source.Select(item => new CustomerOperation
                {
                    Timestamp = item.Timestamp,
                    PartnerId = item.ReferralId,
                    TransactionId = item.ReferralId,
                    TransactionType = CustomerOperationTransactionType.ReleasedReferralStake,
                    ReceiverCustomerId = item.CustomerId,
                    CampaignName = item.CampaignName,
                    Amount = Money18.Abs(item.Amount),
                    AssetSymbol = item.AssetSymbol
                }));
            }

            return(new List <CustomerOperation>());
        }
        public IEnumerable <CustomerOperation> FromVoucherPurchasePayments(
            IEnumerable <VoucherPurchasePaymentResponse> source, IReadOnlyDictionary <Guid, string> spendRuleNames)
        {
            if (source != null)
            {
                return(source.Select(item => new CustomerOperation
                {
                    Timestamp = item.Timestamp,
                    TransactionId = item.TransferId.ToString(),
                    TransactionType = CustomerOperationTransactionType.VoucherPurchasePayment,
                    CampaignName = spendRuleNames.ContainsKey(item.SpendRuleId)
                        ? spendRuleNames[item.SpendRuleId]
                        : null,
                    Amount = -Money18.Abs(item.Amount),
                    AssetSymbol = item.AssetSymbol
                }));
            }

            return(new List <CustomerOperation>());
        }
        public IEnumerable <CustomerOperation> FromLinkedWalletTransfers(string customerId, IEnumerable <LinkedWalletTransferResponse> source)
        {
            if (source != null)
            {
                return(source.Select(item => new CustomerOperation
                {
                    Timestamp = item.Timestamp,
                    TransactionId = item.TransactionId,
                    TransactionType = CustomerOperationTransactionType.LinkedWalletTransfer,
                    WalletAddress = item.Direction == LinkedWalletTransferDirection.Incoming ? item.LinkedWalletAddress : item.WalletAddress,
                    ReceiverCustomerId = customerId,
                    Amount = item.Direction == LinkedWalletTransferDirection.Outgoing ? Money18.Abs(item.Amount) * -1 : Money18.Abs(item.Amount),
                    AssetSymbol = item.AssetSymbol
                }));
            }

            return(new List <CustomerOperation>());
        }