import 'package:servicestack/servicestack.dart';
import 'dart:typed_data';
// @DataContract
abstract class QueryBase
{
// @DataMember(Order=1)
int? skip;
// @DataMember(Order=2)
int? take;
// @DataMember(Order=3)
String? orderBy;
// @DataMember(Order=4)
String? orderByDesc;
// @DataMember(Order=5)
String? include;
// @DataMember(Order=6)
String? fields;
// @DataMember(Order=7)
Map<String,String?>? meta;
QueryBase({this.skip,this.take,this.orderBy,this.orderByDesc,this.include,this.fields,this.meta});
QueryBase.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
skip = json['skip'];
take = json['take'];
orderBy = json['orderBy'];
orderByDesc = json['orderByDesc'];
include = json['include'];
fields = json['fields'];
meta = JsonConverters.toStringMap(json['meta']);
return this;
}
Map<String, dynamic> toJson() => {
'skip': skip,
'take': take,
'orderBy': orderBy,
'orderByDesc': orderByDesc,
'include': include,
'fields': fields,
'meta': meta
};
getTypeName() => "QueryBase";
TypeContext? context = _ctx;
}
abstract class QueryDb<T> extends QueryBase
{
QueryDb();
QueryDb.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() => "QueryDb<$T>";
TypeContext? context = _ctx;
}
// @DataContract
abstract class AuditBase
{
// @DataMember(Order=1)
DateTime? createdDate;
// @DataMember(Order=2)
// @required()
String? createdBy;
// @DataMember(Order=3)
DateTime? modifiedDate;
// @DataMember(Order=4)
// @required()
String? modifiedBy;
// @DataMember(Order=5)
DateTime? deletedDate;
// @DataMember(Order=6)
String? deletedBy;
AuditBase({this.createdDate,this.createdBy,this.modifiedDate,this.modifiedBy,this.deletedDate,this.deletedBy});
AuditBase.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
createdDate = JsonConverters.fromJson(json['createdDate'],'DateTime',context!);
createdBy = json['createdBy'];
modifiedDate = JsonConverters.fromJson(json['modifiedDate'],'DateTime',context!);
modifiedBy = json['modifiedBy'];
deletedDate = JsonConverters.fromJson(json['deletedDate'],'DateTime',context!);
deletedBy = json['deletedBy'];
return this;
}
Map<String, dynamic> toJson() => {
'createdDate': JsonConverters.toJson(createdDate,'DateTime',context!),
'createdBy': createdBy,
'modifiedDate': JsonConverters.toJson(modifiedDate,'DateTime',context!),
'modifiedBy': modifiedBy,
'deletedDate': JsonConverters.toJson(deletedDate,'DateTime',context!),
'deletedBy': deletedBy
};
getTypeName() => "AuditBase";
TypeContext? context = _ctx;
}
enum PhoneKind
{
Home,
Mobile,
Work,
}
class Phone implements IConvertible
{
PhoneKind? kind;
String? number;
String? ext;
Phone({this.kind,this.number,this.ext});
Phone.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
kind = JsonConverters.fromJson(json['kind'],'PhoneKind',context!);
number = json['number'];
ext = json['ext'];
return this;
}
Map<String, dynamic> toJson() => {
'kind': JsonConverters.toJson(kind,'PhoneKind',context!),
'number': number,
'ext': ext
};
getTypeName() => "Phone";
TypeContext? context = _ctx;
}
class PlayerGameItem implements IConvertible
{
int? id;
// @References(typeof(Player))
int? playerId;
// @References(typeof(GameItem))
String? gameItemName;
PlayerGameItem({this.id,this.playerId,this.gameItemName});
PlayerGameItem.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
playerId = json['playerId'];
gameItemName = json['gameItemName'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'playerId': playerId,
'gameItemName': gameItemName
};
getTypeName() => "PlayerGameItem";
TypeContext? context = _ctx;
}
enum PlayerRole
{
Leader,
Player,
NonPlayer,
}
enum PlayerRegion
{
Africa,
Americas,
Asia,
Australasia,
Europe,
}
class Profile extends AuditBase implements IConvertible
{
int? id;
PlayerRole? role;
PlayerRegion? region;
String? username;
int? highScore;
int? gamesPlayed;
int? energy;
String? profileUrl;
String? coverUrl;
Map<String,String?>? meta;
Profile({this.id,this.role,this.region,this.username,this.highScore,this.gamesPlayed,this.energy,this.profileUrl,this.coverUrl,this.meta});
Profile.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
id = json['id'];
role = JsonConverters.fromJson(json['role'],'PlayerRole',context!);
region = JsonConverters.fromJson(json['region'],'PlayerRegion',context!);
username = json['username'];
highScore = json['highScore'];
gamesPlayed = json['gamesPlayed'];
energy = json['energy'];
profileUrl = json['profileUrl'];
coverUrl = json['coverUrl'];
meta = JsonConverters.toStringMap(json['meta']);
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'id': id,
'role': JsonConverters.toJson(role,'PlayerRole',context!),
'region': JsonConverters.toJson(region,'PlayerRegion',context!),
'username': username,
'highScore': highScore,
'gamesPlayed': gamesPlayed,
'energy': energy,
'profileUrl': profileUrl,
'coverUrl': coverUrl,
'meta': meta
});
getTypeName() => "Profile";
TypeContext? context = _ctx;
}
class Player extends AuditBase implements IConvertible
{
int? id;
// @required()
String? firstName;
String? lastName;
String? email;
List<Phone>? phoneNumbers = [];
List<PlayerGameItem>? gameItems = [];
Profile? profile;
int? profileId;
String? savedLevelId;
int? rowVersion;
Player({this.id,this.firstName,this.lastName,this.email,this.phoneNumbers,this.gameItems,this.profile,this.profileId,this.savedLevelId,this.rowVersion});
Player.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
id = json['id'];
firstName = json['firstName'];
lastName = json['lastName'];
email = json['email'];
phoneNumbers = JsonConverters.fromJson(json['phoneNumbers'],'List<Phone>',context!);
gameItems = JsonConverters.fromJson(json['gameItems'],'List<PlayerGameItem>',context!);
profile = JsonConverters.fromJson(json['profile'],'Profile',context!);
profileId = json['profileId'];
savedLevelId = json['savedLevelId'];
rowVersion = json['rowVersion'];
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'id': id,
'firstName': firstName,
'lastName': lastName,
'email': email,
'phoneNumbers': JsonConverters.toJson(phoneNumbers,'List<Phone>',context!),
'gameItems': JsonConverters.toJson(gameItems,'List<PlayerGameItem>',context!),
'profile': JsonConverters.toJson(profile,'Profile',context!),
'profileId': profileId,
'savedLevelId': savedLevelId,
'rowVersion': rowVersion
});
getTypeName() => "Player";
TypeContext? context = _ctx;
}
class QueryPlayer extends QueryDb<Player> implements IConvertible
{
QueryPlayer();
QueryPlayer.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() => "QueryPlayer";
TypeContext? context = _ctx;
}
class Todo implements IConvertible
{
int? id;
String? text;
bool? isFinished;
Todo({this.id,this.text,this.isFinished});
Todo.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
text = json['text'];
isFinished = json['isFinished'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'text': text,
'isFinished': isFinished
};
getTypeName() => "Todo";
TypeContext? context = _ctx;
}
// @DataContract
class QueryResponse<T> implements IConvertible
{
// @DataMember(Order=1)
int? offset;
// @DataMember(Order=2)
int? total;
// @DataMember(Order=3)
List<Todo>? results;
// @DataMember(Order=4)
Map<String,String?>? meta;
// @DataMember(Order=5)
ResponseStatus? responseStatus;
QueryResponse({this.offset,this.total,this.results,this.meta,this.responseStatus});
QueryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
offset = json['offset'];
total = json['total'];
results = JsonConverters.fromJson(json['results'],'List<Todo>',context!);
meta = JsonConverters.toStringMap(json['meta']);
responseStatus = JsonConverters.fromJson(json['responseStatus'],'ResponseStatus',context!);
return this;
}
Map<String, dynamic> toJson() => {
'offset': offset,
'total': total,
'results': JsonConverters.toJson(results,'List<Todo>',context!),
'meta': meta,
'responseStatus': JsonConverters.toJson(responseStatus,'ResponseStatus',context!)
};
getTypeName() => "QueryResponse<$T>";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'blazor_gallery.servicestack.net', types: <String, TypeInfo> {
'PhoneKind': TypeInfo(TypeOf.Enum, enumValues:PhoneKind.values),
'Phone': TypeInfo(TypeOf.Class, create:() => Phone()),
'PlayerGameItem': TypeInfo(TypeOf.Class, create:() => PlayerGameItem()),
'PlayerRole': TypeInfo(TypeOf.Enum, enumValues:PlayerRole.values),
'PlayerRegion': TypeInfo(TypeOf.Enum, enumValues:PlayerRegion.values),
'Profile': TypeInfo(TypeOf.Class, create:() => Profile()),
'Player': TypeInfo(TypeOf.Class, create:() => Player()),
'List<Phone>': TypeInfo(TypeOf.Class, create:() => <Phone>[]),
'List<PlayerGameItem>': TypeInfo(TypeOf.Class, create:() => <PlayerGameItem>[]),
'QueryPlayer': TypeInfo(TypeOf.Class, create:() => QueryPlayer()),
'List<Player>': TypeInfo(TypeOf.Class, create:() => <Player>[]),
'Todo': TypeInfo(TypeOf.Class, create:() => Todo()),
'List<Todo>': TypeInfo(TypeOf.Class, create:() => <Todo>[]),
});
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /csv/reply/QueryPlayer HTTP/1.1
Host: blazor-gallery.servicestack.net
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"skip":0,"take":0,"orderBy":"String","orderByDesc":"String","include":"String","fields":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"offset":0,"total":0,"results":[{"id":0,"firstName":"String","lastName":"String","email":"String","phoneNumbers":[{"kind":"Home","number":"String","ext":"String"}],"gameItems":[{"id":0,"playerId":0,"gameItemName":"String"}],"profile":{"id":0,"role":"Leader","region":"Africa","username":"String","highScore":0,"gamesPlayed":0,"energy":0,"profileUrl":"String","coverUrl":"String","meta":{"String":"String"},"createdDate":"0001-01-01T00:00:00","createdBy":"String","modifiedDate":"0001-01-01T00:00:00","modifiedBy":"String","deletedDate":"0001-01-01T00:00:00","deletedBy":"String"},"profileId":0,"savedLevelId":"00000000-0000-0000-0000-000000000000","rowVersion":0,"createdDate":"0001-01-01T00:00:00","createdBy":"String","modifiedDate":"0001-01-01T00:00:00","modifiedBy":"String","deletedDate":"0001-01-01T00:00:00","deletedBy":"String"}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}