2Service Services API

<back to all web services

PostNewOrder

The following routes are available for this service:
POST/dealers/orderPlaces a new order with the specified items.
import 'package:servicestack/servicestack.dart';

abstract class AuthenticatedRequest
{
    /**
    * Session token received from successful authentication.
    */
    // @ApiMember(Description="Session token received from successful authentication.", IsRequired=true, ParameterType="query")
    String SessionToken = "";

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

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

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

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

class NewOrderResult implements IConvertible
{
    /**
    * Number for the order that has been placed.
    */
    // @ApiMember(Description="Number for the order that has been placed.", ParameterType="model")
    String? OrderNumber;

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

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

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

    getTypeName() => "NewOrderResult";
    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 NewOrderResponse extends OperationResult1<NewOrderResult> implements IConvertible
{
    NewOrderResponse();
    NewOrderResponse.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() => "NewOrderResponse";
    TypeContext? context = _ctx;
}

class NewOrderItem implements IConvertible
{
    /**
    * Unique ID for the part.
    */
    // @ApiMember(Description="Unique ID for the part.", IsRequired=true, ParameterType="body")
    int PartId = 0;

    /**
    * Quantity to order.
    */
    // @ApiMember(Description="Quantity to order.", IsRequired=true, ParameterType="body")
    int Quantity = 0;

    /**
    * Custom reference.
    */
    // @ApiMember(Description="Custom reference.", ParameterType="body")
    String? Reference;

    NewOrderItem({this.PartId=0,this.Quantity=0,this.Reference});
    NewOrderItem.fromJson(Map<String, dynamic> json) { fromMap(json); }

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

    Map<String, dynamic> toJson() => {
        'PartId': PartId,
        'Quantity': Quantity,
        'Reference': Reference
    };

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

class NewOrderItemList extends ListBase<NewOrderItem> implements IConvertible
{
    final List<NewOrderItem> l = [];
    set length(int newLength) { l.length = newLength; }
    int get length => l.length;
    NewOrderItem operator [](int index) => l[index];
    void operator []=(int index, NewOrderItem value) { l[index] = value; }
    NewOrderItemList();
    NewOrderItemList.fromJson(Map<String, dynamic> json) : super();
    fromMap(Map<String, dynamic> json) {
        return this;
    }

    Map<String, dynamic> toJson() => {};
    getTypeName() => "NewOrderItemList";
    TypeContext? context = _ctx;
}

class NewOrderAddress implements IAddress, IConvertible
{
    /**
    * Company name.
    */
    // @ApiMember(Description="Company name.", ParameterType="body")
    String? CompanyName;

    /**
    * First name.
    */
    // @ApiMember(Description="First name.", ParameterType="body")
    String? FirstName;

    /**
    * Last name.
    */
    // @ApiMember(Description="Last name.", ParameterType="body")
    String? LastName;

    /**
    * Street name.
    */
    // @ApiMember(Description="Street name.", IsRequired=true, ParameterType="body")
    String StreetName = "";

    /**
    * House number.
    */
    // @ApiMember(Description="House number.", IsRequired=true, ParameterType="body")
    String HouseNumber = "";

    /**
    * House number addition.
    */
    // @ApiMember(Description="House number addition.", ParameterType="body")
    String? HouseNumberAddition;

    /**
    * Postal code.
    */
    // @ApiMember(Description="Postal code.", IsRequired=true, ParameterType="body")
    String PostalCode = "";

    /**
    * City.
    */
    // @ApiMember(Description="City.", IsRequired=true, ParameterType="body")
    String City = "";

    /**
    * Country code.
    */
    // @ApiMember(Description="Country code.", IsRequired=true, ParameterType="body")
    String CountryCode = "";

    /**
    * Telephone number.
    */
    // @ApiMember(Description="Telephone number.", ParameterType="body")
    String? TelephoneNumber;

    NewOrderAddress({this.CompanyName,this.FirstName,this.LastName,this.StreetName="",this.HouseNumber="",this.HouseNumberAddition,this.PostalCode="",this.City="",this.CountryCode="",this.TelephoneNumber});
    NewOrderAddress.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        CompanyName = json['CompanyName'];
        FirstName = json['FirstName'];
        LastName = json['LastName'];
        StreetName = json['StreetName'] ?? "";
        HouseNumber = json['HouseNumber'] ?? "";
        HouseNumberAddition = json['HouseNumberAddition'];
        PostalCode = json['PostalCode'] ?? "";
        City = json['City'] ?? "";
        CountryCode = json['CountryCode'] ?? "";
        TelephoneNumber = json['TelephoneNumber'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'CompanyName': CompanyName,
        'FirstName': FirstName,
        'LastName': LastName,
        'StreetName': StreetName,
        'HouseNumber': HouseNumber,
        'HouseNumberAddition': HouseNumberAddition,
        'PostalCode': PostalCode,
        'City': City,
        'CountryCode': CountryCode,
        'TelephoneNumber': TelephoneNumber
    };

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

class PostNewOrder extends AuthenticatedRequest implements IConvertible
{
    /**
    * Items to order.
    */
    // @ApiMember(Description="Items to order.", IsRequired=true, ParameterType="body")
    NewOrderItemList? Items;

    /**
    * Dropshipment indication.
    */
    // @ApiMember(Description="Dropshipment indication.", ParameterType="body")
    bool? UseDropshipment;

    /**
    * Delivery address.
    */
    // @ApiMember(Description="Delivery address.", ParameterType="body")
    NewOrderAddress? DeliveryAddress;

    PostNewOrder({this.Items,this.UseDropshipment,this.DeliveryAddress});
    PostNewOrder.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        Items = JsonConverters.fromJson(json['Items'],'NewOrderItemList',context!);
        UseDropshipment = json['UseDropshipment'];
        DeliveryAddress = JsonConverters.fromJson(json['DeliveryAddress'],'NewOrderAddress',context!);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'Items': JsonConverters.toJson(Items,'NewOrderItemList',context!),
        'UseDropshipment': UseDropshipment,
        'DeliveryAddress': JsonConverters.toJson(DeliveryAddress,'NewOrderAddress',context!)
    });

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

TypeContext _ctx = TypeContext(library: 'services.acct.2service.nl', types: <String, TypeInfo> {
    'AuthenticatedRequest': TypeInfo(TypeOf.AbstractClass),
    'NewOrderResult': TypeInfo(TypeOf.Class, create:() => NewOrderResult()),
    '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>()),
    'NewOrderResponse': TypeInfo(TypeOf.Class, create:() => NewOrderResponse()),
    'NewOrderItem': TypeInfo(TypeOf.Class, create:() => NewOrderItem()),
    'NewOrderItemList': TypeInfo(TypeOf.Class, create:() => NewOrderItemList()),
    'NewOrderAddress': TypeInfo(TypeOf.Class, create:() => NewOrderAddress()),
    'PostNewOrder': TypeInfo(TypeOf.Class, create:() => PostNewOrder()),
});

Dart PostNewOrder DTOs

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

HTTP + JSV

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

POST /dealers/order HTTP/1.1 
Host: services.acct.2service.nl 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	Items: 
	[
		{
			PartId: 0,
			Quantity: 0,
			Reference: String
		}
	],
	UseDropshipment: False,
	DeliveryAddress: 
	{
		CompanyName: String,
		FirstName: String,
		LastName: String,
		StreetName: String,
		HouseNumber: String,
		HouseNumberAddition: String,
		PostalCode: String,
		City: String,
		CountryCode: String,
		TelephoneNumber: String
	},
	SessionToken: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Result: 
	{
		OrderNumber: String
	},
	IsSuccessful: False,
	ErrorMessage: String
}