Пример #1
0
    public static IEnumerator GetTransactionData(string accountNumber, System.Action <GetAccountFromUserInput> userData)
    {
        int    page = 1;
        int    maxPages;
        int    currentIndex = 0;
        string accountPage  = "http://" + username + ":" + password + "@" + "api.futurefinance.io/api/accounts/" + accountNumber + "/transactions/?page=" + page + "&sort=DESCENDING";
        WWW    accountData  = new WWW(accountPage);

        yield return(accountData);

        string jsonAccountData = accountData.text;

        TransactionsSpace.AccountTransactions allAccountData = JsonUtility.FromJson <TransactionsSpace.AccountTransactions>(jsonAccountData);
        thisUserData.Transactions = new GetTransactionData[allAccountData.total];

        maxPages = Mathf.CeilToInt((float)allAccountData.total / allAccountData.count);

        for (int i = 0; i < maxPages; i++)
        {
            accountPage = "http://" + username + ":" + password + "@" + "api.futurefinance.io/api/accounts/" + accountNumber + "/transactions/?page=" + page + "&sort=DESCENDING";
            accountData = new WWW(accountPage);
            yield return(accountData);

            jsonAccountData = accountData.text;
            allAccountData  = JsonUtility.FromJson <TransactionsSpace.AccountTransactions>(jsonAccountData);
            for (int x = 0; x < allAccountData.count; x++)
            {
                thisUserData.Transactions[currentIndex] = new GetTransactionData
                                                          (
                    allAccountData._embedded.transactions[x].id,
                    allAccountData._embedded.transactions[x].transactionDate,
                    allAccountData._embedded.transactions[x].transactionDateTimestamp,
                    allAccountData._embedded.transactions[x].merchantCategoryCode,
                    allAccountData._embedded.transactions[x].amount,
                    allAccountData._embedded.transactions[x].text,
                    allAccountData._embedded.transactions[x].alternativeText,
                    allAccountData._embedded.transactions[x].reconciled,
                    allAccountData._embedded.transactions[x].paymentMedia,
                    allAccountData._embedded.transactions[x].reserved
                                                          );
                currentIndex++;
            }
            page++;
        }
        userData(thisUserData);
    }
Пример #2
0
    IEnumerator FillTransactions()
    {
        int    page = 1;
        int    maxPages;
        int    currentIndex = 0;
        string accountPage  = "http://*****:*****@api.futurefinance.io/api/accounts/" + accountNumber + "/transactions/?page=" + page + "&sort=DESCENDING";
        WWW    accountData  = new WWW(accountPage);

        yield return(accountData);

        string jsonAccountData = accountData.text;

        TransactionsSpace.AccountTransactions allAccountData = JsonUtility.FromJson <TransactionsSpace.AccountTransactions>(jsonAccountData);
        transactions = new GetTransactionData[allAccountData.total];

        maxPages = Mathf.CeilToInt((float)allAccountData.total / allAccountData.count);
        //print(maxPages);

        for (int i = 0; i < maxPages; i++)
        {
            accountPage = "http://*****:*****@api.futurefinance.io/api/accounts/" + accountNumber + "/transactions/?page=" + page + "&sort=DESCENDING";
            accountData = new WWW(accountPage);
            yield return(accountData);

            jsonAccountData = accountData.text;
            allAccountData  = JsonUtility.FromJson <TransactionsSpace.AccountTransactions>(jsonAccountData);
            for (int x = 0; x < allAccountData.count; x++)
            {
                transactions[currentIndex] = new GetTransactionData
                                             (
                    allAccountData._embedded.transactions[x].transactionDateTimestamp,
                    allAccountData._embedded.transactions[x].amount,
                    allAccountData._embedded.transactions[x].transactionDate
                                             );
                currentIndex++;
            }
            page++;
            //print(page);
        }
        yield return(new WaitForSeconds(0.5f));

        dataSaved = true;
        string allTransaction = JsonUtility.ToJson(allAccountData);

        print(allTransaction);
    }
Пример #3
0
    IEnumerator GetAccountsData()
    {
        int    page = 1;
        int    maxPages;
        int    currentIndex = 0;
        string accountPage  = "http://" + username + ":" + password + "@" + "api.futurefinance.io/api/accounts/?page=" + page + "&sort=DESCENDING";
        //string accountPage = "http://"+username+":"+password+"@"+APIPage+"accounts/";
        WWW accountData = new WWW(accountPage);

        yield return(accountData);

        string jsonAccountData = accountData.text;

        AccountsSpace.BankAccounts allAcountData = JsonUtility.FromJson <AccountsSpace.BankAccounts>(jsonAccountData);

        userData = new GetUserData[allAcountData.total];
        maxPages = Mathf.CeilToInt((float)allAcountData.total / allAcountData.count);

        for (int i = 0; i < maxPages; i++)
        {
            accountPage = "http://" + username + ":" + password + "@" + "api.futurefinance.io/api/accounts/?page=" + page + "&sort=DESCENDING";
            accountData = new WWW(accountPage);
            yield return(accountData);

            jsonAccountData = accountData.text;
            allAcountData   = JsonUtility.FromJson <AccountsSpace.BankAccounts>(jsonAccountData);

            for (int x = 0; x < allAcountData.count; x++)
            {
                userData[currentIndex] = new GetUserData(allAcountData._embedded.accounts[x].accountNumber, allAcountData._embedded.accounts[x]._links.transactions.href);
            }

            for (int x = 0; x < allAcountData.count; x++)
            {
                string transactionsPage = "http://" + username + ":" + password + "@" + APIPage + "accounts/" + userData[x].AccountNumber + "/transactions/";
                WWW    transactionsData = new WWW(transactionsPage);
                yield return(transactionsData);

                string jsonTransactionData = transactionsData.text;
                TransactionsSpace.AccountTransactions allAcountTransactions = JsonUtility.FromJson <TransactionsSpace.AccountTransactions>(jsonTransactionData);

                string paymentAgreementPage = "http://" + username + ":" + password + "@" + APIPage + "accounts/" + userData[x].AccountNumber + "/paymentagreements/";
                WWW    paymentAgreementData = new WWW(paymentAgreementPage);
                yield return(paymentAgreementData);

                string jsonPaymentAgreementData = paymentAgreementData.text;
                AgreementsSpace.AccountPaymentAgreements allPaymentAgreeements = JsonUtility.FromJson <AgreementsSpace.AccountPaymentAgreements>(jsonPaymentAgreementData);

                userData[currentIndex] = new GetUserData(
                    allAcountData._embedded.accounts[x]._embedded.owner.firstname,
                    allAcountData._embedded.accounts[x]._embedded.owner.lastname,
                    allAcountData._embedded.accounts[x]._embedded.owner.customerNumber,
                    allAcountData._embedded.accounts[x].accountNumber,
                    allAcountData._embedded.accounts[x].coowners,
                    allAcountData._embedded.accounts[x].accountStatus,
                    allAcountData._embedded.accounts[x].balance,
                    allAcountData._embedded.accounts[x].creditMax,
                    allAcountData._embedded.accounts[x]._links.transactions.href,
                    allAcountData._embedded.accounts[x]._links.paymentagreements.href);
                //userData[currentIndex].CustomerTransactions = new GetTransactionData[allAcountTransactions.count];
                //userData[currentIndex].PaymentAgreements = new GetPaymentAgreementData[allPaymentAgreeements.count];

                /*for(int y = 0; y < allAcountTransactions.count; y++)
                 * {
                 *      userData[currentIndex].CustomerTransactions[y] = new GetTransactionData(
                 *              allAcountTransactions._embedded.transactions[y].id,
                 *              allAcountTransactions._embedded.transactions[y].transactionDate,
                 *              allAcountTransactions._embedded.transactions[y].transactionDateTimestamp,
                 *              allAcountTransactions._embedded.transactions[y].merchantCategoryCode,
                 *              allAcountTransactions._embedded.transactions[y].amount,
                 *              allAcountTransactions._embedded.transactions[y].text,
                 *              allAcountTransactions._embedded.transactions[y].alternativeText,
                 *              allAcountTransactions._embedded.transactions[y].reconciled,
                 *              allAcountTransactions._embedded.transactions[y].paymentMedia,
                 *              allAcountTransactions._embedded.transactions[y].reserved);
                 * }*/
                /*for(int z = 0; z < allPaymentAgreeements.count; z++)
                 * {
                 *      userData[currentIndex].PaymentAgreements[z] = new GetPaymentAgreementData(
                 *              allPaymentAgreeements._embedded.paymentAgreements[z].agreementNumber,
                 *              allPaymentAgreeements._embedded.paymentAgreements[z].text,
                 *              allPaymentAgreeements._embedded.paymentAgreements[z].pbsDebitGroup,
                 *              allPaymentAgreeements._embedded.paymentAgreements[z].pbsCreditorGroup,
                 *              allPaymentAgreeements._embedded.paymentAgreements[z].pbsCustomerNumber,
                 *              allPaymentAgreeements._embedded.paymentAgreements[z].status);
                 * }*/
                currentIndex++;
            }
            page++;
        }
    }