Code Monkey home page Code Monkey logo

ynab-sdk-python's Issues

Mismapped Parameters When Pulling Categories from Budget Detail

If a category is access directly it works fine, however when pulling the categories from the Budget Detail endpoint the category.goal_type is mapped to the 'Note' endpoint.

In file
Iynab_sdk/api/models/responses/budget_detail.py

Lines: 87 - 89

       goal_type = parsers.from_union(
            [parsers.from_str, parsers.from_none], obj.get("note")
        )

Add CI

Stages:

  • Static Analysis (flake8, codeclimate)
  • Test
  • Coverage
  • Deploy to Pypi (Tags Only)

Scheduled Transactions

I really appreciate all the work that went into this. Thanks so much!

I think that Scheduled Transactions (future dates) aren't yet available based on what I read and what I can try to see digging into the code.

¿Is that right?

Looks like they're different from Transactions, though clearly similar.

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

get_budget fails with some split transactions in the budget

Hi!
I have some issue with the sdk and my budget.

Calling this code will raise an error:

from ynab_sdk import YNAB

try:
    api_key = "12312123.....123123"
    apicheck = YNAB(api_key)
    data = apicheck.budgets.get_budget("12345678-f349-410e-8ae8-d35672845374")
    print(repr(data.data.budget))
except Exception:
    raise

The response:

Traceback (most recent call last):
  File "/Users/andreas/Downloads/apitest.py", line 21, in <module>
    data = apicheck.budgets.get_budget("12345678-f349-410e-8ae8-d35672845374")
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/budgets.py", line 17, in get_budget
    return BudgetDetailResponse.from_dict(response)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/models/responses/budget_detail.py", line 505, in from_dict
    data = Data.from_dict(obj.get("data"))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/models/responses/budget_detail.py", line 493, in from_dict
    budget = Budget.from_dict(obj.get("budget"))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/models/responses/budget_detail.py", line 455, in from_dict
    subtransactions = parsers.from_list(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/utils/parsers.py", line 47, in from_list
    return [f(y) for y in x]
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/utils/parsers.py", line 47, in <listcomp>
    return [f(y) for y in x]
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/models/responses/budget_detail.py", line 276, in from_dict
    category_id = parsers.from_str(obj.get("category_id"))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/utils/parsers.py", line 16, in from_str
    raise ex
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/utils/parsers.py", line 11, in from_str
    assert isinstance(x, str)

I have a certain type of split transaction (mix of category and account) that is causing this issue (image attached):

Transaction: Payee TEST / Outflow: 100€
Split 1: Category RENT / Outflow: 50€
Split 2: Account CREDITCARD / Outflow: 50€

When I create this kind of transaction in a test budget, that is working otherwise, it fails. As soon as I delete it, the call is working fine.

Could you make your api handle this case? I am no programmer, so I cannot figure it myself and provide you with a pull request.

Thank you!
Andreas
Screenshot_2021-03-05 bla test YNAB

get_transactions_from_account function does not accept the available optional filter params since_date or type

Your get_transactions_from_account implementation doesnt take the params since_date or type, which are really helpful for filtering and speeding up things when you only need transactions from the last couple of weeks. See the official docs here: https://api.ynab.com/v1#/Transactions/getTransactions.

I do not have the time to do a proper PR so I simply extended the class in my project like this

from ynab_sdk.api.transactions import TransactionsApi
from ynab_sdk.api.transactions import TransactionsApi
from ynab_sdk.api.transactions import TransactionsResponse

class ExtendedTransactionsApi(TransactionsApi):
    def get_transactions_from_account(self, budget_id, since_date=None, type=None):
        params = {}
        if since_date:
            params['since_date'] = since_date
        if type:
            params['type'] = type

        return self.service.get(f'/budgets/{budget_id}/transactions', params)

def construct_url_with_params(base_url, params):
    if params:
        param_str = "&".join(f"{k}={v}" for k, v in params.items())
        return f"{base_url}?{param_str}"
    else:
        return base_url
    
class ExtendedTransactionsApi(TransactionsApi):
    def get_transactions_from_account(self, budget_id, account_id, since_date=None, type=None):
        params = {}
        if since_date:
            params['since_date'] = since_date
        if type:
            params['type'] = type

        url = construct_url_with_params(f'/budgets/{budget_id}/accounts/{account_id}/transactions', params)
        response = self.client.get(url)
        return TransactionsResponse.from_dict(response)
    
class ExtendedYNAB(YNAB):
    def __init__(self, token):
        super().__init__(token)
        self.extended_transactions = ExtendedTransactionsApi(self.transactions.client)

#ynab = YNAB(YNAB_API_KEY)
ynab = ExtendedYNAB(YNAB_API_KEY)

Now I can do this:

transactions = ynab.extended_transactions.get_transactions_from_account(budget_id=budget, account_id=account_dict['Savings'], since_date="2024-02-26", type="uncategorized")

Running Balance

It looks like Running Balance (available in the UI) isn't something that's in this API, likely because it seems not to be in the API spec.

¿Is that right?

Presuming so, then would the "right" way to do it be to grab the current account balance and then self-calculate it by going backwards in time using the transaction dates.

Esse projeto continua ativamente sendo mantido? 👀

Oi, tô considerando sair da minha implementação própria para me comunicar com a API do YNAB, mas para tomar essa decisão gostaria de saber se este projeto ainda está sendo mantido. @andreroggeri pode me responder essa? Se não eu poderia ajudar na manutenção também.

is there documentation?

where the module documentation? All I see is one "get_budgets()" example in the readme.md. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.