// @DataContract
export class QueryBase
{
// @DataMember(Order=1)
public skip?: number;
// @DataMember(Order=2)
public take?: number;
// @DataMember(Order=3)
public orderBy: string;
// @DataMember(Order=4)
public orderByDesc: string;
// @DataMember(Order=5)
public include: string;
// @DataMember(Order=6)
public fields: string;
// @DataMember(Order=7)
public meta: { [index:string]: string; };
public constructor(init?: Partial<QueryBase>) { (Object as any).assign(this, init); }
}
export class QueryDb<T> extends QueryBase
{
public constructor(init?: Partial<QueryDb<T>>) { super(init); (Object as any).assign(this, init); }
}
// @DataContract
export class AuditBase
{
// @DataMember(Order=1)
public createdDate: string;
// @DataMember(Order=2)
// @Required()
public createdBy: string;
// @DataMember(Order=3)
public modifiedDate: string;
// @DataMember(Order=4)
// @Required()
public modifiedBy: string;
// @DataMember(Order=5)
public deletedDate?: string;
// @DataMember(Order=6)
public deletedBy: string;
public constructor(init?: Partial<AuditBase>) { (Object as any).assign(this, init); }
}
export enum PhoneKind
{
Home = 'Home',
Mobile = 'Mobile',
Work = 'Work',
}
export class Phone
{
public kind: PhoneKind;
public number: string;
public ext: string;
public constructor(init?: Partial<Phone>) { (Object as any).assign(this, init); }
}
export class PlayerGameItem
{
public id: number;
// @References("typeof(MyApp.ServiceModel.Player)")
public playerId: number;
// @References("typeof(MyApp.ServiceModel.GameItem)")
public gameItemName: string;
public constructor(init?: Partial<PlayerGameItem>) { (Object as any).assign(this, init); }
}
export enum PlayerRole
{
Leader = 'Leader',
Player = 'Player',
NonPlayer = 'NonPlayer',
}
export enum PlayerRegion
{
Africa = 1,
Americas = 2,
Asia = 3,
Australasia = 4,
Europe = 5,
}
export class Profile extends AuditBase
{
public id: number;
public role: PlayerRole;
public region: PlayerRegion;
public username?: string;
public highScore: number;
public gamesPlayed: number;
public energy: number;
public profileUrl?: string;
public coverUrl?: string;
public meta?: { [index:string]: string; };
public constructor(init?: Partial<Profile>) { super(init); (Object as any).assign(this, init); }
}
export class Player extends AuditBase
{
public id: number;
// @Required()
public firstName: string;
public lastName: string;
public email: string;
public phoneNumbers: Phone[] = [];
public gameItems: PlayerGameItem[] = [];
public profile: Profile;
public profileId: number;
public savedLevelId: string;
public rowVersion: number;
public constructor(init?: Partial<Player>) { super(init); (Object as any).assign(this, init); }
}
export class QueryPlayer extends QueryDb<Player>
{
public constructor(init?: Partial<QueryPlayer>) { super(init); (Object as any).assign(this, init); }
}
export class Todo
{
public id: number;
public text: string;
public isFinished: boolean;
public constructor(init?: Partial<Todo>) { (Object as any).assign(this, init); }
}
// @DataContract
export class QueryResponse<T>
{
// @DataMember(Order=1)
public offset: number;
// @DataMember(Order=2)
public total: number;
// @DataMember(Order=3)
public results: Todo[];
// @DataMember(Order=4)
public meta: { [index:string]: string; };
// @DataMember(Order=5)
public responseStatus: ResponseStatus;
public constructor(init?: Partial<QueryResponse<T>>) { (Object as any).assign(this, init); }
}
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"}}}