MyApp

<back to all web services

QueryPlayer

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

// @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!) ?? DateTime(0);
        createdBy = json['createdBy'] ?? "";
        modifiedDate = JsonConverters.fromJson(json['modifiedDate'],'DateTime',context!) ?? DateTime(0);
        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 = 0;
    // @References(typeof(Player))
    int playerId = 0;

    // @References(typeof(GameItem))
    String gameItemName = "";

    PlayerGameItem({this.id=0,this.playerId=0,this.gameItemName=""});
    PlayerGameItem.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'] ?? 0;
        playerId = json['playerId'] ?? 0;
        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 = 0;
    PlayerRole? role;
    PlayerRegion? region;
    String? username;
    int highScore = 0;
    int gamesPlayed = 0;
    int energy = 0;
    String? profileUrl;
    String? coverUrl;
    Map<String,String?>? meta;

    Profile({this.id=0,this.role,this.region,this.username,this.highScore=0,this.gamesPlayed=0,this.energy=0,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'] ?? 0;
        role = JsonConverters.fromJson(json['role'],'PlayerRole',context!);
        region = JsonConverters.fromJson(json['region'],'PlayerRegion',context!);
        username = json['username'];
        highScore = json['highScore'] ?? 0;
        gamesPlayed = json['gamesPlayed'] ?? 0;
        energy = json['energy'] ?? 0;
        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 = 0;
    // @required()
    String firstName = "";

    String lastName = "";
    String email = "";
    List<Phone> phoneNumbers = [];
    List<PlayerGameItem> gameItems = [];
    Profile? profile;
    int profileId = 0;
    String savedLevelId = "";
    int rowVersion = 0;

    Player({this.id=0,this.firstName="",this.lastName="",this.email="",this.phoneNumbers=const [],this.gameItems=const [],this.profile,this.profileId=0,this.savedLevelId="",this.rowVersion=0});
    Player.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        id = json['id'] ?? 0;
        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'] ?? 0;
        savedLevelId = json['savedLevelId'] ?? "";
        rowVersion = json['rowVersion'] ?? 0;
        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 = 0;
    String text = "";
    bool? isFinished;

    Todo({this.id=0,this.text="",this.isFinished});
    Todo.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'] ?? 0;
        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 = 0;

    // @DataMember(Order=2)
    int total = 0;

    // @DataMember(Order=3)
    List<Todo> results = [];

    // @DataMember(Order=4)
    Map<String,String?>? meta;

    // @DataMember(Order=5)
    ResponseStatus? responseStatus;

    QueryResponse({this.offset=0,this.total=0,this.results=const [],this.meta,this.responseStatus});
    QueryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        offset = json['offset'] ?? 0;
        total = json['total'] ?? 0;
        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>[]),
});

Dart QueryPlayer DTOs

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

HTTP + XML

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

POST /xml/reply/QueryPlayer HTTP/1.1 
Host: blazor-gallery.servicestack.net 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<QueryPlayer xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyApp.ServiceModel">
  <Skip xmlns="http://schemas.servicestack.net/types">0</Skip>
  <Take xmlns="http://schemas.servicestack.net/types">0</Take>
  <OrderBy xmlns="http://schemas.servicestack.net/types">String</OrderBy>
  <OrderByDesc xmlns="http://schemas.servicestack.net/types">String</OrderByDesc>
  <Include xmlns="http://schemas.servicestack.net/types">String</Include>
  <Fields xmlns="http://schemas.servicestack.net/types">String</Fields>
  <Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns="http://schemas.servicestack.net/types">
    <d2p1:KeyValueOfstringstring>
      <d2p1:Key>String</d2p1:Key>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:KeyValueOfstringstring>
  </Meta>
</QueryPlayer>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<QueryResponseOfPlayertlJ4_P31p xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
  <Offset>0</Offset>
  <Total>0</Total>
  <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/MyApp.ServiceModel">
    <d2p1:Player>
      <CreatedDate>0001-01-01T00:00:00</CreatedDate>
      <CreatedBy>String</CreatedBy>
      <ModifiedDate>0001-01-01T00:00:00</ModifiedDate>
      <ModifiedBy>String</ModifiedBy>
      <DeletedDate>0001-01-01T00:00:00</DeletedDate>
      <DeletedBy>String</DeletedBy>
      <d2p1:Email>String</d2p1:Email>
      <d2p1:FirstName>String</d2p1:FirstName>
      <d2p1:GameItems>
        <d2p1:PlayerGameItem>
          <d2p1:GameItemName>String</d2p1:GameItemName>
          <d2p1:Id>0</d2p1:Id>
          <d2p1:PlayerId>0</d2p1:PlayerId>
        </d2p1:PlayerGameItem>
      </d2p1:GameItems>
      <d2p1:Id>0</d2p1:Id>
      <d2p1:LastName>String</d2p1:LastName>
      <d2p1:PhoneNumbers>
        <d2p1:Phone>
          <d2p1:Ext>String</d2p1:Ext>
          <d2p1:Kind>Home</d2p1:Kind>
          <d2p1:Number>String</d2p1:Number>
        </d2p1:Phone>
      </d2p1:PhoneNumbers>
      <d2p1:Profile>
        <CreatedDate>0001-01-01T00:00:00</CreatedDate>
        <CreatedBy>String</CreatedBy>
        <ModifiedDate>0001-01-01T00:00:00</ModifiedDate>
        <ModifiedBy>String</ModifiedBy>
        <DeletedDate>0001-01-01T00:00:00</DeletedDate>
        <DeletedBy>String</DeletedBy>
        <d2p1:CoverUrl>String</d2p1:CoverUrl>
        <d2p1:Energy>0</d2p1:Energy>
        <d2p1:GamesPlayed>0</d2p1:GamesPlayed>
        <d2p1:HighScore>0</d2p1:HighScore>
        <d2p1:Id>0</d2p1:Id>
        <d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </d2p1:Meta>
        <d2p1:ProfileUrl>String</d2p1:ProfileUrl>
        <d2p1:Region>Africa</d2p1:Region>
        <d2p1:Role>Leader</d2p1:Role>
        <d2p1:Username>String</d2p1:Username>
      </d2p1:Profile>
      <d2p1:ProfileId>0</d2p1:ProfileId>
      <d2p1:RowVersion>0</d2p1:RowVersion>
      <d2p1:SavedLevelId>00000000-0000-0000-0000-000000000000</d2p1:SavedLevelId>
    </d2p1:Player>
  </Results>
  <Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:KeyValueOfstringstring>
      <d2p1:Key>String</d2p1:Key>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:KeyValueOfstringstring>
  </Meta>
  <ResponseStatus>
    <ErrorCode>String</ErrorCode>
    <Message>String</Message>
    <StackTrace>String</StackTrace>
    <Errors>
      <ResponseError>
        <ErrorCode>String</ErrorCode>
        <FieldName>String</FieldName>
        <Message>String</Message>
        <Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </Meta>
      </ResponseError>
    </Errors>
    <Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </Meta>
  </ResponseStatus>
</QueryResponseOfPlayertlJ4_P31p>