namaggarwal / splitwise

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

Suddenly cannot create new expenses? #76

Closed SantoSimone closed 1 year ago

SantoSimone commented 1 year ago

Hi, first of all thanks for your work! I am using this sdk for a while now, but suddenly it seems to be broken only when I need to create a new expense. I am attaching a sample script.

import splitwise
from secrets import SPLITWISE

sw_instance = splitwise.Splitwise(
    consumer_key=SPLITWISE["consumer_key"],
    consumer_secret=SPLITWISE["consumer_secret"],
    api_key=SPLITWISE["api_key"]
)
my_user = sw_instance.getCurrentUser()

exp = splitwise.Expense()
exp.setGroupId(SPLITWISE["group_id"])
exp.setCategory(sw_instance.getCategories()[0])
exp.setDescription("Test")
exp.setCost("6.00")
user0_exp = splitwise.expense.ExpenseUser()
user0_exp.setId(SPLITWISE["user0_id"])
user1_exp = splitwise.expense.ExpenseUser()
user1_exp.setId(SPLITWISE["user1_id"])
user0_exp.setPaidShare("6.00")
user1_exp.setPaidShare('0.00')

exp.setUsers([user0_exp, user1_exp])
try:
    nExpense, errors = sw_instance.createExpense(exp)
except:
    import traceback
    traceback.print_exc()

This prints out the following (coming from traceback obviously).

Traceback (most recent call last):
  File ".../tmp.py", line 25, in <module>
    nExpense, errors = split_instance.createExpense(exp)
  File ".../lib/python3.9/site-packages/splitwise/__init__.py", line 561, in createExpense
    content = self.__makeRequest(
  File ".../lib/python3.9/site-packages/splitwise/__init__.py", line 291, in __makeRequest
    raise SplitwiseBadRequestException("Please check your request", response=response)

Am I missing something?

jpconfessor commented 1 year ago

Same problem here... using latest version (2.4.0) and python 3.10.


...\splitwise\__init__.py", line 561, in createExpense
    content = self.__makeRequest(
...\splitwise\__init__.py", line 291, in __makeRequest
    raise SplitwiseBadRequestException("Please check your request", response=response)
splitwise.exception.SplitwiseBadRequestException: Please check your request```
jpconfessor commented 1 year ago

After applying the changes in this commit, everything came back to normal: https://github.com/namaggarwal/splitwise/pull/77/commits/1f90b5433803d56c0d0767e5203447c7bc9dee0c

I hope this pull request gets approved soon! ;)

namaggarwal commented 1 year ago

Thanks, Merged and released a new version