MyApp

<back to all web services

QueryPlayerGameItem

Game
import Foundation
import ServiceStack

public class QueryPlayerGameItem : QueryDb<PlayerGameItem>
{
    public var id:Int?
    public var playerId:Int?
    public var gameItemName:String

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case id
        case playerId
        case gameItemName
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        id = try container.decodeIfPresent(Int.self, forKey: .id)
        playerId = try container.decodeIfPresent(Int.self, forKey: .playerId)
        gameItemName = try container.decodeIfPresent(String.self, forKey: .gameItemName)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if id != nil { try container.encode(id, forKey: .id) }
        if playerId != nil { try container.encode(playerId, forKey: .playerId) }
        if gameItemName != nil { try container.encode(gameItemName, forKey: .gameItemName) }
    }
}

public class PlayerGameItem : Codable
{
    public var id:Int
    // @References(typeof(Player))
    public var playerId:Int

    // @References(typeof(GameItem))
    public var gameItemName:String

    required public init(){}
}

public class Todo : Codable
{
    public var id:Int
    public var text:String
    public var isFinished:Bool

    required public init(){}
}


Swift QueryPlayerGameItem DTOs

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

HTTP + JSV

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

POST /jsv/reply/QueryPlayerGameItem HTTP/1.1 
Host: blazor-gallery.servicestack.net 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	id: 0,
	playerId: 0,
	gameItemName: String,
	skip: 0,
	take: 0,
	orderBy: String,
	orderByDesc: String,
	include: String,
	fields: String,
	meta: 
	{
		String: String
	}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	offset: 0,
	total: 0,
	results: 
	[
		{
			id: 0,
			playerId: 0,
			gameItemName: String
		}
	],
	meta: 
	{
		String: String
	},
	responseStatus: 
	{
		errorCode: String,
		message: String,
		stackTrace: String,
		errors: 
		[
			{
				errorCode: String,
				fieldName: String,
				message: String,
				meta: 
				{
					String: String
				}
			}
		],
		meta: 
		{
			String: String
		}
	}
}