You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added docs to create a custom config class. Updated README.md to reflect new changes. Added the configurations to __init__ for importing digikey. Minor message fix
result =digikey.keyword_search(body=search_request)
53
+
result =dk_api.keyword_search(body=search_request)
58
54
```
59
55
60
-
## Logging [API V3]
61
-
Logging is not forced upon the user but can be enabled according to convention:
62
-
```python
63
-
import logging
64
-
65
-
logger = logging.getLogger(__name__)
66
-
logger.setLevel(logging.DEBUG)
67
-
68
-
digikey_logger = logging.getLogger('digikey')
69
-
digikey_logger.setLevel(logging.DEBUG)
70
-
71
-
handler = logging.StreamHandler()
72
-
handler.setLevel(logging.DEBUG)
73
-
logger.addHandler(handler)
74
-
digikey_logger.addHandler(handler)
75
-
```
56
+
## API Configuration Storage
57
+
`DigikeyAPI` requires a configuration class that will handle getting, storing, and saving key-value pairs. Currently
58
+
only `DigikeyJsonConfig` is implemented for storing settings in a JSON file, but a custom configuration can be created.
59
+
See [docs/DigikeyBaseConfig.md](docs/DigikeyBaseConfig.md) for more details on that.
76
60
77
61
## Top-level APIs
78
62
79
63
#### Product Information
80
64
All functions from the [PartSearch](https://developer.digikey.com/products/product-information/partsearch/) API have been implemented.
81
-
*`digikey.keyword_search()`
82
-
*`digikey.product_details()`
83
-
*`digikey.digi_reel_pricing()`
84
-
*`digikey.suggested_parts()`
85
-
*`digikey.manufacturer_product_details()`
65
+
*`DigikeyAPI.keyword_search()`
66
+
*`DigikeyAPI.product_details()`
67
+
*`DigikeyAPI.digi_reel_pricing()`
68
+
*`DigikeyAPI.suggested_parts()`
69
+
*`DigikeyAPI.manufacturer_product_details()`
86
70
87
71
#### Batch Product Details
88
72
The one function from the [BatchProductDetailsAPI](https://developer.digikey.com/products/batch-productdetails/batchproductdetailsapi) API has been implemented.
89
-
*`digikey.batch_product_details()`
73
+
*`DigikeyAPI.batch_product_details()`
90
74
91
75
#### Order Support
92
76
All functions from the [OrderDetails](https://developer.digikey.com/products/order-support/orderdetails/) API have been implemented.
93
-
*`digikey.salesorder_history()`
94
-
*`digikey.status_salesorder_id()`
77
+
*`DigikeyAPI.salesorder_history()`
78
+
*`DigikeyAPI.status_salesorder_id()`
95
79
96
80
#### Barcode
97
81
TODO
@@ -103,7 +87,7 @@ It is possible to retrieve the number of max requests and current requests by pa
The `DigikeyAPI` class of the V3 API must be given a configuration class as one of it's arguments.
4
+
The purpose of this configuration class is to determine how the API will store some settings like the client-id, client-secret, and other stuff.
5
+
6
+
As of right now, there is only 1 available configuration class which is `DigikeyJsonConfig`. Of course you can create your own configurator class and input that into `DigikeyAPI`, for example if you want the API to store it's configuration in a database.
7
+
8
+
## DigikeyJsonConfig
9
+
10
+
This configuration classes stores the API settings in a JSON file. When initializing this class, a file name/path must be given.
You can create your own storage configurator as mentioned to define how to store the API's settings. The `DigikeyBaseConfig` class can be inherited to create it. You must override and define 3 functions:
22
+
23
+
- save(self): This function gets called when the API wants to save the settings.
24
+
- get(self, key: str): This function gets called when the API wants to retrieve a value for a given key. Return `None` if it doesn't exist
25
+
- set(self, key: str, val: str): This function gets called when the API wants to store a value for a given key.
26
+
27
+
As an example, this is how `DigikeyJsonConfig` is implemented:
0 commit comments