skinLicenses.jsonl
Schema
_key
(required): integer
Range: 34599 .. 90126duration
(required): integer
Range: -1 .. 365isSingleUse
: booleanlicenseTypeID
(required): integer
Range: 34599 .. 90126skinID
(required): integer
Range: 5 .. 12585
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var skinLicense = SkinLicense.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class SkinLicense
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("duration")]
public long Duration { get; set; }
[JsonProperty("isSingleUse", NullValueHandling = NullValueHandling.Ignore)]
public bool? IsSingleUse { get; set; }
[JsonProperty("licenseTypeID")]
public long LicenseTypeId { get; set; }
[JsonProperty("skinID")]
public long SkinId { get; set; }
}
public partial class SkinLicense
{
public static SkinLicense FromJson(string json) => JsonConvert.DeserializeObject<SkinLicense>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this SkinLicense self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}
// Code generated from JSON Schema using quicktype. DO NOT EDIT.
// To parse and unparse this JSON data, add this code to your project and do:
//
// skinLicense, err := UnmarshalSkinLicense(bytes)
// bytes, err = skinLicense.Marshal()
package model
import "encoding/json"
func UnmarshalSkinLicense(data []byte) (SkinLicense, error) {
var r SkinLicense
err := json.Unmarshal(data, &r)
return r, err
}
func (r *SkinLicense) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type SkinLicense struct {
Key int64 `json:"_key"`
Duration int64 `json:"duration"`
IsSingleUse *bool `json:"isSingleUse,omitempty"`
LicenseTypeID int64 `json:"licenseTypeID"`
SkinID int64 `json:"skinID"`
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"_key": {
"type": "integer",
"minimum": 34599,
"maximum": 90126
},
"duration": {
"type": "integer",
"minimum": -1,
"maximum": 365
},
"isSingleUse": {
"type": "boolean"
},
"licenseTypeID": {
"type": "integer",
"minimum": 34599,
"maximum": 90126
},
"skinID": {
"type": "integer",
"minimum": 5,
"maximum": 12585
}
},
"required": [
"_key",
"duration",
"licenseTypeID",
"skinID"
]
}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val skinLicense = json.parse(SkinLicense.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class SkinLicense (
@SerialName("_key")
val key: Long,
val duration: Long,
val isSingleUse: Boolean? = null,
@SerialName("licenseTypeID")
val licenseTypeId: Long,
@SerialName("skinID")
val skinId: Long
)
<?php
// This is a autogenerated file:SkinLicense
class SkinLicense {
private int $key; // json:_key Required
private int $duration; // json:duration Required
private ?bool $isSingleUse; // json:isSingleUse Optional
private int $licenseTypeId; // json:licenseTypeID Required
private int $skinId; // json:skinID Required
/**
* @param int $key
* @param int $duration
* @param bool|null $isSingleUse
* @param int $licenseTypeId
* @param int $skinId
*/
public function __construct(int $key, int $duration, ?bool $isSingleUse, int $licenseTypeId, int $skinId) {
$this->key = $key;
$this->duration = $duration;
$this->isSingleUse = $isSingleUse;
$this->licenseTypeId = $licenseTypeId;
$this->skinId = $skinId;
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromKey(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toKey(): int {
if (SkinLicense::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this SkinLicense::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SkinLicense::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (SkinLicense::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey SkinLicense::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromDuration(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toDuration(): int {
if (SkinLicense::validateDuration($this->duration)) {
return $this->duration; /*int*/
}
throw new Exception('never get to this SkinLicense::duration');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateDuration(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SkinLicense::duration");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getDuration(): int {
if (SkinLicense::validateDuration($this->duration)) {
return $this->duration;
}
throw new Exception('never get to getDuration SkinLicense::duration');
}
/**
* @return int
*/
public static function sampleDuration(): int {
return 32; /*32:duration*/
}
/**
* @param ?bool $value
* @throws Exception
* @return ?bool
*/
public static function fromIsSingleUse(?bool $value): ?bool {
if (!is_null($value)) {
return $value; /*bool*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?bool
*/
public function toIsSingleUse(): ?bool {
if (SkinLicense::validateIsSingleUse($this->isSingleUse)) {
if (!is_null($this->isSingleUse)) {
return $this->isSingleUse; /*bool*/
} else {
return null;
}
}
throw new Exception('never get to this SkinLicense::isSingleUse');
}
/**
* @param bool|null
* @return bool
* @throws Exception
*/
public static function validateIsSingleUse(?bool $value): bool {
if (!is_null($value)) {
if (!is_bool($value)) {
throw new Exception("Attribute Error:SkinLicense::isSingleUse");
}
}
return true;
}
/**
* @throws Exception
* @return ?bool
*/
public function getIsSingleUse(): ?bool {
if (SkinLicense::validateIsSingleUse($this->isSingleUse)) {
return $this->isSingleUse;
}
throw new Exception('never get to getIsSingleUse SkinLicense::isSingleUse');
}
/**
* @return ?bool
*/
public static function sampleIsSingleUse(): ?bool {
return true; /*33:isSingleUse*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromLicenseTypeId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toLicenseTypeId(): int {
if (SkinLicense::validateLicenseTypeId($this->licenseTypeId)) {
return $this->licenseTypeId; /*int*/
}
throw new Exception('never get to this SkinLicense::licenseTypeId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateLicenseTypeId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SkinLicense::licenseTypeId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getLicenseTypeId(): int {
if (SkinLicense::validateLicenseTypeId($this->licenseTypeId)) {
return $this->licenseTypeId;
}
throw new Exception('never get to getLicenseTypeId SkinLicense::licenseTypeId');
}
/**
* @return int
*/
public static function sampleLicenseTypeId(): int {
return 34; /*34:licenseTypeId*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromSkinId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toSkinId(): int {
if (SkinLicense::validateSkinId($this->skinId)) {
return $this->skinId; /*int*/
}
throw new Exception('never get to this SkinLicense::skinId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateSkinId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SkinLicense::skinId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getSkinId(): int {
if (SkinLicense::validateSkinId($this->skinId)) {
return $this->skinId;
}
throw new Exception('never get to getSkinId SkinLicense::skinId');
}
/**
* @return int
*/
public static function sampleSkinId(): int {
return 35; /*35:skinId*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return SkinLicense::validateKey($this->key)
|| SkinLicense::validateDuration($this->duration)
|| SkinLicense::validateIsSingleUse($this->isSingleUse)
|| SkinLicense::validateLicenseTypeId($this->licenseTypeId)
|| SkinLicense::validateSkinId($this->skinId);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'duration'} = $this->toDuration();
$out->{'isSingleUse'} = $this->toIsSingleUse();
$out->{'licenseTypeID'} = $this->toLicenseTypeId();
$out->{'skinID'} = $this->toSkinId();
return $out;
}
/**
* @param stdClass $obj
* @return SkinLicense
* @throws Exception
*/
public static function from(stdClass $obj): SkinLicense {
return new SkinLicense(
SkinLicense::fromKey($obj->{'_key'})
,SkinLicense::fromDuration($obj->{'duration'})
,SkinLicense::fromIsSingleUse($obj->{'isSingleUse'})
,SkinLicense::fromLicenseTypeId($obj->{'licenseTypeID'})
,SkinLicense::fromSkinId($obj->{'skinID'})
);
}
/**
* @return SkinLicense
*/
public static function sample(): SkinLicense {
return new SkinLicense(
SkinLicense::sampleKey()
,SkinLicense::sampleDuration()
,SkinLicense::sampleIsSingleUse()
,SkinLicense::sampleLicenseTypeId()
,SkinLicense::sampleSkinId()
);
}
}
from typing import Optional, Any, TypeVar, Type, cast
T = TypeVar("T")
def from_int(x: Any) -> int:
assert isinstance(x, int) and not isinstance(x, bool)
return x
def from_bool(x: Any) -> bool:
assert isinstance(x, bool)
return x
def from_none(x: Any) -> Any:
assert x is None
return x
def from_union(fs, x):
for f in fs:
try:
return f(x)
except:
pass
assert False
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
class SkinLicense:
key: int
duration: int
is_single_use: Optional[bool]
license_type_id: int
skin_id: int
def __init__(self, key: int, duration: int, is_single_use: Optional[bool], license_type_id: int, skin_id: int) -> None:
self.key = key
self.duration = duration
self.is_single_use = is_single_use
self.license_type_id = license_type_id
self.skin_id = skin_id
@staticmethod
def from_dict(obj: Any) -> 'SkinLicense':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
duration = from_int(obj.get("duration"))
is_single_use = from_union([from_bool, from_none], obj.get("isSingleUse"))
license_type_id = from_int(obj.get("licenseTypeID"))
skin_id = from_int(obj.get("skinID"))
return SkinLicense(key, duration, is_single_use, license_type_id, skin_id)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["duration"] = from_int(self.duration)
if self.is_single_use is not None:
result["isSingleUse"] = from_union([from_bool, from_none], self.is_single_use)
result["licenseTypeID"] = from_int(self.license_type_id)
result["skinID"] = from_int(self.skin_id)
return result
def skin_license_from_dict(s: Any) -> SkinLicense:
return SkinLicense.from_dict(s)
def skin_license_to_dict(x: SkinLicense) -> Any:
return to_class(SkinLicense, x)
// To parse this data:
//
// import { Convert, SkinLicense } from "./file";
//
// const skinLicense = Convert.toSkinLicense(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface SkinLicense {
_key: number;
duration: number;
isSingleUse?: boolean;
licenseTypeID: number;
skinID: number;
[property: string]: any;
}
// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
public static toSkinLicense(json: string): SkinLicense {
return cast(JSON.parse(json), r("SkinLicense"));
}
public static skinLicenseToJson(value: SkinLicense): string {
return JSON.stringify(uncast(value, r("SkinLicense")), null, 2);
}
}
function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
const prettyTyp = prettyTypeName(typ);
const parentText = parent ? ` on ${parent}` : '';
const keyText = key ? ` for key "${key}"` : '';
throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
}
function prettyTypeName(typ: any): string {
if (Array.isArray(typ)) {
if (typ.length === 2 && typ[0] === undefined) {
return `an optional ${prettyTypeName(typ[1])}`;
} else {
return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
}
} else if (typeof typ === "object" && typ.literal !== undefined) {
return typ.literal;
} else {
return typeof typ;
}
}
function jsonToJSProps(typ: any): any {
if (typ.jsonToJS === undefined) {
const map: any = {};
typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
typ.jsonToJS = map;
}
return typ.jsonToJS;
}
function jsToJSONProps(typ: any): any {
if (typ.jsToJSON === undefined) {
const map: any = {};
typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
typ.jsToJSON = map;
}
return typ.jsToJSON;
}
function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
function transformPrimitive(typ: string, val: any): any {
if (typeof typ === typeof val) return val;
return invalidValue(typ, val, key, parent);
}
function transformUnion(typs: any[], val: any): any {
// val must validate against one typ in typs
const l = typs.length;
for (let i = 0; i < l; i++) {
const typ = typs[i];
try {
return transform(val, typ, getProps);
} catch (_) {}
}
return invalidValue(typs, val, key, parent);
}
function transformEnum(cases: string[], val: any): any {
if (cases.indexOf(val) !== -1) return val;
return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
}
function transformArray(typ: any, val: any): any {
// val must be an array with no invalid elements
if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
return val.map(el => transform(el, typ, getProps));
}
function transformDate(val: any): any {
if (val === null) {
return null;
}
const d = new Date(val);
if (isNaN(d.valueOf())) {
return invalidValue(l("Date"), val, key, parent);
}
return d;
}
function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
if (val === null || typeof val !== "object" || Array.isArray(val)) {
return invalidValue(l(ref || "object"), val, key, parent);
}
const result: any = {};
Object.getOwnPropertyNames(props).forEach(key => {
const prop = props[key];
const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
result[prop.key] = transform(v, prop.typ, getProps, key, ref);
});
Object.getOwnPropertyNames(val).forEach(key => {
if (!Object.prototype.hasOwnProperty.call(props, key)) {
result[key] = transform(val[key], additional, getProps, key, ref);
}
});
return result;
}
if (typ === "any") return val;
if (typ === null) {
if (val === null) return val;
return invalidValue(typ, val, key, parent);
}
if (typ === false) return invalidValue(typ, val, key, parent);
let ref: any = undefined;
while (typeof typ === "object" && typ.ref !== undefined) {
ref = typ.ref;
typ = typeMap[typ.ref];
}
if (Array.isArray(typ)) return transformEnum(typ, val);
if (typeof typ === "object") {
return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
: typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
: typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
: invalidValue(typ, val, key, parent);
}
// Numbers can be parsed by Date but shouldn't be.
if (typ === Date && typeof val !== "number") return transformDate(val);
return transformPrimitive(typ, val);
}
function cast<T>(val: any, typ: any): T {
return transform(val, typ, jsonToJSProps);
}
function uncast<T>(val: T, typ: any): any {
return transform(val, typ, jsToJSONProps);
}
function l(typ: any) {
return { literal: typ };
}
function a(typ: any) {
return { arrayItems: typ };
}
function u(...typs: any[]) {
return { unionMembers: typs };
}
function o(props: any[], additional: any) {
return { props, additional };
}
function m(additional: any) {
return { props: [], additional };
}
function r(name: string) {
return { ref: name };
}
const typeMap: any = {
"SkinLicense": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "duration", js: "duration", typ: 0 },
{ json: "isSingleUse", js: "isSingleUse", typ: u(undefined, true) },
{ json: "licenseTypeID", js: "licenseTypeID", typ: 0 },
{ json: "skinID", js: "skinID", typ: 0 },
], "any"),
};