Greyhounds.WebApi

<back to all web services

ConfigureGame

The following routes are available for this service:
POST/configure/game
import 'package:servicestack/servicestack.dart';

class RTPStrategies
{
    static const RTPStrategies RNG = const RTPStrategies._(0);
    static const RTPStrategies Default = const RTPStrategies._(1);

    final int _value;
    const RTPStrategies._(this._value);
    int get value => _value;
    static List<RTPStrategies> get values => const [RNG,Default];
}

class RoundConfiguration implements IConvertible
{
    int countdownDurationInSeconds = 0;
    int raceDurationInSeconds = 0;
    int resultsDurationInSeconds = 0;
    RTPStrategies rtpStrategy;

    RoundConfiguration({this.countdownDurationInSeconds,this.raceDurationInSeconds,this.resultsDurationInSeconds,this.rtpStrategy});
    RoundConfiguration.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        countdownDurationInSeconds = json['countdownDurationInSeconds'];
        raceDurationInSeconds = json['raceDurationInSeconds'];
        resultsDurationInSeconds = json['resultsDurationInSeconds'];
        rtpStrategy = JsonConverters.fromJson(json['rtpStrategy'],'RTPStrategies',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'countdownDurationInSeconds': countdownDurationInSeconds,
        'raceDurationInSeconds': raceDurationInSeconds,
        'resultsDurationInSeconds': resultsDurationInSeconds,
        'rtpStrategy': JsonConverters.toJson(rtpStrategy,'RTPStrategies',context!)
    };

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

class GameConfiguration implements IConvertible
{
    String? id;
    int queueSize = 0;
    RoundConfiguration? roundConfiguration;

    GameConfiguration({this.id,this.queueSize,this.roundConfiguration});
    GameConfiguration.fromJson(Map<String, dynamic> json) { fromMap(json); }

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

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

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

class ConfigureGame implements IConvertible
{
    String? id;
    GameConfiguration? configuration;

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

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

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

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

TypeContext _ctx = TypeContext(library: 'grh1.api.bettor.webhop.biz', types: <String, TypeInfo> {
    'RTPStrategies': TypeInfo(TypeOf.Enum, enumValues:RTPStrategies.values),
    'RoundConfiguration': TypeInfo(TypeOf.Class, create:() => RoundConfiguration()),
    'GameConfiguration': TypeInfo(TypeOf.Class, create:() => GameConfiguration()),
    'ConfigureGame': TypeInfo(TypeOf.Class, create:() => ConfigureGame()),
});

Dart ConfigureGame 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 /configure/game HTTP/1.1 
Host: grh1.api.bettor.webhop.biz 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	id: String,
	configuration: 
	{
		queueSize: 0,
		roundConfiguration: 
		{
			countdownDurationInSeconds: 0,
			raceDurationInSeconds: 0,
			resultsDurationInSeconds: 0
		},
		rtpStrategy: 0
	}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	errorCode: String,
	message: String,
	stackTrace: String,
	errors: 
	[
		{
			errorCode: String,
			fieldName: String,
			message: String,
			meta: 
			{
				String: String
			}
		}
	],
	meta: 
	{
		String: String
	}
}