import 'package:servicestack/servicestack.dart';
import 'dart:typed_data';
class JsonDto implements IConvertible
{
JsonDto();
JsonDto.fromJson(Map<String, dynamic> json) : super();
fromMap(Map<String, dynamic> json) {
return this;
}
Map<String, dynamic> toJson() => {};
getTypeName() => "JsonDto";
TypeContext? context = _ctx;
}
class JsonRequestDto extends JsonDto implements IConvertible
{
String? ClientCode;
String? ClientRegistrationCode;
String? Token;
JsonRequestDto({this.ClientCode,this.ClientRegistrationCode,this.Token});
JsonRequestDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
ClientCode = json['ClientCode'];
ClientRegistrationCode = json['ClientRegistrationCode'];
Token = json['Token'];
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'ClientCode': ClientCode,
'ClientRegistrationCode': ClientRegistrationCode,
'Token': Token
});
getTypeName() => "JsonRequestDto";
TypeContext? context = _ctx;
}
class JsonRegisterClientRequest extends JsonRequestDto implements IConvertible
{
JsonRegisterClientRequest();
JsonRegisterClientRequest.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() => "JsonRegisterClientRequest";
TypeContext? context = _ctx;
}
enum RegistrationResult
{
Success,
ClientCodeNotFound,
ClientAlreadyRegistered,
Error,
}
class JsonRegisterClientResponse extends JsonDto implements IConvertible
{
RegistrationResult? Result;
String? ErrorMessage;
String? ClientRegistrationCode;
JsonRegisterClientResponse({this.Result,this.ErrorMessage,this.ClientRegistrationCode});
JsonRegisterClientResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
Result = JsonConverters.fromJson(json['Result'],'RegistrationResult',context!);
ErrorMessage = json['ErrorMessage'];
ClientRegistrationCode = json['ClientRegistrationCode'];
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'Result': JsonConverters.toJson(Result,'RegistrationResult',context!),
'ErrorMessage': ErrorMessage,
'ClientRegistrationCode': ClientRegistrationCode
});
getTypeName() => "JsonRegisterClientResponse";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'buildmax.org', types: <String, TypeInfo> {
'JsonDto': TypeInfo(TypeOf.Class, create:() => JsonDto()),
'JsonRequestDto': TypeInfo(TypeOf.Class, create:() => JsonRequestDto()),
'JsonRegisterClientRequest': TypeInfo(TypeOf.Class, create:() => JsonRegisterClientRequest()),
'RegistrationResult': TypeInfo(TypeOf.Enum, enumValues:RegistrationResult.values),
'JsonRegisterClientResponse': TypeInfo(TypeOf.Class, create:() => JsonRegisterClientResponse()),
});
Dart JsonRegisterClientRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsonl/reply/JsonRegisterClientRequest HTTP/1.1
Host: buildmax.org
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"ClientCode":"String","ClientRegistrationCode":"String","Token":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"Result":"Success","ErrorMessage":"String","ClientRegistrationCode":"String"}