Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api endpoints #21

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

Api endpoints #21

wants to merge 4 commits into from

Conversation

hershsa
Copy link

@hershsa hershsa commented Jan 3, 2019

Added switches to Get-YnabCategory, month and CategoryID to allow cmdlet to retrieve data from this API endpoint - /budgets/{budget_id}/months/{month}/categories/{category_id}

Also added to Jsonparse to include goal data in the single category portion.

ConnorGriffin and others added 4 commits July 28, 2018 03:36
v0.2.2 Release - Added Get-YnabTransaction
Added functionality for endpoint - /budgets/{budget_id}/months/{month}/categories/{category_id}

Expanded Get-YnabCategory to include -month and -categoryID to allow for single category by month. Returns single category.
@ConnorGriffin
Copy link
Owner

Alright I had a chance to look at this and have a couple of questions/issues, and would be interested in your input.

Month

You are defining $Month as an array of strings ([String[]]) but you are not iterating over it in the process block. I'm not sure how we would return the data to the user. We could add a 'Month' column to the data, but if they also request multiple categories it can get complicated. I believe we should split the data further into a Months section.

Month      Categories
-----      ----------
2018-12-01 {@{Category=Bank Rewards; Note=; Budgeted=0;...}}
2019-01-01 {@{Category=Bank Rewards; Note=; Budgeted=0;...}}

Alternatively we could add a Month header to the data:

Month    : 2016-12-01
Category : Natural Gas
Budged   :
Activity : -80.84
Balance  : 0

Month    : 2017-01-01
Category : Natural Gas
Budged   :
Activity : -52.14
Balance  : 0

Also your Month flag does not support returning data for multiple categories. Do you think there is value in being able to say, "Show me data for December and January for my Food, Fuel, and Leisure categories"? I'm not sure if it's worth the effort to add the functionality vs just implementing the API to spec.

CategoryID

When I first started building this module I included the ability to specify IDs as well as Names as identifiers for items like Budgets, Accounts, Categories, etc. This quickly became unmanageable with hundreds of branching parameter sets, trying to ensure that either an ID or Name is specified for every call. I eventually settled on making the Name a required field and dropping the IDs completely, instead performing lookups for IDs based on names. I understand this removes a bit of flexibility and also slows things down if you already have the ID on hand.

An alternative may be to use the Category parameter for both values, simply treating the value as an ID if it matches a certain regex pattern (^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$). I will have to implement this in every function call, but it might be worth it for speed and useability.

In the meantime I propose removing your CategoryID change and instead suggest we use the Category.

@ConnorGriffin
Copy link
Owner

I rewrote this to meet my own requirements on a branch called 'feat/CategoryMonth'. Let me know what you think.

> Get-YnabCategory -Category 'Work Food','Drinking','Electricity' -Month 2018-11-04,2018-12-01,(get-date) | select * -exclude CategoryID | ft -autosize

Month      Category    Note Budgeted Activity Balance Hidden
-----      --------    ---- -------- -------- ------- ------
2018-11-01 Work Food          152.12  -152.12       0  False
2018-12-01 Work Food            71.5    -71.5       0  False
2019-01-01 Work Food             125   -45.69   79.31  False
2018-11-01 Drinking               20        0      20  False
2018-12-01 Drinking               20        0      40  False
2019-01-01 Drinking               20   -94.63  -34.63  False
2018-11-01 Electricity           149     -149       0  False
2018-12-01 Electricity           149     -149       0  False
2019-01-01 Electricity          74.5        0    74.5  False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants