Test

<back to all web services

CreateRockstarAudit

import 'package:servicestack/servicestack.dart';
import 'dart:typed_data';

enum LivingStatus
{
    Alive,
    Dead,
}

abstract class RockstarBase
{
    String? firstName;
    String? lastName;
    int? age;
    DateTime? dateOfBirth;
    DateTime? dateDied;
    LivingStatus? livingStatus;

    RockstarBase({this.firstName,this.lastName,this.age,this.dateOfBirth,this.dateDied,this.livingStatus});
    RockstarBase.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        firstName = json['firstName'];
        lastName = json['lastName'];
        age = json['age'];
        dateOfBirth = JsonConverters.fromJson(json['dateOfBirth'],'DateTime',context!);
        dateDied = JsonConverters.fromJson(json['dateDied'],'DateTime',context!);
        livingStatus = JsonConverters.fromJson(json['livingStatus'],'LivingStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'firstName': firstName,
        'lastName': lastName,
        'age': age,
        'dateOfBirth': JsonConverters.toJson(dateOfBirth,'DateTime',context!),
        'dateDied': JsonConverters.toJson(dateDied,'DateTime',context!),
        'livingStatus': JsonConverters.toJson(livingStatus,'LivingStatus',context!)
    };

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

class RockstarWithIdResponse implements IConvertible
{
    int? id;
    ResponseStatus? responseStatus;

    RockstarWithIdResponse({this.id,this.responseStatus});
    RockstarWithIdResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        responseStatus = JsonConverters.fromJson(json['responseStatus'],'ResponseStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'responseStatus': JsonConverters.toJson(responseStatus,'ResponseStatus',context!)
    };

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

class CreateRockstarAudit extends RockstarBase implements ICreateDb<RockstarAudit>, IConvertible
{
    CreateRockstarAudit();
    CreateRockstarAudit.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() => "CreateRockstarAudit";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'test.servicestack.net', types: <String, TypeInfo> {
    'LivingStatus': TypeInfo(TypeOf.Enum, enumValues:LivingStatus.values),
    'RockstarBase': TypeInfo(TypeOf.AbstractClass),
    'RockstarWithIdResponse': TypeInfo(TypeOf.Class, create:() => RockstarWithIdResponse()),
    'CreateRockstarAudit': TypeInfo(TypeOf.Class, create:() => CreateRockstarAudit()),
});

Dart CreateRockstarAudit DTOs

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

HTTP + CSV

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

POST /csv/reply/CreateRockstarAudit HTTP/1.1 
Host: test.servicestack.net 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"firstName":"String","lastName":"String","age":0,"dateOfBirth":"\/Date(-62135596800000-0000)\/","dateDied":"\/Date(-62135596800000-0000)\/","livingStatus":"Alive"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"id":0,"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}