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 'package:servicestack/servicestack.dart';

class AuthenticateResult implements IConvertible
{
    /**
    * Session token to use in successive calls to the services.
    */
    // @ApiMember(Description="Session token to use in successive calls to the services.", ParameterType="model")
    String? SessionToken;

    AuthenticateResult({this.SessionToken});
    AuthenticateResult.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        SessionToken = json['SessionToken'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'SessionToken': SessionToken
    };

    getTypeName() => "AuthenticateResult";
    TypeContext? context = _ctx;
}

class OperationResult implements IConvertible
{
    /**
    * Specifies if the operation was successful.
    */
    // @ApiMember(Description="Specifies if the operation was successful.", ParameterType="model")
    bool? IsSuccessful;

    /**
    * States error message in case of unsuccessful operation.
    */
    // @ApiMember(Description="States error message in case of unsuccessful operation.", ParameterType="model")
    String? ErrorMessage;

    OperationResult({this.IsSuccessful,this.ErrorMessage});
    OperationResult.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        IsSuccessful = json['IsSuccessful'];
        ErrorMessage = json['ErrorMessage'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'IsSuccessful': IsSuccessful,
        'ErrorMessage': ErrorMessage
    };

    getTypeName() => "OperationResult";
    TypeContext? context = _ctx;
}

class PartInfoResultImage implements IConvertible
{
    /**
    * Image number
    */
    // @ApiMember(Description="Image number")
    int ImageNumber = 0;

    /**
    * Image URL
    */
    // @ApiMember(Description="Image URL")
    String? ImageUrl;

    PartInfoResultImage({this.ImageNumber=0,this.ImageUrl});
    PartInfoResultImage.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        ImageNumber = json['ImageNumber'] ?? 0;
        ImageUrl = json['ImageUrl'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'ImageNumber': ImageNumber,
        'ImageUrl': ImageUrl
    };

    getTypeName() => "PartInfoResultImage";
    TypeContext? context = _ctx;
}

class PartStockQuantity implements IConvertible
{
    /**
    * Location ID
    */
    // @ApiMember(Description="Location ID")
    int LocationId = 0;

    /**
    * Location code
    */
    // @ApiMember(Description="Location code")
    String? LocationCode;

    /**
    * Stock quantity in location
    */
    // @ApiMember(Description="Stock quantity in location")
    int StockQuantity = 0;

    PartStockQuantity({this.LocationId=0,this.LocationCode,this.StockQuantity=0});
    PartStockQuantity.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        LocationId = json['LocationId'] ?? 0;
        LocationCode = json['LocationCode'];
        StockQuantity = json['StockQuantity'] ?? 0;
        return this;
    }

    Map<String, dynamic> toJson() => {
        'LocationId': LocationId,
        'LocationCode': LocationCode,
        'StockQuantity': StockQuantity
    };

    getTypeName() => "PartStockQuantity";
    TypeContext? context = _ctx;
}

class PartInfoResult implements IConvertible
{
    /**
    * Unique ID for the part.
    */
    // @ApiMember(Description="Unique ID for the part.")
    int Id = 0;

    /**
    * Part number.
    */
    // @ApiMember(Description="Part number.")
    String? PartNumber;

    /**
    * Description of the part.
    */
    // @ApiMember(Description="Description of the part.")
    String? Description;

    /**
    * Part manufacturer.
    */
    // @ApiMember(Description="Part manufacturer.")
    String? Manufacturer;

    /**
    * Determines if the part can be ordered.
    */
    // @ApiMember(Description="Determines if the part can be ordered.")
    bool? CanBeOrdered;

    /**
    * Textual representation of the status of the part.
    */
    // @ApiMember(Description="Textual representation of the status of the part.")
    String? StatusText;

    /**
    * Available stock to order.
    */
    // @ApiMember(Description="Available stock to order.")
    int AvailableStockQuantity = 0;

    /**
    * Average days needed for delivery.
    */
    // @ApiMember(Description="Average days needed for delivery.")
    int? AverageDeliveryInDays;

    /**
    * Price of a single unit, excluding VAT.
    */
    // @ApiMember(Description="Price of a single unit, excluding VAT.")
    double? UnitPrice;

    /**
    * EAN number.
    */
    // @ApiMember(Description="EAN number.")
    String? EanNumber;

    /**
    * Images
    */
    // @ApiMember(Description="Images")
    List<PartInfoResultImage>? Images;

    /**
    * Secondary article numbers
    */
    // @ApiMember(Description="Secondary article numbers")
    List<String>? SecondaryArticleNumbers;

    /**
    * Replacement article numbers
    */
    // @ApiMember(Description="Replacement article numbers")
    List<String>? ReplacementArticleNumbers;

    /**
    * Stock quantities
    */
    // @ApiMember(Description="Stock quantities")
    List<PartStockQuantity>? StockQuantities;

    PartInfoResult({this.Id=0,this.PartNumber,this.Description,this.Manufacturer,this.CanBeOrdered,this.StatusText,this.AvailableStockQuantity=0,this.AverageDeliveryInDays,this.UnitPrice,this.EanNumber,this.Images,this.SecondaryArticleNumbers,this.ReplacementArticleNumbers,this.StockQuantities});
    PartInfoResult.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'] ?? 0;
        PartNumber = json['PartNumber'];
        Description = json['Description'];
        Manufacturer = json['Manufacturer'];
        CanBeOrdered = json['CanBeOrdered'];
        StatusText = json['StatusText'];
        AvailableStockQuantity = json['AvailableStockQuantity'] ?? 0;
        AverageDeliveryInDays = json['AverageDeliveryInDays'];
        UnitPrice = JsonConverters.toDouble(json['UnitPrice']);
        EanNumber = json['EanNumber'];
        Images = JsonConverters.fromJson(json['Images'],'List<PartInfoResultImage>',context!);
        SecondaryArticleNumbers = JsonConverters.fromJson(json['SecondaryArticleNumbers'],'List<String>',context!);
        ReplacementArticleNumbers = JsonConverters.fromJson(json['ReplacementArticleNumbers'],'List<String>',context!);
        StockQuantities = JsonConverters.fromJson(json['StockQuantities'],'List<PartStockQuantity>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'PartNumber': PartNumber,
        'Description': Description,
        'Manufacturer': Manufacturer,
        'CanBeOrdered': CanBeOrdered,
        'StatusText': StatusText,
        'AvailableStockQuantity': AvailableStockQuantity,
        'AverageDeliveryInDays': AverageDeliveryInDays,
        'UnitPrice': UnitPrice,
        'EanNumber': EanNumber,
        'Images': JsonConverters.toJson(Images,'List<PartInfoResultImage>',context!),
        'SecondaryArticleNumbers': JsonConverters.toJson(SecondaryArticleNumbers,'List<String>',context!),
        'ReplacementArticleNumbers': JsonConverters.toJson(ReplacementArticleNumbers,'List<String>',context!),
        'StockQuantities': JsonConverters.toJson(StockQuantities,'List<PartStockQuantity>',context!)
    };

    getTypeName() => "PartInfoResult";
    TypeContext? context = _ctx;
}

class PartResults implements IConvertible
{
    /**
    * Total number of parts available.
    */
    // @ApiMember(Description="Total number of parts available.")
    int TotalNumberOfParts = 0;

    /**
    * Indication if there are more parts to retrieve.
    */
    // @ApiMember(Description="Indication if there are more parts to retrieve.")
    bool? HasMoreRecords;

    /**
    * Part records.
    */
    // @ApiMember(Description="Part records.")
    List<PartInfoResult>? Parts;

    PartResults({this.TotalNumberOfParts=0,this.HasMoreRecords,this.Parts});
    PartResults.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        TotalNumberOfParts = json['TotalNumberOfParts'] ?? 0;
        HasMoreRecords = json['HasMoreRecords'];
        Parts = JsonConverters.fromJson(json['Parts'],'List<PartInfoResult>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'TotalNumberOfParts': TotalNumberOfParts,
        'HasMoreRecords': HasMoreRecords,
        'Parts': JsonConverters.toJson(Parts,'List<PartInfoResult>',context!)
    };

    getTypeName() => "PartResults";
    TypeContext? context = _ctx;
}

class OperationResult1<T> extends OperationResult implements IConvertible
{
    /**
    * Result value
    */
    // @ApiMember(Description="Result value", ParameterType="model")
    PartResults? Result;

    OperationResult1({this.Result});
    OperationResult1.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        Result = JsonConverters.fromJson(json['Result'],'PartResults',context!);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'Result': JsonConverters.toJson(Result,'PartResults',context!)
    });

    getTypeName() => "OperationResult<$T>";
    TypeContext? context = _ctx;
}

class AuthenticateResponse extends OperationResult1<AuthenticateResult> implements IConvertible
{
    AuthenticateResponse();
    AuthenticateResponse.fromJson(Map<String, dynamic> json) : super.fromJson(json);
    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson();
    getTypeName() => "AuthenticateResponse";
    TypeContext? context = _ctx;
}

class Authenticate implements IConvertible
{
    /**
    * User name for your account.
    */
    // @ApiMember(Description="User name for your account.", IsRequired=true, ParameterType="query")
    String UserName = "";

    /**
    * Password provided by your supplier.
    */
    // @ApiMember(Description="Password provided by your supplier.", IsRequired=true, ParameterType="query")
    String Password = "";

    Authenticate({this.UserName="",this.Password=""});
    Authenticate.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        UserName = json['UserName'] ?? "";
        Password = json['Password'] ?? "";
        return this;
    }

    Map<String, dynamic> toJson() => {
        'UserName': UserName,
        'Password': Password
    };

    getTypeName() => "Authenticate";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'services.acct.2service.nl', types: <String, TypeInfo> {
    'AuthenticateResult': TypeInfo(TypeOf.Class, create:() => AuthenticateResult()),
    'OperationResult': TypeInfo(TypeOf.Class, create:() => OperationResult()),
    'PartInfoResultImage': TypeInfo(TypeOf.Class, create:() => PartInfoResultImage()),
    'PartStockQuantity': TypeInfo(TypeOf.Class, create:() => PartStockQuantity()),
    'PartInfoResult': TypeInfo(TypeOf.Class, create:() => PartInfoResult()),
    'List<PartInfoResultImage>': TypeInfo(TypeOf.Class, create:() => <PartInfoResultImage>[]),
    'List<PartStockQuantity>': TypeInfo(TypeOf.Class, create:() => <PartStockQuantity>[]),
    'PartResults': TypeInfo(TypeOf.Class, create:() => PartResults()),
    'List<PartInfoResult>': TypeInfo(TypeOf.Class, create:() => <PartInfoResult>[]),
    'OperationResult1<T>': TypeInfo(TypeOf.Class, create:() => OperationResult1<T>()),
});

Dart Authenticate DTOs

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

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

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/json
Content-Type: application/json
Content-Length: length

{"UserName":"String","Password":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Result":{"SessionToken":"String"},"IsSuccessful":false,"ErrorMessage":"String"}