| GET | /dealers/part/{PartId} | Retrieves part info based on part id. |
|---|
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 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 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 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 PartInfoResponse(OperationResult1[PartInfoResult]):
pass
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class GetPartInfoById(AuthenticatedRequest):
# @ApiMember(Description="Part id to retrieve info for.", IsRequired=true, ParameterType="path")
part_id: int = 0
"""
Part id to retrieve info for.
"""
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /dealers/part/{PartId} HTTP/1.1
Host: services.acct.2service.nl
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
IsSuccessful: False,
ErrorMessage: String
}