Skip to content

Conversation

@gbp
Copy link

@gbp gbp commented Oct 9, 2023

I'm wanting to be able to respond programmatically to event invites but there are some missing endpoints in your library. I have added what is required in this PR.

Note while this is working for me I don't use Python often so if you want to merge this please review the code. I'm happy to make any changes required.

gbp added 3 commits October 9, 2023 13:24
Useful for retrieving events without a response.
Return details of the user currently logged in.
```
    s = spond.Spond(username=username, password=password)
    events = await s.get_events(response="unanswered")
    await s.update_event_response(event[0]["id"], accepted=True)
    await s.clientsession.close()
```
@elliot-100 elliot-100 requested a review from Olen November 21, 2023 21:50
event = await self.get_event(uid)

membershipId = None
members = event["recipients"]["group"]["members"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a similar test also needed in other functions?
Seems like it might be a good idea maybe?
And if so - it should probably be abstracted out to a separate function?

What do you think @elliot-100 ?

Copy link
Collaborator

@elliot-100 elliot-100 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raise exception if the current user isn't a member of the event's group?

It makes sense that you can't respond to an event if you're not in its group - the event isn't available for you to attend. It's needed because you may or may not be able to read it anyway, depending on visibility settings.

I guess there are other 'write' cases where this should be checked but I'm not really familiar with them. Which ones do you think?

Uses `scheduled` API parameter.
response : str, optional
Only include events which this response. Valid known options are:
`unanswered`, there may be more.
Copy link
Collaborator

@elliot-100 elliot-100 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should read "Only include events with this response from the authenticated user ...", to make it clearer that this parameter (unlike the others) is not intrinsic to the event itself.

self.chat_url = result["url"]
self.auth = result["auth"]

async def get_profile(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the function name get_profile() should be get_current_profile() or similar, as the former sounds like a general purpose function to read an arbitrary item, like get_event(), get_group(), etc.

@elliot-100 elliot-100 marked this pull request as draft November 23, 2023 12:18
@elliot-100 elliot-100 added the enhancement New feature or request label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants