namaggarwal / splitwise

Python SDK for Splitwise
MIT License
185 stars 46 forks source link

How do I set a category with expense.setCategory()? #26

Closed mileyvirus closed 4 years ago

mileyvirus commented 4 years ago

Whatever I tried just creates an expense but with the General category… "category":{"id":18,"name":"General"}

I suspect it's because you can't have nested parameters…

mileyvirus commented 4 years ago

Found the solution, I added expense_data["category_id"] = expense_data.pop("category") in createExpense before sending the expense_data and sure enough it works. So the correct name is category_id and when you create a new expense you just do expense.setCategory(5) where 5 is Electricity.

namaggarwal commented 4 years ago

I do need to update the documentation. Once done I will mark it as done

namaggarwal commented 4 years ago

So, I had a look at this. Unfortunately, this is a bug. Ideally you should be able to do this

cat = Category()
cat.setId(10)
expense.setCategory(cat)

and it should work

I am fixing this and it will be available in next release (this week)

namaggarwal commented 4 years ago

~Same goes for group and currency as well~

namaggarwal commented 4 years ago

This is fixed and available for use in version 1.2.0

mileyvirus commented 4 years ago

Great job, thanks!