fmeringdal / nettu-scheduler

A self-hosted calendar and scheduler server.
MIT License
535 stars 27 forks source link

Inconsistency in SDK methods #31

Closed omid closed 3 years ago

omid commented 3 years ago

I just realized to delete a user, we need to pass ID but to delete a calendar we need to pass DeleteCalendarInput which contains one field for ID.

It's better to follow one pattern.

It can be there for all requests, delete/update/... and calendar/event/user/...

fmeringdal commented 3 years ago

Definitely. I think the pattern should be:

  1. All methods will have just one argument (This function violates this for example).
  2. If only one value is needed then use only simple argument with that value. For example: fn foo(&self, user_id: ID)
  3. If several values are needed then define a new type and use that as input. For examaple
    
    struct CreateCalendarInput {
    pub user_id: ID,
    pub timezone: String,
    ...
    }

fn create( &self, input: CreateCalendarInput, )

omid commented 3 years ago

I 100% agree with what you said.