You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
8.2 KiB

// Generated from ../schema.json. Do not edit.
// Structural DTOs; schema and semantic validation are separate.
typedef UUID = String;
typedef Revision = int;
typedef Instant = String;
typedef Locale = String;
typedef ErrorCode = String;
typedef MessageArgument = Object;
typedef MessageArgs = Map<String, MessageArgument>;
class LocalizedMessage {
final String key;
final MessageArgs args;
const LocalizedMessage({required this.key, required this.args});
factory LocalizedMessage.fromJson(Map<String, dynamic> json) => LocalizedMessage(
key: _required(json, 'key') as String,
args: _object(_required(json, 'args')).map((key, item) => MapEntry(key, _argument(item))),
);
Map<String, dynamic> toJson() => {
'key': key,
'args': args,
};
}
typedef ErrorOrigin = String;
typedef ErrorCategory = String;
typedef OperationOutcome = String;
typedef RecoveryAction = String;
class Recovery {
final RecoveryAction action;
final int? retryAfterMs;
const Recovery({required this.action, this.retryAfterMs});
factory Recovery.fromJson(Map<String, dynamic> json) => Recovery(
action: _required(json, 'action') as String,
retryAfterMs: json['retryAfterMs'] == null ? null : json['retryAfterMs'] as int,
);
Map<String, dynamic> toJson() => {
'action': action,
if (retryAfterMs != null) 'retryAfterMs': retryAfterMs,
};
}
class Violation {
final String pointer;
final ErrorCode code;
final LocalizedMessage message;
const Violation({required this.pointer, required this.code, required this.message});
factory Violation.fromJson(Map<String, dynamic> json) => Violation(
pointer: _required(json, 'pointer') as String,
code: _required(json, 'code') as String,
message: LocalizedMessage.fromJson(_object(_required(json, 'message'))),
);
Map<String, dynamic> toJson() => {
'pointer': pointer,
'code': code,
'message': message.toJson(),
};
}
class ErrorData {
final int modelVersion;
final ErrorOrigin origin;
final ErrorCode code;
final ErrorCategory category;
final OperationOutcome outcome;
final LocalizedMessage message;
final Recovery recovery;
final List<Violation> violations;
const ErrorData({required this.modelVersion, required this.origin, required this.code, required this.category, required this.outcome, required this.message, required this.recovery, required this.violations});
factory ErrorData.fromJson(Map<String, dynamic> json) => ErrorData(
modelVersion: _required(json, 'modelVersion') as int,
origin: _required(json, 'origin') as String,
code: _required(json, 'code') as String,
category: _required(json, 'category') as String,
outcome: _required(json, 'outcome') as String,
message: LocalizedMessage.fromJson(_object(_required(json, 'message'))),
recovery: Recovery.fromJson(_object(_required(json, 'recovery'))),
violations: (_required(json, 'violations') as List).map((item) => Violation.fromJson(_object(item))).toList(),
);
Map<String, dynamic> toJson() => {
'modelVersion': modelVersion,
'origin': origin,
'code': code,
'category': category,
'outcome': outcome,
'message': message.toJson(),
'recovery': recovery.toJson(),
'violations': violations.map((item) => item.toJson()).toList(),
};
}
class Correlation {
final UUID? requestId;
final UUID? commandId;
final UUID? operationId;
final UUID? subscriptionId;
const Correlation({this.requestId, this.commandId, this.operationId, this.subscriptionId});
factory Correlation.fromJson(Map<String, dynamic> json) => Correlation(
requestId: json['requestId'] == null ? null : json['requestId'] as String,
commandId: json['commandId'] == null ? null : json['commandId'] as String,
operationId: json['operationId'] == null ? null : json['operationId'] as String,
subscriptionId: json['subscriptionId'] == null ? null : json['subscriptionId'] as String,
);
Map<String, dynamic> toJson() => {
if (requestId != null) 'requestId': requestId,
if (commandId != null) 'commandId': commandId,
if (operationId != null) 'operationId': operationId,
if (subscriptionId != null) 'subscriptionId': subscriptionId,
};
}
class HttpProblem {
final String type;
final String title;
final int status;
final Correlation correlation;
final ErrorData error;
const HttpProblem({required this.type, required this.title, required this.status, required this.correlation, required this.error});
factory HttpProblem.fromJson(Map<String, dynamic> json) => HttpProblem(
type: _required(json, 'type') as String,
title: _required(json, 'title') as String,
status: _required(json, 'status') as int,
correlation: Correlation.fromJson(_object(_required(json, 'correlation'))),
error: ErrorData.fromJson(_object(_required(json, 'error'))),
);
Map<String, dynamic> toJson() => {
'type': type,
'title': title,
'status': status,
'correlation': correlation.toJson(),
'error': error.toJson(),
};
}
class ErrorMessagePayload {
final Correlation correlation;
final ErrorData error;
const ErrorMessagePayload({required this.correlation, required this.error});
factory ErrorMessagePayload.fromJson(Map<String, dynamic> json) => ErrorMessagePayload(
correlation: Correlation.fromJson(_object(_required(json, 'correlation'))),
error: ErrorData.fromJson(_object(_required(json, 'error'))),
);
Map<String, dynamic> toJson() => {
'correlation': correlation.toJson(),
'error': error.toJson(),
};
}
class CommandRejection {
final String status;
final ErrorData error;
const CommandRejection({required this.status, required this.error});
factory CommandRejection.fromJson(Map<String, dynamic> json) => CommandRejection(
status: _required(json, 'status') as String,
error: ErrorData.fromJson(_object(_required(json, 'error'))),
);
Map<String, dynamic> toJson() => {
'status': status,
'error': error.toJson(),
};
}
class GameCard {
final String id;
final String version;
final String title;
final String summary;
final Locale locale;
final int minPlayers;
final int maxPlayers;
const GameCard({required this.id, required this.version, required this.title, required this.summary, required this.locale, required this.minPlayers, required this.maxPlayers});
factory GameCard.fromJson(Map<String, dynamic> json) => GameCard(
id: _required(json, 'id') as String,
version: _required(json, 'version') as String,
title: _required(json, 'title') as String,
summary: _required(json, 'summary') as String,
locale: _required(json, 'locale') as String,
minPlayers: _required(json, 'minPlayers') as int,
maxPlayers: _required(json, 'maxPlayers') as int,
);
Map<String, dynamic> toJson() => {
'id': id,
'version': version,
'title': title,
'summary': summary,
'locale': locale,
'minPlayers': minPlayers,
'maxPlayers': maxPlayers,
};
}
class CatalogPage {
final List<GameCard> items;
final String? nextCursor;
const CatalogPage({required this.items, required this.nextCursor});
factory CatalogPage.fromJson(Map<String, dynamic> json) => CatalogPage(
items: (_required(json, 'items') as List).map((item) => GameCard.fromJson(_object(item))).toList(),
nextCursor: _required(json, 'nextCursor') == null ? null : _required(json, 'nextCursor') as String,
);
Map<String, dynamic> toJson() => {
'items': items.map((item) => item.toJson()).toList(),
'nextCursor': nextCursor,
};
}
class CatalogResponse {
final UUID requestId;
final CatalogPage data;
const CatalogResponse({required this.requestId, required this.data});
factory CatalogResponse.fromJson(Map<String, dynamic> json) => CatalogResponse(
requestId: _required(json, 'requestId') as String,
data: CatalogPage.fromJson(_object(_required(json, 'data'))),
);
Map<String, dynamic> toJson() => {
'requestId': requestId,
'data': data.toJson(),
};
}
dynamic _required(Map<String, dynamic> json, String key) {
if (!json.containsKey(key)) throw FormatException('Missing field: $key');
return json[key];
}
Map<String, dynamic> _object(dynamic value) => Map<String, dynamic>.from(value as Map);
Object _argument(dynamic value) {
if (value is String || value is bool || (value is num && value.isFinite)) return value as Object;
throw const FormatException('Invalid message argument');
}

Powered by TurnKey Linux.