Required role: | Admin | Required permissions: | CanAccess, CanAdd |
POST | /sync/products/batch |
---|
import 'package:servicestack/servicestack.dart';
import 'dart:typed_data';
/**
* Represents a product.
*/
// @Api(Description="Represents a product.")
class Product implements IHasName, IConvertible
{
/**
* The unique identifier of the product.
*/
// @ApiMember(Description="The unique identifier of the product.", IsRequired=true)
int? id;
/**
* The position of this instance in a collection of 'Product' instances
*/
// @ApiMember(Description="The position of this instance in a collection of 'Product' instances", IsRequired=true)
int? index;
/**
* The name of the product.
*/
// @ApiMember(Description="The name of the product.", IsRequired=true)
// @Validate(Validator="NotEmpty")
String? name;
/**
* The version of the product.
*/
// @ApiMember(Description="The version of the product.", IsRequired=true)
// @Validate(Validator="NotEmpty")
String? version;
/**
* The version of the product.
*/
// @ApiMember(Description="The version of the product.")
String? description;
/**
* Tags associated with the product.
*/
// @ApiMember(Description="Tags associated with the product.")
List<String>? tags;
Product({this.id,this.index,this.name,this.version,this.description,this.tags});
Product.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
index = json['index'];
name = json['name'];
version = json['version'];
description = json['description'];
tags = JsonConverters.fromJson(json['tags'],'List<String>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'index': index,
'name': name,
'version': version,
'description': description,
'tags': JsonConverters.toJson(tags,'List<String>',context!)
};
getTypeName() => "Product";
TypeContext? context = _ctx;
}
/**
* Specifies a base service request to register one or more products in a batch operation.
*/
// @Api(Description="Specifies a base service request to register one or more products in a batch operation.")
abstract class BatchRegisterProductsBase implements IPost
{
/**
* The products to register.
*/
// @ApiMember(Description="The products to register.", IsRequired=true)
List<Product>? products;
BatchRegisterProductsBase({this.products});
BatchRegisterProductsBase.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
products = JsonConverters.fromJson(json['products'],'List<Product>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'products': JsonConverters.toJson(products,'List<Product>',context!)
};
getTypeName() => "BatchRegisterProductsBase";
TypeContext? context = _ctx;
}
/**
* Represents a service request to register one or more products in a batch operation.
*/
// @Api(Description="Represents a service request to register one or more products in a batch operation.")
class BatchRegisterProducts extends BatchRegisterProductsBase implements IConvertible
{
/**
* The products to register.
*/
// @ApiMember(Description="The products to register.", IsRequired=true)
List<Product>? products;
BatchRegisterProducts({this.products});
BatchRegisterProducts.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
products = JsonConverters.fromJson(json['products'],'List<Product>',context!);
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'products': JsonConverters.toJson(products,'List<Product>',context!)
});
getTypeName() => "BatchRegisterProducts";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'taxfiling.pwc.de', types: <String, TypeInfo> {
'Product': TypeInfo(TypeOf.Class, create:() => Product()),
'BatchRegisterProductsBase': TypeInfo(TypeOf.AbstractClass),
'List<Product>': TypeInfo(TypeOf.Class, create:() => <Product>[]),
'BatchRegisterProducts': TypeInfo(TypeOf.Class, create:() => BatchRegisterProducts()),
});
Dart BatchRegisterProducts DTOs
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.
POST /sync/products/batch HTTP/1.1
Host: taxfiling.pwc.de
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
products:
[
{
id: 0,
index: 0,
name: String,
version: String,
description: String,
tags:
[
String
]
}
]
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length [ { product: { id: 0, index: 0, name: String, version: String, description: String, tags: [ String ] }, orders: [ { id: 0, productId: 0, accountId: 0, name: String, serviceName: String, requestTimestamp: 0001-01-01, responseTimestamp: 0001-01-01, requestUri: String, requestHttpMethod: String, requestDuration: PT0S, responseStatusCode: Continue, clientIPAddress: String, unitOfMeasurement: String, processType: String, dataType: String, dataName: String, creationDate: 0001-01-01, expiryDate: 0001-01-01, isTest: False } ], responseStatus: { errorCode: String, message: String, stackTrace: String, errors: [ { errorCode: String, fieldName: String, message: String, meta: { String: String } } ], meta: { String: String } } } ]