static public async Task <ListTransactionsResponse> GetTransactions(string id) { TransactionsApi api = new TransactionsApi(); ListTransactionsResponse resp = await api.ListTransactionsAsync(id); return(resp); }
static void Main(string[] args) { var txn_client = new TransactionsApi(new FireflyIII.Client.Configuration() { BasePath = ff3_demo_url, AccessToken = ff3_demo_pat, }); var txn = new FireflyIII.Model.TransactionSplit( date: DateTime.Now, description: "Test FireflyIII .Net Transaction", amount: 12.54, currencyCode: "EUR", type: TransactionSplit.TypeEnum.Withdrawal, // Can set source/dest by account ID or name // sourceId: 1, sourceName: "Checking Account", destinationId: 7 ); var txn_rsp = txn_client.StoreTransaction(new FireflyIII.Model.Transaction(new[] { txn }.ToList())); Console.WriteLine($"Created transaction {txn_rsp.Data.Id}"); // Set a breakpoint here: txn_client.DeleteTransaction(txn_rsp.Data.Id); Console.WriteLine($"Deleted transaction"); }
public void OnPost() { string nonce = Request.Form["nonce"]; TransactionsApi transactionsApi = new TransactionsApi(); // Every payment you process with the SDK must have a unique idempotency key. // If you're unsure whether a particular payment succeeded, you can reattempt // it with the same idempotency key without worrying about double charging // the buyer. string uuid = NewIdempotencyKey(); // Monetary amounts are specified in the smallest unit of the applicable currency. // This amount is in cents. It's also hard-coded for $1.00, // which isn't very useful. Money amount = new Money(100, Money.CurrencyEnum.USD); // To learn more about splitting transactions with additional recipients, // see the Transactions API documentation on our [developer site] // (https://docs.connect.squareup.com/payments/transactions/overview#mpt-overview). ChargeRequest body = new ChargeRequest(AmountMoney: amount, IdempotencyKey: uuid, CardNonce: nonce); try { var response = transactionsApi.Charge(LocationId, body); this.ResultMessage = "Transaction complete! " + response.ToJson(); } catch (ApiException e) { this.ResultMessage = e.Message; } }
public static string Charge(string nonce) { TransactionsApi transactionsApi = new TransactionsApi(); // Every payment you process with the SDK must have a unique idempotency key. // If you're unsure whether a particular payment succeeded, you can reattempt // it with the same idempotency key without worrying about double charging // the buyer. string uuid = NewIdempotencyKey(); // Monetary amounts are specified in the smallest unit of the applicable currency. // This amount is in cents. It's also hard-coded for $1.00, // which isn't very useful. Money amount = new Money(100, Money.CurrencyEnum.USD); ChargeRequest body = new ChargeRequest(AmountMoney: amount, IdempotencyKey: uuid, CardNonce: nonce); try { var response = transactionsApi.Charge(LocationId, body); return("Transaction complete\n" + response.ToJson()); } catch (ApiException e) { return(e.Message); } }
public string SendTransferTransactionToDataBase <M>(string assetID, MetaDataSaved <M> metaData, string senderPrivateSignKey, string recieverPublicSignKey, string inputTransID) { var senderSignPrivateKey = EncryptionService.getSignKeyFromPrivate(senderPrivateSignKey); var recieverSignPublicKey = EncryptionService.getSignPublicKeyFromString(recieverPublicSignKey); // Using TRANSFER: START // add input var input = new Omnibasis.BigchainCSharp.Model.FulFill(); input.TransactionId = inputTransID; input.OutputIndex = 0; Details details = null; // transfer transaction // assetId is the transactionId to the asset we want to change var transaction = BigchainDbTransactionBuilder <Asset <string>, MetaDataSaved <M> > .init() .addAssets(assetID) .addMetaData(metaData) .addInput(details, input, senderSignPrivateKey.PublicKey) .addOutput("1", recieverSignPublicKey) .operation(Operations.TRANSFER) .buildAndSignOnly(senderSignPrivateKey.PublicKey, senderSignPrivateKey); var createTransaction = TransactionsApi <Asset <string>, MetaDataSaved <M> > .sendTransactionAsync(transaction).GetAwaiter().GetResult(); return(createTransaction.Data.Id); }
/// <summary> /// Get transaction of account Retrieve the details of a single transaction by its ID associated to a specific account. /// </summary> /// <exception cref="ApiException">Thrown when fails to make API call</exception> /// <param name="accessToken"></param> /// <param name="accountId"></param> /// <param name="transactionId"></param> /// <returns>Transaction</returns> public async Task <Transaction> GetDetailAsync(AccessTokenDto accessToken, string accountId, string transactionId) { if (accessToken == null) { throw new ArgumentNullException(nameof(accessToken)); } if (!accessToken.IsValid) { throw new ArgumentException($"{nameof(accessToken)} is expired."); } if (accountId == null) { throw new ArgumentNullException(nameof(accountId)); } if (transactionId == null) { throw new ArgumentNullException(nameof(transactionId)); } this.Configuration.AccessToken = accessToken.AccessToken; var transactionsApi = new TransactionsApi(this.Configuration, this.Logger); return(await transactionsApi .GetTransctionOfAccountAsync(accountId, transactionId) .ConfigureAwait(false)); }
/// <summary> /// List transactions Get a list of the transactions of all accounts. You can additionally constrain the amount of /// transactions being returned by using the query parameters described below as filters. /// </summary> /// <exception cref="ApiException">Thrown when fails to make API call</exception> /// <param name="accessToken"></param> /// <param name="listFilter"> /// (optional) /// count: /// Limit the number of returned items. In combination with the offset parameter this can be used to /// paginate the result list. (optional, default to 1000) /// offset: /// Skip this number of transactions in the response. In combination with the count parameter this can /// be used to paginate the result list. (optional, default to 0) /// since: /// Return only transactions after this date based on since_type. This parameter can either /// be a transaction ID or a date. Given at least one transaction matches the filter criterion, if provided as /// transaction ID the result will *not* contain this ID. If provided as ISO date, the result *will* contain this date. /// This behavior may change in the future. (optional) /// sinceType: /// This parameter defines how the parameter since will be interpreted. (optional, /// default to created) /// filter: /// Filter transactions by given key:value combination. Possible keys: - date (maps to /// booked_at, please use ISO date here, not datetime) - person (maps to payer/payee name) - purpose /// - amount Values are interpreted using wildcards: person:John Doe will match %John Doe%. /// (optional) /// includePending: /// This flag indicates whether pending transactions should be included in the response. /// Pending transactions are always included as a complete set, regardless of the since parameter. (optional, default /// to false) /// sort /// Determines whether results will be sorted in ascending or descending order. (optional) /// until: /// Return only transactions which were booked on or before this date. Please provide as ISO date. It /// is not possible to use the since_type semantics with until. (optional) /// includeStatistics: /// If true includes statistics on the returned transactions: maximum deposit, /// total deposits, maximum expense, total expenses. (optional, default to false) /// filter: /// Filter transactions by given key:value combination. Possible keys: - date (maps to /// booked_at, please use ISO date here, not datetime) - person (maps to payer/payee name) - purpose /// - amount Values are interpreted using wildcards: person:John Doe will match %John Doe%. /// (optional) /// </param> /// <returns>TransactionList</returns> public async Task <TransactionList> GetAllAsync(AccessTokenDto accessToken, AccountListFilter listFilter = default) { if (accessToken == null) { throw new ArgumentNullException(nameof(accessToken)); } if (!accessToken.IsValid) { throw new ArgumentException($"{nameof(accessToken)} is expired."); } this.Configuration.AccessToken = accessToken.AccessToken; var transactionsApi = new TransactionsApi(this.Configuration, this.Logger); return(await transactionsApi.ListTransactionsAsync( null, listFilter?.Filter, null, listFilter?.Count, listFilter?.Offset, listFilter?.Sort, listFilter?.Since?.ToString("O"), listFilter?.Until?.ToString("O"), listFilter?.SinceType, listFilter?.Types, listFilter?.Cents, listFilter?.IncludePending, listFilter?.IncludeStatistics).ConfigureAwait(false)); }
public PageableTransactionList NewTransactions(string userId, string userPassword, long accountid, int page) { var token = GetUserAccessToken(userId, userPassword); var api = new TransactionsApi(BasePath); api.ApiClient.AddDefaultHeader("Authorization", "Bearer " + token); var ids = new List <long?>(); ids.Add(accountid); var isNew = true; //var page = 1; var amount = 100; //var result = api.GetAndSearchAllTransactions("bankView", ids, null, null, null, null, null, null, null, null, null, null, null, null, null, null, isNew, null, null, null, null, page, amount, null); var request = new RestRequest("/api/v1/transactions", Method.GET); request.AddHeader("Authorization", "Bearer " + token); request.AddParameter("page", page); request.AddParameter("perPage", amount); request.AddParameter("isNew", isNew); request.AddParameter("accountIds", accountid); request.AddParameter("view", "bankView"); var response = restClient.Execute <PageableTransactionList>(request); var result = response.Data; return(result); }
public OrdersSample(JObject authConfig) { Configuration config = Configuration.Default; config.ApiKey.Add("X-Auth-Token", (string)authConfig["accessToken"]); config.BasePath = config.BasePath.Replace("{$$.env.store_hash}", (string)authConfig["storeId"]); this.transactionsApi = new TransactionsApi(config); }
public void Initialize() { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; _tokensApi = new TokensApi(TestApiSettings.Uri); _transactionsApi = new TransactionsApi(TestApiSettings.Uri); _tokensApi.Configuration.AddDefaultHeader("Authorization", "Api-Key " + TestApiSettings.PublicKey); _transactionsApi.Configuration.AddDefaultHeader("Authorization", "Api-Key " + TestApiSettings.PublicKey); }
public PaystackApi(string apiKey) { _apiKey = apiKey; SubAccounts = new SubAccountApi(this); Transactions = new TransactionsApi(this); Customers = new CustomersApi(this); Miscellaneous = new MiscellaneousApi(this); Charge = new ChargeApi(this); _paystackApiBaseUrl = new Uri("https://api.paystack.co/"); }
public void Initialize() { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; _transactionsApi = new TransactionsApi(TestApiSettings.Uri); var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(TestApiSettings.Key + ":" + TestApiSettings.Secret); _transactionsApi.Configuration.AddDefaultHeader("Authorization", "Basic " + System.Convert.ToBase64String(plainTextBytes)); }
/// <summary> /// Void authorized transaction /// </summary> /// <param name="transactionId">Transaction ID</param> /// <returns>True if the transaction successfully voided; otherwise false. And/or errors if exist</returns> public PaymentResponse <bool> VoidTransaction(string transactionId) { try { //try to get the selected location var selectedLocation = GetActiveLocations().FirstOrDefault(location => location.Id.Equals(_squarePaymentSettings.LocationId)); if (selectedLocation == null) { throw new NopException("Location is a required parameter for payment requests"); } //create transaction API var configuration = CreateApiConfiguration(); var transactionsApi = new TransactionsApi(configuration); //void transaction by identifier var voidTransactionResponse = transactionsApi.VoidTransaction(selectedLocation.Id, transactionId); if (voidTransactionResponse == null) { throw new NopException("No service response"); } //check whether there are errors in the service response if (voidTransactionResponse.Errors?.Any() ?? false) { var errorsMessage = string.Join(";", voidTransactionResponse.Errors.Select(error => error.ToString())); throw new NopException($"There are errors in the service response. {errorsMessage}"); } //if there are no errors in the response, transaction was successfully voided return(new PaymentResponse <bool> { ResponseValue = true }); } catch (Exception exception) { //log full error var errorMessage = exception.Message; _logger.Error($"Square payment error: {errorMessage}.", exception, _workContext.CurrentCustomer); if (exception is ApiException apiException) { //try to get error details var response = JsonConvert.DeserializeObject <VoidTransactionResponse>(apiException.ErrorContent) as VoidTransactionResponse; if (response?.Errors?.Any() ?? false) { errorMessage = string.Join(";", response.Errors.Select(error => error.Detail)); } } return(new PaymentResponse <bool> { Error = errorMessage }); } }
private async Task <List <TransactionDetail> > GetVenmoDeposits(Database.Models.VenmoUser venmoUser, Configuration configuration) { TransactionsApi transactionsApi = new TransactionsApi(configuration); TransactionsResponse transactions = await transactionsApi.GetTransactionsByAccountAsync(Default, venmoUser.YNAB !.DefaultAccount); var venmoDeposits = transactions.Transactions .Where(t => t.PayeeName != null && t.PayeeName.ToLower().Contains("from venmo")) .OrderByDescending(t => t.Date) .ToList(); return(venmoDeposits); }
/// <summary> /// Create a refund of the transaction /// </summary> /// <param name="transactionId">Transaction ID</param> /// <param name="refundRequest">Request parameters to create refund</param> /// <param name="storeId">Store identifier for which refund should be created</param> /// <returns>Refund and/or errors if exist</returns> public (Refund, string) CreateRefund(string transactionId, CreateRefundRequest refundRequest, int storeId) { try { var settings = _settingService.LoadSetting <SquarePaymentSettings>(storeId); //try to get the selected location var selectedLocation = GetActiveLocations(storeId).FirstOrDefault(location => location.Id.Equals(settings.LocationId)); if (selectedLocation == null) { throw new NopException("Location is a required parameter for payment requests"); } //create transaction API var configuration = CreateApiConfiguration(storeId); var transactionsApi = new TransactionsApi(configuration); //create refund var createRefundResponse = transactionsApi.CreateRefund(selectedLocation.Id, transactionId, refundRequest); if (createRefundResponse == null) { throw new NopException("No service response"); } //check whether there are errors in the service response if (createRefundResponse.Errors?.Any() ?? false) { var errorsMessage = string.Join(";", createRefundResponse.Errors.Select(error => error.ToString())); throw new NopException($"There are errors in the service response. {errorsMessage}"); } return(createRefundResponse.Refund, null); } catch (Exception exception) { //log full error var errorMessage = exception.Message; _logger.Error($"Square payment error: {errorMessage}.", exception, _workContext.CurrentCustomer); if (exception is ApiException apiException) { //try to get error details var response = JsonConvert.DeserializeObject <CreateRefundResponse>(apiException.ErrorContent) as CreateRefundResponse; if (response?.Errors?.Any() ?? false) { errorMessage = string.Join(";", response.Errors.Select(error => error.Detail)); } } return(null, errorMessage); } }
public async Task <IActionResult> ValidateAsync(string transactionId) { if (string.IsNullOrWhiteSpace(transactionId)) { return(NotFound()); } try { var conn1Config = new Dictionary <string, object>(); //config connection 1 conn1Config.Add("baseUrl", "http://ebcl1.ici.ro"); BlockchainConnection conn1 = new BlockchainConnection(conn1Config); var conn2Config = new Dictionary <string, object>(); var headers2 = new Dictionary <string, string>(); //config connection 2 conn2Config.Add("baseUrl", "http://ebcl2.ici.ro"); BlockchainConnection conn2 = new BlockchainConnection(conn2Config); var conn3Config = new Dictionary <string, object>(); var headers3 = new Dictionary <string, string>(); //config connection 2 conn3Config.Add("baseUrl", "http://ebcl3.ici.ro"); BlockchainConnection conn3 = new BlockchainConnection(conn2Config); //add connections IList <BlockchainConnection> connections = new List <BlockchainConnection>(); connections.Add(conn1); connections.Add(conn2); connections.Add(conn3); //multiple connections var builderWithConnections = BigchainDbConfigBuilder .addConnections(connections) .setTimeout(60000); //override default timeout of 20000 milliseconds await builderWithConnections.setup(); var testTran2 = await TransactionsApi <object, object> .getTransactionByIdAsync(transactionId); BlockchainTransaction bt = JsonConvert.DeserializeObject <BlockchainTransaction>(testTran2.Asset.Data.ToString()); return(View(bt)); } catch (Exception e) { return(Content("Error connecting to the blockchain")); } }
public M GetMetadataFromAssetPublicKey <M>(string assetID, string signPublicKey) { var rawPublicKey = EncryptionService.getRawBase58PublicKey(signPublicKey); var unspentOutsList = OutputsApi.getUnspentOutputsAsync(rawPublicKey).GetAwaiter().GetResult(); var assetTransactions = TransactionsApi <object, object> .getTransactionsByAssetIdAsync(assetID).GetAwaiter().GetResult(); var neededTransaction = from a in unspentOutsList.AsQueryable() join b in assetTransactions.AsQueryable() on a.TransactionId equals b.Id select b.MetaData.Metadata; MetaDataSaved <M> result = JsonConvert.DeserializeObject <MetaDataSaved <M> >(neededTransaction.FirstOrDefault().ToString()); return(result.data); }
public AtriumClient(string apiKey, string clientID, string basePath = "https://vestibule.mx.com") { this.accounts = new AccountsApi(apiKey, clientID, basePath); this.connectWidget = new ConnectWidgetApi(apiKey, clientID, basePath); this.holdings = new HoldingsApi(apiKey, clientID, basePath); this.identity = new IdentityApi(apiKey, clientID, basePath); this.institutions = new InstitutionsApi(apiKey, clientID, basePath); this.members = new MembersApi(apiKey, clientID, basePath); this.merchants = new MerchantsApi(apiKey, clientID, basePath); this.statements = new StatementsApi(apiKey, clientID, basePath); this.transactions = new TransactionsApi(apiKey, clientID, basePath); this.users = new UsersApi(apiKey, clientID, basePath); this.verification = new VerificationApi(apiKey, clientID, basePath); }
static string GetTransactionFromErrorMessageExample(Configuration configuration) { // Please see https://docs.transferzero.com/docs/transaction-flow/#receiving-error-messages // on details about error messages Guid transationId = Guid.Parse("2cf44191-ffff-ffff-ffff-f0d133a709f1"); TransactionsApi transactionsApi = new TransactionsApi(configuration); TransactionResponse response = transactionsApi.GetTransaction(transactionID: transationId); System.Console.WriteLine("Payout error message on recipient: " + response.Object.Recipients[0].StateReason); return(response.Object.Recipients[0].StateReason); }
public FlutterwaveApi(string apiKey) { _apiKey = apiKey; _flutterwaveApiBaseUrl = new Uri("https://api.flutterwave.com/v3/"); Card = new CardPaymentApi(this); Transactions = new TransactionsApi(this); Verifications = new VerificationApi(this); Banks = new BanksApi(this); Bills = new BillsApi(this); Settlements = new SettlementsApi(this); Otps = new OtpsApi(this); Chargebacks = new ChargebacksApi(this); Misc = new MiscApi(this); }
public string SendCreateTransactionToDataBase <A, M>(AssetSaved <A> asset, MetaDataSaved <M> metaData, string privateSignKey) { var signPrivateKey = EncryptionService.getSignKeyFromPrivate(privateSignKey); var transaction = BigchainDbTransactionBuilder <AssetSaved <A>, MetaDataSaved <M> > .init() .addAssets(asset) .addMetaData(metaData) .operation(Operations.CREATE) .buildAndSignOnly(signPrivateKey.PublicKey, signPrivateKey); var createTransaction = TransactionsApi <AssetSaved <A>, MetaDataSaved <M> > .sendTransactionAsync(transaction).GetAwaiter().GetResult(); return(createTransaction.Data.Id); }
public OkraApi(string accessToken, bool useSandBox) { if (string.IsNullOrWhiteSpace(accessToken)) { throw new ArgumentException("Okra api token cannot be empty", nameof(accessToken)); } var baseUrl = useSandBox ? "https://api.okra.ng/sandbox/v1/" : "https://api.okra.ng/v1/"; _client = CreateClient(baseUrl, accessToken); Auth = new AuthApi(this); Balance = new BalanceApi(this); Identity = new IdentityApi(this); Income = new IncomeApi(this); Transactions = new TransactionsApi(this); }
public AtriumClient(string apiKey, string clientID) { Configuration.Default.AddApiKey("MX-API-Key", apiKey); Configuration.Default.AddApiKey("MX-Client-ID", clientID); this.accounts = new AccountsApi(); this.connectWidget = new ConnectWidgetApi(); this.holdings = new HoldingsApi(); this.identity = new IdentityApi(); this.institutions = new InstitutionsApi(); this.members = new MembersApi(); this.merchants = new MerchantsApi(); this.statements = new StatementsApi(); this.transactions = new TransactionsApi(); this.users = new UsersApi(); this.verification = new VerificationApi(); }
public MetaData <MetaDataSaved <M> > GetMetadataIDFromAssetPublicKey <M>(string assetID, string signPublicKey) { var rawPublicKey = EncryptionService.getRawBase58PublicKey(signPublicKey); var unspentOutsList = OutputsApi.getUnspentOutputsAsync(rawPublicKey).GetAwaiter().GetResult(); var assetTransactions = TransactionsApi <object, MetaDataSaved <M> > .getTransactionsByAssetIdAsync(assetID).GetAwaiter().GetResult(); var neededTransaction = from a in unspentOutsList.AsQueryable() join b in assetTransactions.AsQueryable() on a.TransactionId equals b.Id select new MetaData <MetaDataSaved <M> > { Id = b.Id, Metadata = b.MetaData.Metadata }; var result = neededTransaction.FirstOrDefault(); return(result); }
public void GetAllTransactionsTest() { AuthInfosMock.Configure(); var client = new TransactionsApi(); var transactions = client.GETTransactions( "Organisation ID", "Account", null, null, null, null, null, null, null, null ); Assert.IsNotNull(transactions); }
/// <summary> /// Void authorized transaction /// </summary> /// <param name="transactionId">Transaction ID</param> /// <returns>True if the transaction successfully voided; otherwise false</returns> public bool VoidTransaction(string transactionId) { try { //try to get the selected location var selectedLocation = GetActiveLocations().FirstOrDefault(location => location.Id.Equals(_squarePaymentSettings.LocationId)); if (selectedLocation == null) throw new NopException("Location is a required parameter for payment requests"); //create transaction API var configuration = CreateApiConfiguration(); var transactionsApi = new TransactionsApi(configuration); //void transaction by identifier var voidTransactionResponse = transactionsApi.VoidTransaction(selectedLocation.Id, transactionId); if (voidTransactionResponse == null) throw new NopException("No service response"); //check whether there are errors in the service response if (voidTransactionResponse.Errors?.Any() ?? false) { var errorsMessage = string.Join(";", voidTransactionResponse.Errors.Select(error => error.ToString())); throw new NopException($"There are errors in the service response. {errorsMessage}"); } //if there are no errors in the response, transaction was successfully voided return true; } catch (Exception exception) { var errorMessage = $"Square payment error: {exception.Message}."; if (exception is ApiException apiException) errorMessage = $"{errorMessage} Details: {apiException.ErrorCode} - {apiException.ErrorContent}"; //log errors _logger.Error(errorMessage, exception, _workContext.CurrentCustomer); return false; } }
/// <summary> /// Charge transaction /// </summary> /// <param name="chargeRequest">Request parameters to charge transaction</param> /// <returns>Transaction</returns> public Transaction Charge(ChargeRequest chargeRequest) { try { //try to get the selected location var selectedLocation = GetActiveLocations().FirstOrDefault(location => location.Id.Equals(_squarePaymentSettings.LocationId)); if (selectedLocation == null) throw new NopException("Location is a required parameter for payment requests"); //create transaction API var configuration = CreateApiConfiguration(); var transactionsApi = new TransactionsApi(configuration); //create charge transaction var chargeResponse = transactionsApi.Charge(selectedLocation.Id, chargeRequest); if (chargeResponse == null) throw new NopException("No service response"); //check whether there are errors in the service response if (chargeResponse.Errors?.Any() ?? false) { var errorsMessage = string.Join(";", chargeResponse.Errors.Select(error => error.ToString())); throw new NopException($"There are errors in the service response. {errorsMessage}"); } return chargeResponse.Transaction; } catch (Exception exception) { var errorMessage = $"Square payment error: {exception.Message}."; if (exception is ApiException apiException) errorMessage = $"{errorMessage} Details: {apiException.ErrorCode} - {apiException.ErrorContent}"; //log errors _logger.Error(errorMessage, exception, _workContext.CurrentCustomer); return null; } }
private void btnSpendByPayee_Click(object sender, System.EventArgs e) { var payeesApi = new PayeesApi(); var payees = payeesApi.GetPayees(_selectedBudget.Id); List <PaidPerPayeeModel> models = new List <PaidPerPayeeModel>(); TransactionsApi transactionApi = new TransactionsApi(); foreach (var payee in payees.Data.Payees) { PaidPerPayeeModel newModel = new PaidPerPayeeModel(); var transactions = transactionApi.GetTransactionsByPayee(_selectedBudget.Id, payee.Id, null, string.Empty); newModel.Name = payee.Name; foreach (var transaction in transactions.Data.Transactions) { double transAsDecimal = Convert.ToDouble(transaction.Amount) / 1000; if (transaction.Amount != null) { newModel.TotalSpend += transAsDecimal; } } models.Add(newModel); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"test.csv")) { file.WriteLine($"\"Name\";\"Total Spend\""); foreach (var model in models) { if (model.TotalSpend >= 0 || model.Name.StartsWith("Transfer :")) { continue; } file.WriteLine($"\"{model.Name}\";\"{model.TotalSpend}\""); } } }
/// <summary> /// Initializes a new instance of the <see cref="ParasutClient"/> class. /// </summary> /// <param name="url">The url<see cref="string"/>.</param> /// <param name="version">The version<see cref="string"/>.</param> /// <param name="companyId">The companyId<see cref="string"/>.</param> /// <param name="clientId">The clientId<see cref="string"/>.</param> /// <param name="clientSecret">The clientSecret<see cref="string"/>.</param> /// <param name="username">The username<see cref="string"/>.</param> /// <param name="password">The password<see cref="string"/>.</param> public ParasutClient(string url = null, string version = null, string companyId = null, string clientId = null, string clientSecret = null, string username = null, string password = null) : base() { Url = ParasutApiSettings.Url(url); Version = ParasutApiSettings.Version(version); CompanyId = ParasutApiSettings.CompanyId(companyId); ClientId = ParasutApiSettings.ClientId(clientId); ClientSecret = ParasutApiSettings.ClientSecret(clientSecret); Username = ParasutApiSettings.Username(username); Password = ParasutApiSettings.Password(password); GenerateConfiguration(); Home = new ApiHomeApi(Configuration); ItemCategories = new ItemCategoriesApi(Configuration); Accounts = new AccountsApi(Configuration); BankFees = new BankFeesApi(Configuration); Contacts = new ContactsApi(Configuration); EArchives = new EArchivesApi(Configuration); EInvoiceInboxes = new EInvoiceInboxesApi(Configuration); EInvoices = new EInvoicesApi(Configuration); Employees = new EmployeesApi(Configuration); Products = new ProductsApi(Configuration); PurchaseBills = new PurchaseBillsApi(Configuration); Salaries = new SalariesApi(Configuration); SalesInvoices = new SalesInvoicesApi(Configuration); Tags = new TagsApi(Configuration); Taxes = new TaxesApi(Configuration); TrackableJobs = new TrackableJobsApi(Configuration); Transactions = new TransactionsApi(Configuration); }
static Transaction GetTransactionFromExternalId(Configuration configuration) { // Please see https://docs.transferzero.com/docs/transaction-flow/#external-id // for more details on external IDs TransactionsApi transactionsApi = new TransactionsApi(configuration); String externalId = "TRANSACTION-00001"; TransactionListResponse transactionListResponse = transactionsApi.GetTransactions(externalId: externalId); if (transactionListResponse.Object.Count > 0) { System.Console.WriteLine("Transaction found"); Transaction result = transactionListResponse.Object[0]; System.Console.WriteLine(result); return(result); } else { System.Console.WriteLine("Transaction not found"); return(null); } }