tybug / ossapi

The definitive python wrapper for the osu! api.
https://tybug.github.io/ossapi/
GNU Affero General Public License v3.0
80 stars 17 forks source link

get-events endpoint #66

Closed yanda-dy closed 1 year ago

yanda-dy commented 1 year ago

Are there any plans to implement the (relatively new) get-events endpoint (https://osu.ppy.sh/docs/index.html#get-events)?

tybug commented 1 year ago

yup; done in https://github.com/circleguard/ossapi/commit/acf5ef9aeba5bedd4a3b53769b8ca5c982e95473. I'm pretty proud of ossapi's 100% endpoint coverage, so the answer to such questions is always "yes" 😄. Thanks for reminding me that endpoint was implemented.

yanda-dy commented 1 year ago

Just wondering if there are supposed to be two different fields for created_at/createdAt in Event https://github.com/circleguard/ossapi/blob/0b4f9425acfc13ec7729cb1a2e3206629c243c76/ossapi/models.py#L680C1-L684C20

tybug commented 1 year ago

yeah, createdAt is deprecated, and I match api pretty much 1:1. The right thing to do is not to serialize that field, but then tests fail because strict=True mode in ossapi requires all attributes returned by the api to be serialized into a model. I need to add a mechanism to explicitly mark certain fields as ignored so strict mode is satisfied, and then I'll remove fields like that.

yanda-dy commented 1 year ago

Sorry to bother you again, but how would I get the actual event data (e.g., achievement / user) instead of just the event type?

For instance, https://osu.ppy.sh/docs/index.html#get-events has the example response

{
  events: [
    {
      created_at: "2022-12-08T02:02:51+00:00",
      id: 57,
      type: "achievement",
      achievement: { ... },
      user: { ... }
    },
    ...
  ],
  cursor_string: "eyJldmVudF9pZCI6OH0"
}

Thanks!

tybug commented 1 year ago

bleh, I used the wrong model. should be _Event. I'll fix when I wake up.

tybug commented 1 year ago

This was a relatively involved change, as I had to add support for setting a deserialize type which differs from the runtime type (and the type provided to static type checkers and autocomplete tools).

Fixed by https://github.com/circleguard/ossapi/compare/f29586207904...a9bfe36a450b.