From e801bc38e6ef8746ea61dd2bc7fce59e3204049f Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 17 Aug 2019 02:36:43 -0400 Subject: add ability to actually update transactions --- src/ynab/client.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/ynab/client.rs') diff --git a/src/ynab/client.rs b/src/ynab/client.rs index 852481a..9467750 100644 --- a/src/ynab/client.rs +++ b/src/ynab/client.rs @@ -15,7 +15,7 @@ impl Client { } } - pub fn default_budget(&self) -> super::budget::Budget { + pub fn into_default_budget(self) -> super::budget::Budget { let budgets = self.api.budgets_api().get_budgets().unwrap().data.budgets; let budget = budgets.iter().next().unwrap(); @@ -26,6 +26,22 @@ impl Client { .unwrap() .data .budget; - super::budget::Budget::new(full_budget) + super::budget::Budget::new(self, full_budget) + } + + pub fn update_transactions( + &self, + budget_id: &str, + transactions: ynab_api::models::UpdateTransactionsWrapper, + ) -> Option { + let res = self + .api + .transactions_api() + .update_transactions(budget_id, transactions); + if let Err(e) = res { + Some(format!("{:?}", e)) + } else { + None + } } } -- cgit v1.2.3-54-g00ecf