Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions digikey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
manufacturer_product_details)
from digikey.v3.api import (status_salesorder_id, salesorder_history)
from digikey.v3.api import (batch_product_details)
from digikey.v3.api import (get_orders, accept_order_lines_by_order_id, ship_order, update_supplier_invoice_number)

name = 'digikey'
56 changes: 48 additions & 8 deletions digikey/v3/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
from distutils.util import strtobool
import digikey.oauth.oauth2
from digikey.exceptions import DigikeyError
from digikey.v3.productinformation import (KeywordSearchRequest, KeywordSearchResponse, ProductDetails, DigiReelPricing,
from digikey.v3.productinformation import (KeywordSearchRequest, KeywordSearchResponse, ProductDetails, DigiReelPricingDto,
ManufacturerProductDetailsRequest)
from digikey.v3.productinformation.rest import ApiException
from digikey.v3.ordersupport import (OrderStatusResponse, SalesOrderHistoryItem)
from digikey.v3.batchproductdetails import (BatchProductDetailsRequest, BatchProductDetailsResponse)
from digikey.v3.marketplace import (GetOrdersPage,Order,AcceptOrderDetailErrorsPage,AcceptOrderDetailsCommandBody,ShipOrderModel)

logger = logging.getLogger(__name__)

Expand All @@ -17,15 +18,17 @@ def __init__(self, wrapped_function, module):
self.sandbox = False

apinames = {
digikey.v3.productinformation: 'Search',
digikey.v3.ordersupport: 'OrderDetails',
digikey.v3.batchproductdetails: 'BatchSearch'
digikey.v3.productinformation: 'Search/v3',
digikey.v3.ordersupport: 'OrderDetails/v3',
digikey.v3.batchproductdetails: 'BatchSearch/v3',
digikey.v3.marketplace: 'Sales/Marketplace2/Orders/v1'
}

apiclasses = {
digikey.v3.productinformation: digikey.v3.productinformation.PartSearchApi,
digikey.v3.ordersupport: digikey.v3.ordersupport.OrderDetailsApi,
digikey.v3.batchproductdetails: digikey.v3.batchproductdetails.BatchSearchApi
digikey.v3.batchproductdetails: digikey.v3.batchproductdetails.BatchSearchApi,
digikey.v3.marketplace: digikey.v3.marketplace.OrdersApi
}

apiname = apinames[module]
Expand All @@ -40,10 +43,10 @@ def __init__(self, wrapped_function, module):
raise DigikeyError('Please provide a valid DIGIKEY_CLIENT_ID and DIGIKEY_CLIENT_SECRET in your env setup')

# Use normal API by default, if DIGIKEY_CLIENT_SANDBOX is True use sandbox API
configuration.host = 'https://api.digikey.com/' + apiname + '/v3'
configuration.host = 'https://api.digikey.com/' + apiname
try:
if bool(strtobool(os.getenv('DIGIKEY_CLIENT_SANDBOX'))):
configuration.host = 'https://sandbox-api.digikey.com/' + apiname + '/v3'
configuration.host = 'https://sandbox-api.digikey.com/' + apiname
self.sandbox = True
except (ValueError, AttributeError):
pass
Expand Down Expand Up @@ -125,7 +128,7 @@ def product_details(*args, **kwargs) -> ProductDetails:
return client.call_api_function(*args, **kwargs)


def digi_reel_pricing(*args, **kwargs) -> DigiReelPricing:
def digi_reel_pricing(*args, **kwargs) -> DigiReelPricingDto:
client = DigikeyApiWrapper('digi_reel_pricing_with_http_info', digikey.v3.productinformation)

if len(args):
Expand Down Expand Up @@ -179,3 +182,40 @@ def batch_product_details(*args, **kwargs) -> BatchProductDetailsResponse:
return client.call_api_function(*args, **kwargs)
else:
raise DigikeyError('Please provide a valid BatchProductDetailsRequest argument')


def get_orders(*args, **kwargs) -> GetOrdersPage:
client = DigikeyApiWrapper('get_orders_with_http_info', digikey.v3.marketplace)

if len(args) == 0:
logger.debug('CALL -> get_orders')
return client.call_api_function(*args, **kwargs)


def accept_order_lines_by_order_id(*args, **kwargs) -> AcceptOrderDetailErrorsPage:
client = DigikeyApiWrapper('accept_order_lines_by_order_id_with_http_info', digikey.v3.marketplace)

if 'body' in kwargs and type(kwargs['body']) == AcceptOrderDetailsCommandBody:
logger.debug('CALL -> accept_order_lines_by_order_id')
return client.call_api_function(*args, **kwargs)
else:
raise DigikeyError('Please provide a valid AcceptOrderDetailsCommandBody argument')


def ship_order(*args, **kwargs) -> Order:
client = DigikeyApiWrapper('ship_order_with_http_info', digikey.v3.marketplace)

if 'body' in kwargs and type(kwargs['body']) == ShipOrderModel:
logger.debug('CALL -> ship_order')
return client.call_api_function(*args, **kwargs)
else:
raise DigikeyError('Please provide a valid ShipOrderModel argument')


def update_supplier_invoice_number(*args, **kwargs) -> Order:
client = DigikeyApiWrapper('update_supplier_invoice_number_with_http_info', digikey.v3.marketplace)

if len(args):
logger.info(f'Get order for ID: {args[0]}')
return client.call_api_function(*args, **kwargs)

52 changes: 52 additions & 0 deletions digikey/v3/marketplace/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# coding: utf-8

# flake8: noqa

"""
Orders

API operations for managing orders as well as refunds and incidents as they relate to the order # noqa: E501

OpenAPI spec version: suppliers-v1
Contact: MarketplaceAPISupport@digikey.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

# import apis into sdk package
from digikey.v3.marketplace.api.health_check_api import HealthCheckApi
from digikey.v3.marketplace.api.orders_api import OrdersApi

# import ApiClient
from digikey.v3.marketplace.api_client import ApiClient
from digikey.v3.marketplace.configuration import Configuration
# import models into sdk package
from digikey.v3.marketplace.models.accept_order_detail_error_result import AcceptOrderDetailErrorResult
from digikey.v3.marketplace.models.accept_order_detail_errors_page import AcceptOrderDetailErrorsPage
from digikey.v3.marketplace.models.accept_order_detail_model import AcceptOrderDetailModel
from digikey.v3.marketplace.models.accept_order_details_command_body import AcceptOrderDetailsCommandBody
from digikey.v3.marketplace.models.additional_field import AdditionalField
from digikey.v3.marketplace.models.cancel_order_detail_error_result import CancelOrderDetailErrorResult
from digikey.v3.marketplace.models.cancel_order_detail_errors_page import CancelOrderDetailErrorsPage
from digikey.v3.marketplace.models.cancel_order_detail_model import CancelOrderDetailModel
from digikey.v3.marketplace.models.cancel_order_details_command_body import CancelOrderDetailsCommandBody
from digikey.v3.marketplace.models.contact_info import ContactInfo
from digikey.v3.marketplace.models.customer import Customer
from digikey.v3.marketplace.models.get_orders_page import GetOrdersPage
from digikey.v3.marketplace.models.health_check_response import HealthCheckResponse
from digikey.v3.marketplace.models.order import Order
from digikey.v3.marketplace.models.order_cancellation import OrderCancellation
from digikey.v3.marketplace.models.order_detail import OrderDetail
from digikey.v3.marketplace.models.order_expanded import OrderExpanded
from digikey.v3.marketplace.models.order_incident import OrderIncident
from digikey.v3.marketplace.models.order_refund import OrderRefund
from digikey.v3.marketplace.models.order_refund_item import OrderRefundItem
from digikey.v3.marketplace.models.problem_details import ProblemDetails
from digikey.v3.marketplace.models.ship_order_model import ShipOrderModel
from digikey.v3.marketplace.models.shipping_tracking_info import ShippingTrackingInfo
from digikey.v3.marketplace.models.shipping_tracking_information_model import ShippingTrackingInformationModel
from digikey.v3.marketplace.models.update_order_additional_fields_command_body import UpdateOrderAdditionalFieldsCommandBody
from digikey.v3.marketplace.models.update_order_additional_fields_error_result import UpdateOrderAdditionalFieldsErrorResult
from digikey.v3.marketplace.models.update_order_additional_fields_errors_page import UpdateOrderAdditionalFieldsErrorsPage
7 changes: 7 additions & 0 deletions digikey/v3/marketplace/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import absolute_import

# flake8: noqa

# import apis into api package
from digikey.v3.marketplace.api.health_check_api import HealthCheckApi
from digikey.v3.marketplace.api.orders_api import OrdersApi
119 changes: 119 additions & 0 deletions digikey/v3/marketplace/api/health_check_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# coding: utf-8

"""
Orders

API operations for managing orders as well as refunds and incidents as they relate to the order # noqa: E501

OpenAPI spec version: suppliers-v1
Contact: MarketplaceAPISupport@digikey.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import re # noqa: F401

# python 2 and python 3 compatibility library
import six

from digikey.v3.marketplace.api_client import ApiClient


class HealthCheckApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.

Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""

def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client

def get_health_check(self, **kwargs): # noqa: E501
"""Get health status of the API # noqa: E501

This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_health_check(async_req=True)
>>> result = thread.get()

:param async_req bool
:return: HealthCheckResponse
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.get_health_check_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_health_check_with_http_info(**kwargs) # noqa: E501
return data

def get_health_check_with_http_info(self, **kwargs): # noqa: E501
"""Get health status of the API # noqa: E501

This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_health_check_with_http_info(async_req=True)
>>> result = thread.get()

:param async_req bool
:return: HealthCheckResponse
If the method is called asynchronously,
returns the request thread.
"""

all_params = [] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')

params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_health_check" % key
)
params[key] = val
del params['kwargs']

collection_formats = {}

path_params = {}

query_params = []

header_params = {}

form_params = []
local_var_files = {}

body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501

# Authentication setting
auth_settings = ['apiKeySecurity', 'oauth2AccessCodeSecurity'] # noqa: E501

return self.api_client.call_api(
'/healthcheck', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='HealthCheckResponse', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
Loading