| GET | /dealers/parts | Retrieves part info based on multiple part numbers. |
|---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
Object = TypeVar('Object')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AuthenticatedRequest:
# @ApiMember(Description="Session token received from successful authentication.", IsRequired=true, ParameterType="query")
session_token: Optional[str] = None
"""
Session token received from successful authentication.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class OperationResult:
# @ApiMember(Description="Specifies if the operation was successful.", ParameterType="model")
is_successful: bool = False
"""
Specifies if the operation was successful.
"""
# @ApiMember(Description="States error message in case of unsuccessful operation.", ParameterType="model")
error_message: Optional[str] = None
"""
States error message in case of unsuccessful operation.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PartInfoResultImage:
# @ApiMember(Description="Image number")
image_number: int = 0
"""
Image number
"""
# @ApiMember(Description="Image URL")
image_url: Optional[str] = None
"""
Image URL
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PartStockQuantity:
# @ApiMember(Description="Location ID")
location_id: int = 0
"""
Location ID
"""
# @ApiMember(Description="Location code")
location_code: Optional[str] = None
"""
Location code
"""
# @ApiMember(Description="Stock quantity in location")
stock_quantity: int = 0
"""
Stock quantity in location
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PartInfoResult:
# @ApiMember(Description="Unique ID for the part.")
id: int = 0
"""
Unique ID for the part.
"""
# @ApiMember(Description="Part number.")
part_number: Optional[str] = None
"""
Part number.
"""
# @ApiMember(Description="Description of the part.")
description: Optional[str] = None
"""
Description of the part.
"""
# @ApiMember(Description="Part manufacturer.")
manufacturer: Optional[str] = None
"""
Part manufacturer.
"""
# @ApiMember(Description="Determines if the part can be ordered.")
can_be_ordered: bool = False
"""
Determines if the part can be ordered.
"""
# @ApiMember(Description="Textual representation of the status of the part.")
status_text: Optional[str] = None
"""
Textual representation of the status of the part.
"""
# @ApiMember(Description="Available stock to order.")
available_stock_quantity: int = 0
"""
Available stock to order.
"""
# @ApiMember(Description="Average days needed for delivery.")
average_delivery_in_days: Optional[int] = None
"""
Average days needed for delivery.
"""
# @ApiMember(Description="Price of a single unit, excluding VAT.")
unit_price: Optional[Decimal] = None
"""
Price of a single unit, excluding VAT.
"""
# @ApiMember(Description="EAN number.")
ean_number: Optional[str] = None
"""
EAN number.
"""
# @ApiMember(Description="Images")
images: Optional[List[PartInfoResultImage]] = None
"""
Images
"""
# @ApiMember(Description="Secondary article numbers")
secondary_article_numbers: Optional[List[str]] = None
"""
Secondary article numbers
"""
# @ApiMember(Description="Replacement article numbers")
replacement_article_numbers: Optional[List[str]] = None
"""
Replacement article numbers
"""
# @ApiMember(Description="Stock quantities")
stock_quantities: Optional[List[PartStockQuantity]] = None
"""
Stock quantities
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PartResults:
# @ApiMember(Description="Total number of parts available.")
total_number_of_parts: int = 0
"""
Total number of parts available.
"""
# @ApiMember(Description="Indication if there are more parts to retrieve.")
has_more_records: bool = False
"""
Indication if there are more parts to retrieve.
"""
# @ApiMember(Description="Part records.")
parts: Optional[List[PartInfoResult]] = None
"""
Part records.
"""
T = TypeVar('T')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class OperationResult1(Generic[T], OperationResult):
# @ApiMember(Description="Result value", ParameterType="model")
result: Optional[PartResults] = None
"""
Result value
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class MultiplePartInfosResponse(OperationResult1[List[PartInfoResult]]):
unknown_parts: Optional[List[str]] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class GetMultiplePartInfos(AuthenticatedRequest):
# @ApiMember(Description="Multiple part numbers to retrieve info for.", IsRequired=true)
part_numbers: List[str] = field(default_factory=list)
"""
Multiple part numbers to retrieve info for.
"""
Python GetMultiplePartInfos DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /dealers/parts HTTP/1.1 Host: services.acct.2service.nl Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<MultiplePartInfosResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel.Dealers">
<ErrorMessage xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel">String</ErrorMessage>
<IsSuccessful xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel">false</IsSuccessful>
<Result xmlns:d2p1="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel.Dealers" xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel">
<d2p1:PartInfoResult i:nil="true" />
</Result>
<UnknownParts xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:string>String</d2p1:string>
</UnknownParts>
</MultiplePartInfosResponse>