Skip to content

Commit

Permalink
Test DK API #2
Browse files Browse the repository at this point in the history
  • Loading branch information
eeintech committed Dec 29, 2024
1 parent 60be33a commit a60aa2c
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions kintree/search/digikey_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def setup_environment(force=False) -> bool:
os.environ['DIGIKEY_LOCAL_SITE'] = digikey_api_settings.get('DIGIKEY_LOCAL_SITE', 'US')
os.environ['DIGIKEY_LOCAL_LANGUAGE'] = digikey_api_settings.get('DIGIKEY_LOCAL_LANGUAGE', 'en')
os.environ['DIGIKEY_LOCAL_CURRENCY'] = digikey_api_settings.get('DIGIKEY_LOCAL_CURRENCY', 'USD')
print(os.environ)
return check_environment()


Expand Down Expand Up @@ -112,27 +111,6 @@ def digikey_search_timeout():
x_digikey_locale_currency=os.environ['DIGIKEY_LOCAL_CURRENCY'],
).to_dict()

# THIS METHOD WILL NOT WORK WITH DIGI-KEY PART NUMBERS...
# @timeout(dec_timeout=20)
# def digikey_search_timeout():
# from digikey.v3.productinformation.models.manufacturer_product_details_request import ManufacturerProductDetailsRequest
# # Set parametric filter for Cut Tape
# parametric_filters = {
# "ParameterId": 7,
# "ValueId": "2",
# }
# # Create search request body
# # TODO: record_count and filters parameter do not seem to work as intended
# search_request = ManufacturerProductDetailsRequest(manufacturer_product=part_number, record_count=1, filters=parametric_filters)
# # Run search
# manufacturer_product_details = digikey.manufacturer_product_details(body=search_request).to_dict()
# from ..common.tools import cprint
# print(f'length of response = {len(manufacturer_product_details.get("product_details", None))}')
# if type(manufacturer_product_details.get('product_details', None)) == list:
# # Return the first item only
# return manufacturer_product_details.get('product_details', None)[0]
# else:
# return {}
# Method to process price breaks
def process_price_break(product_variation):
part_info['digi_key_part_number'] = product_variation.get(digi_number_key)
Expand Down Expand Up @@ -225,8 +203,6 @@ def process_price_break(product_variation):

def test_api(check_content=False) -> bool:
''' Test method for API token '''
setup_environment()

test_success = True
expected = {
'product_description': 'RES 10K OHM 5% 1/16W 0402',
Expand All @@ -239,6 +215,7 @@ def test_api(check_content=False) -> bool:
}

test_part = fetch_part_info('RMCF0402JT10K0')
print(f'{test_part=}')

# Check for response
if not test_part:
Expand Down

0 comments on commit a60aa2c

Please sign in to comment.