narthur/pyminder

Consider adding to the readme an example of using API modifying goal

matkoniecz opened this issue · 0 comments

Currently it is not obvious to me how to do this using this library

I found

def update_goal(self, goal_name, slug=None, title=None, yaxis=None, secret=None,
that allows to do this with some subset of parameters.

    pyminder = Pyminder(user='[your username - dummy field]', token=token())
    pyminder._beeminder.update_goal("ping_babcia", title="ping_babcia_description")

works, but is using internal _ prefixed things.

And to edit arbitrary parameters following terribleness works, but I hope for something nicer.

    pyminder = Pyminder(user='[your username - dummy field]', token=token())
    #pyminder._beeminder.update_goal("ping_babcia", title="ping_babcia_description")
    goal_name = "ping_babcia"
    endpoint = f'users/{pyminder._beeminder._user}/goals/{goal_name}.json'
    data = {"fineprint": "test fineprint", "title": "ping_babcia_description"}
    pyminder._beeminder._call(endpoint, data=data, method="PUT")

And thanks for a publishing this library, it saved me some time that would be needed to write it on my own!