keenlabs / keen-sdk-net

A .NET SDK for the Keen IO API
MIT License
37 stars 24 forks source link

Create Access Key #76

Open masojus opened 7 years ago

IshamMohamed commented 6 years ago

I would like to participate in the Access Keys project

masojus commented 6 years ago

Hi @IshamMohamed, I could help with that. Have you started prototyping or thinking about a design at a high level? I'd love to hear what ideas you have.

masojus commented 6 years ago

Also, if you're looking for inspiration, you could look at the recent Python PR that added Access Keys and the ongoing PHP PR doing the same.

IshamMohamed commented 6 years ago

The Python create_access_key returns the JSON, so is it enough if we return the JSON or do you think we need to created objects?

IshamMohamed commented 6 years ago

I have created the model class for the Access Keys - https://github.com/IshamMohamed/keen-sdk-net/blob/master/Keen/AccessKey/AccessKey.cs would appreciate your feedback.

masojus commented 6 years ago

Thanks @IshamMohamed I will take a look.

masojus commented 6 years ago

I think the model is starting to look good. A few questions/comments:

IshamMohamed commented 6 years ago

Really useful comments and feedback. Agrees with all your comments. I am learning alot, and have started working on the changes.

masojus commented 6 years ago

Good to hear! Yeah if you have good reasons for any of your choices, please feel free to correct me. I've thought about this Access Keys stuff to some extent, but I'm glad someone is finally getting it done :)

Another question: Is there a reason for AccessKey.Permitted to be a List<> instead of some other collection type (e.g. set in this case)? List<> tends to imply ordering or wanting to be able to index into the collection, which is fine if that's what we want.

Also, FYI, you could see trouble where you're trying to deserialize to interface types, though, since without a specific JsonConverter, Json.net doesn't know what concrete type to deserialize to. (if the model is an interface, that is...maybe here it's fine since they're all concrete types.)

masojus commented 6 years ago

AccessKey.Permitted could really be an ISet<> since they should be unique. They'd still be an IEnumerable<> that way but would enforce uniqueness. Same thing for blocked and allowed since they really can't be duplicates and ordering doesn't matter.

IshamMohamed commented 6 years ago

Implemented the method and a unit test for testing success - https://github.com/IshamMohamed/keen-sdk-net/commit/3596593fe4eef37484e5e8d93a6eaa526f08d08b

masojus commented 6 years ago

Thanks @IshamMohamed I'll take a look probably later today.

masojus commented 6 years ago

Can you create a pull request when you're ready so we can review this here? I'd prefer to have the context.