digikey-api icon indicating copy to clipboard operation
digikey-api copied to clipboard

Add configuration storage class. Made DigikeyAPI into a class

Open Electro707 opened this issue 4 years ago • 6 comments

This PR adds a method of setting and saving this package's settings (like client-id and refresh-token) without needing to use OS environment variables. Main changes includes:

  • Added all API fucntions (for V3) under a DigikeyAPI class.
  • Added a configuration class which is fed into DigikeyAPI. This class includes all necessary functions to be able to save and get configurations. The parent class is DigikeyBaseConfig, which that one does nothing but outline what functions any child class must override. As of right now I've only 1 config storage method/kind under DigikeyJsonConfig, which stores and retrieves configurations in a JSON file.
  • Added the functions needs_client_id(), needs_client_secret(), and set_client_info() to allow the user to know if said info are needed and to be able to give them to this library.

TODO:

  • [x] Document DigikeyBaseConfig further to specify how a user can create their own (for example if someone wants to store said settings inside a database).
  • [x] Document the new changes to how to call up the API
  • [x] ~~Change V2's code to allow for the new configuration:~~
    • ~~Is this even worth it, or is it better to drop V2 support?~~
    • V2 support is dropped

Electro707 avatar May 31 '21 20:05 Electro707

This is an interesting proposition and I hope to see this being merged.

@peeter123 Any plan to review this soon?

@Electro707 Do you need help with testing?

eeintech avatar Jul 21 '21 14:07 eeintech

@eeintech Sure, just beware that A) This is not too well documented which is something I need to do, and B) Only works with V3 API. @peeter123 Is it even worth it to add support to v2 even tough it's deprecated by Digikey, or is it time to drop V2 support?

Electro707 avatar Aug 06 '21 05:08 Electro707

@peeter123 Any thoughts on the V2 API, if I should add this new config class to it or if it should be deprecated?

Electro707 avatar Sep 27 '21 00:09 Electro707

I will look into this, I think we can make a 1.0 version where we drop the V2 API completely. What do you think?

peeter123 avatar Nov 19 '21 20:11 peeter123

Could you rebase on development-1.0 branch in peeter123/digikey-api?

peeter123 avatar Nov 19 '21 21:11 peeter123

Rebasing is done.

Electro707 avatar Nov 22 '21 20:11 Electro707