| Requires any of the roles: | Admin, TeamAdmin | Required permission: | Tickets.Add |
| POST | /Webshop/Product |
|---|
import 'package:servicestack/servicestack.dart';
class WebshopVariantSummary implements IConvertible
{
int? id;
int? productId;
String? size;
String? color;
int? stockOnHand;
int? quantitySold;
int? availableQuantity;
String? status;
WebshopVariantSummary({this.id,this.productId,this.size,this.color,this.stockOnHand,this.quantitySold,this.availableQuantity,this.status});
WebshopVariantSummary.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
productId = json['productId'];
size = json['size'];
color = json['color'];
stockOnHand = json['stockOnHand'];
quantitySold = json['quantitySold'];
availableQuantity = json['availableQuantity'];
status = json['status'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'productId': productId,
'size': size,
'color': color,
'stockOnHand': stockOnHand,
'quantitySold': quantitySold,
'availableQuantity': availableQuantity,
'status': status
};
getTypeName() => "WebshopVariantSummary";
TypeContext? context = _ctx;
}
class WebshopProductSummary implements IConvertible
{
int? id;
int? ownerId;
String? name;
String? description;
String? category;
String? subCategory;
int? defaultPriceMinor;
String? imageUrl;
int? viewOrder;
String? status;
int? payoutInfoId;
int? legacyItemId;
List<WebshopVariantSummary>? variants;
WebshopProductSummary({this.id,this.ownerId,this.name,this.description,this.category,this.subCategory,this.defaultPriceMinor,this.imageUrl,this.viewOrder,this.status,this.payoutInfoId,this.legacyItemId,this.variants});
WebshopProductSummary.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
ownerId = json['ownerId'];
name = json['name'];
description = json['description'];
category = json['category'];
subCategory = json['subCategory'];
defaultPriceMinor = json['defaultPriceMinor'];
imageUrl = json['imageUrl'];
viewOrder = json['viewOrder'];
status = json['status'];
payoutInfoId = json['payoutInfoId'];
legacyItemId = json['legacyItemId'];
variants = JsonConverters.fromJson(json['variants'],'List<WebshopVariantSummary>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'ownerId': ownerId,
'name': name,
'description': description,
'category': category,
'subCategory': subCategory,
'defaultPriceMinor': defaultPriceMinor,
'imageUrl': imageUrl,
'viewOrder': viewOrder,
'status': status,
'payoutInfoId': payoutInfoId,
'legacyItemId': legacyItemId,
'variants': JsonConverters.toJson(variants,'List<WebshopVariantSummary>',context!)
};
getTypeName() => "WebshopProductSummary";
TypeContext? context = _ctx;
}
class WebshopProductResult implements IConvertible
{
WebshopProductSummary? product;
int? statusCode;
String? message;
WebshopProductResult({this.product,this.statusCode,this.message});
WebshopProductResult.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
product = JsonConverters.fromJson(json['product'],'WebshopProductSummary',context!);
statusCode = json['statusCode'];
message = json['message'];
return this;
}
Map<String, dynamic> toJson() => {
'product': JsonConverters.toJson(product,'WebshopProductSummary',context!),
'statusCode': statusCode,
'message': message
};
getTypeName() => "WebshopProductResult";
TypeContext? context = _ctx;
}
class WebshopProduct implements IConvertible
{
int? id;
int? ownerId;
// @StringLength(200)
String? name;
// @StringLength(2000)
String? description;
// @StringLength(150)
String? category;
// @StringLength(150)
String? subCategory;
int? defaultPriceMinor;
// @StringLength(1500)
String? imageUrl;
int? viewOrder;
// @StringLength(20)
String? status;
int? payoutInfoId;
int? legacyItemId;
DateTime? createdAt;
DateTime? updatedAt;
WebshopProduct({this.id,this.ownerId,this.name,this.description,this.category,this.subCategory,this.defaultPriceMinor,this.imageUrl,this.viewOrder,this.status,this.payoutInfoId,this.legacyItemId,this.createdAt,this.updatedAt});
WebshopProduct.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
ownerId = json['ownerId'];
name = json['name'];
description = json['description'];
category = json['category'];
subCategory = json['subCategory'];
defaultPriceMinor = json['defaultPriceMinor'];
imageUrl = json['imageUrl'];
viewOrder = json['viewOrder'];
status = json['status'];
payoutInfoId = json['payoutInfoId'];
legacyItemId = json['legacyItemId'];
createdAt = JsonConverters.fromJson(json['createdAt'],'DateTime',context!);
updatedAt = JsonConverters.fromJson(json['updatedAt'],'DateTime',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'ownerId': ownerId,
'name': name,
'description': description,
'category': category,
'subCategory': subCategory,
'defaultPriceMinor': defaultPriceMinor,
'imageUrl': imageUrl,
'viewOrder': viewOrder,
'status': status,
'payoutInfoId': payoutInfoId,
'legacyItemId': legacyItemId,
'createdAt': JsonConverters.toJson(createdAt,'DateTime',context!),
'updatedAt': JsonConverters.toJson(updatedAt,'DateTime',context!)
};
getTypeName() => "WebshopProduct";
TypeContext? context = _ctx;
}
class WebshopProductCreateRequest implements IConvertible
{
WebshopProduct? item;
int? ownerId;
WebshopProductCreateRequest({this.item,this.ownerId});
WebshopProductCreateRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
item = JsonConverters.fromJson(json['item'],'WebshopProduct',context!);
ownerId = json['ownerId'];
return this;
}
Map<String, dynamic> toJson() => {
'item': JsonConverters.toJson(item,'WebshopProduct',context!),
'ownerId': ownerId
};
getTypeName() => "WebshopProductCreateRequest";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'stubbur_app.azurewebsites.net', types: <String, TypeInfo> {
'WebshopVariantSummary': TypeInfo(TypeOf.Class, create:() => WebshopVariantSummary()),
'WebshopProductSummary': TypeInfo(TypeOf.Class, create:() => WebshopProductSummary()),
'List<WebshopVariantSummary>': TypeInfo(TypeOf.Class, create:() => <WebshopVariantSummary>[]),
'WebshopProductResult': TypeInfo(TypeOf.Class, create:() => WebshopProductResult()),
'WebshopProduct': TypeInfo(TypeOf.Class, create:() => WebshopProduct()),
'WebshopProductCreateRequest': TypeInfo(TypeOf.Class, create:() => WebshopProductCreateRequest()),
});
Dart WebshopProductCreateRequest 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 /Webshop/Product HTTP/1.1
Host: stubbur-app.azurewebsites.net
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
item:
{
id: 0,
ownerId: 0,
name: String,
description: String,
category: String,
subCategory: String,
defaultPriceMinor: 0,
imageUrl: String,
viewOrder: 0,
status: String,
payoutInfoId: 0,
legacyItemId: 0,
createdAt: 0001-01-01,
updatedAt: 0001-01-01
},
ownerId: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
product:
{
id: 0,
ownerId: 0,
name: String,
description: String,
category: String,
subCategory: String,
defaultPriceMinor: 0,
imageUrl: String,
viewOrder: 0,
status: String,
payoutInfoId: 0,
legacyItemId: 0,
variants:
[
{
id: 0,
productId: 0,
size: String,
color: String,
stockOnHand: 0,
quantitySold: 0,
availableQuantity: 0,
status: String
}
]
},
statusCode: 0,
message: String
}