MyApp

<back to all web services

QueryProfile

Game
#![allow(
    dead_code,
    non_camel_case_types,
    non_snake_case,
    clippy::upper_case_acronyms
)]

use serde::{Deserialize, Serialize};
use serde_json::Value;
use servicestack::*;
use std::collections::HashMap;

#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum PlayerRole {
    #[default]
    #[serde(rename = "Leader")]
    Leader,
    #[serde(rename = "Player")]
    Player,
    #[serde(rename = "NonPlayer")]
    NonPlayer,
}

#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum PlayerRegion {
    #[default]
    #[serde(rename = "Africa")]
    Africa,
    #[serde(rename = "Americas")]
    Americas,
    #[serde(rename = "Asia")]
    Asia,
    #[serde(rename = "Australasia")]
    Australasia,
    #[serde(rename = "Europe")]
    Europe,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
#[serde(default)]
pub struct Profile {
    #[serde(flatten)]
    pub audit_base: AuditBase,
    pub id: i32,
    pub role: PlayerRole,
    pub region: PlayerRegion,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    #[serde(rename = "highScore")]
    pub high_score: i64,
    #[serde(rename = "gamesPlayed")]
    pub games_played: i64,
    pub energy: i32,
    #[serde(rename = "profileUrl")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub profile_url: Option<String>,
    #[serde(rename = "coverUrl")]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cover_url: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<HashMap<String, String>>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
#[serde(default)]
pub struct QueryProfile {
    #[serde(flatten)]
    pub query_db: QueryDb,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
#[serde(default)]
pub struct Todo {
    pub id: i64,
    pub text: String,
    #[serde(rename = "isFinished")]
    pub is_finished: bool,
}

Rust QueryProfile 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/QueryProfile 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,"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"}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}