2Service Services API

<back to all web services

Authenticate

The following routes are available for this service:
POST/dealers/authenticateAuthenticate with user name and password. Returns session token. Note: the token expires after 5 minutes of inactivity.
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 AuthenticateResult:
    # @ApiMember(Description="Session token to use in successive calls to the services.", ParameterType="model")
    session_token: Optional[str] = None
    """
    Session token to use in successive calls to the services.
    """


@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 AuthenticateResponse(OperationResult1[AuthenticateResult]):
    pass


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Authenticate:
    # @ApiMember(Description="User name for your account.", IsRequired=true, ParameterType="query")
    user_name: Optional[str] = None
    """
    User name for your account.
    """


    # @ApiMember(Description="Password provided by your supplier.", IsRequired=true, ParameterType="query")
    password: Optional[str] = None
    """
    Password provided by your supplier.
    """

Python Authenticate DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /dealers/authenticate HTTP/1.1 
Host: services.acct.2service.nl 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<Authenticate xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel.Dealers">
  <Password>String</Password>
  <UserName>String</UserName>
</Authenticate>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<AuthenticateResponse 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:SessionToken>String</d2p1:SessionToken>
  </Result>
</AuthenticateResponse>