Skip to content

EVE SDE Schema

Documentation for third-party developers

industryTargetFilters.jsonl

Schema

  • _key (required): integer
    Range: 1 .. 18
  • categoryIDs: array of integer
    Type: integer
    Range: 6 .. 87
  • groupIDs: array of integer
    Type: integer
    Range: 12 .. 5120
  • name (required): string

Code snippets

// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
//    using QuickType;
//
//    var industryTargetFilter = IndustryTargetFilter.FromJson(jsonString);
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8602
#pragma warning disable CS8603

namespace QuickType
{
    using System;
    using System.Collections.Generic;

    using System.Text.Json;
    using System.Text.Json.Serialization;
    using System.Globalization;

    public partial class IndustryTargetFilter
    {
        [JsonPropertyName("_key")]
        public long Key { get; set; }

        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
        [JsonPropertyName("categoryIDs")]
        public long[]? CategoryIDs { get; set; }

        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
        [JsonPropertyName("groupIDs")]
        public long[]? GroupIDs { get; set; }

        [JsonPropertyName("name")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter))]
        public string Name { get; set; }
    }

    public partial class IndustryTargetFilter
    {
        public static IndustryTargetFilter FromJson(string json) => JsonSerializer.Deserialize<IndustryTargetFilter>(json, QuickType.Converter.Settings);
    }

    public static class Serialize
    {
        public static string ToJson(this IndustryTargetFilter self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
    }

    internal static class Converter
    {
        public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
        {
            Converters =
            {
                new DateOnlyConverter(),
                new TimeOnlyConverter(),
                IsoDateTimeOffsetConverter.Singleton
            },
        };
    }

    internal class MinMaxLengthCheckConverter : JsonConverter<string>
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var value = reader.GetString();
            if (value.Length >= 5 && value.Length <= 27)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
        {
            if (value.Length >= 5 && value.Length <= 27)
            {
                JsonSerializer.Serialize(writer, value, options);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter Singleton = new MinMaxLengthCheckConverter();
    }

    public class DateOnlyConverter : JsonConverter<DateOnly>
    {
        private readonly string serializationFormat;
        public DateOnlyConverter() : this(null) { }

        public DateOnlyConverter(string? serializationFormat)
        {
                this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
        }

        public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
                var value = reader.GetString();
                return DateOnly.Parse(value!);
        }

        public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
                => writer.WriteStringValue(value.ToString(serializationFormat));
    }

    public class TimeOnlyConverter : JsonConverter<TimeOnly>
    {
        private readonly string serializationFormat;

        public TimeOnlyConverter() : this(null) { }

        public TimeOnlyConverter(string? serializationFormat)
        {
                this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
        }

        public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
                var value = reader.GetString();
                return TimeOnly.Parse(value!);
        }

        public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
                => writer.WriteStringValue(value.ToString(serializationFormat));
    }

    internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
    {
        public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);

        private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";

        private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
        private string? _dateTimeFormat;
        private CultureInfo? _culture;

        public DateTimeStyles DateTimeStyles
        {
                get => _dateTimeStyles;
                set => _dateTimeStyles = value;
        }

        public string? DateTimeFormat
        {
                get => _dateTimeFormat ?? string.Empty;
                set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
        }

        public CultureInfo Culture
        {
                get => _culture ?? CultureInfo.CurrentCulture;
                set => _culture = value;
        }

        public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
        {
                string text;


                if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
                        || (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
                {
                        value = value.ToUniversalTime();
                }

                text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);

                writer.WriteStringValue(text);
        }

        public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
                string? dateText = reader.GetString();

                if (string.IsNullOrEmpty(dateText) == false)
                {
                        if (!string.IsNullOrEmpty(_dateTimeFormat))
                        {
                                return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
                        }
                        else
                        {
                                return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
                        }
                }
                else
                {
                        return default(DateTimeOffset);
                }
        }


        public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
    }
}
#pragma warning restore CS8618
#pragma warning restore CS8601
#pragma warning restore CS8602
#pragma warning restore CS8603
// 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:
//
//    industryTargetFilter, err := UnmarshalIndustryTargetFilter(bytes)
//    bytes, err = industryTargetFilter.Marshal()

package model

import "encoding/json"

func UnmarshalIndustryTargetFilter(data []byte) (IndustryTargetFilter, error) {
    var r IndustryTargetFilter
    err := json.Unmarshal(data, &r)
    return r, err
}

func (r *IndustryTargetFilter) Marshal() ([]byte, error) {
    return json.Marshal(r)
}

type IndustryTargetFilter struct {
    Key         int64   `json:"_key"`
    CategoryIDs []int64 `json:"categoryIDs,omitempty"`
    GroupIDs    []int64 `json:"groupIDs,omitempty"`
    Name        string  `json:"name"`
}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"_key":{"type":"integer","minimum":1,"maximum":18},"categoryIDs":{"type":"array","items":{"type":"integer","minimum":6,"maximum":87},"minItems":1,"maxItems":5},"groupIDs":{"type":"array","items":{"type":"integer","minimum":12,"maximum":5120},"minItems":1,"maxItems":12},"name":{"type":"string","minLength":5,"maxLength":27}},"required":["_key","name"]}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json                 = Json { allowStructuredMapKeys = true }
// val industryTargetFilter = json.parse(IndustryTargetFilter.serializer(), jsonString)

package model

import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*

@Serializable
data class IndustryTargetFilter (
    @SerialName("_key")
    val key: Long,

    val categoryIDs: List<Long>? = null,
    val groupIDs: List<Long>? = null,
    val name: String
)
<?php

// This is an autogenerated file:IndustryTargetFilter

class IndustryTargetFilter {
    private int $key; // json:_key Required
    private ?array $categoryIDs; // json:categoryIDs Optional
    private ?array $groupIDs; // json:groupIDs Optional
    private string $name; // json:name Required

    /**
     * @param int $key
     * @param array|null $categoryIDs
     * @param array|null $groupIDs
     * @param string $name
     */
    public function __construct(int $key, ?array $categoryIDs, ?array $groupIDs, string $name) {
        $this->key = $key;
        $this->categoryIDs = $categoryIDs;
        $this->groupIDs = $groupIDs;
        $this->name = $name;
    }

    /**
     * @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 (IndustryTargetFilter::validateKey($this->key))  {
            return $this->key; /*int*/
        }
        throw new Exception('never get to this IndustryTargetFilter::key');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateKey(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:IndustryTargetFilter::key");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getKey(): int {
        if (IndustryTargetFilter::validateKey($this->key))  {
            return $this->key;
        }
        throw new Exception('never get to getKey IndustryTargetFilter::key');
    }

    /**
     * @return int
     */
    public static function sampleKey(): int {
        return 31; /*31:key*/
    }

    /**
     * @param ?array $value
     * @throws Exception
     * @return ?array
     */
    public static function fromCategoryIDs(?array $value): ?array {
        if (!is_null($value)) {
            return  array_map(function ($value) {
                return $value; /*int*/
            }, $value);
        } else {
            return  null;
        }
    }

    /**
     * @throws Exception
     * @return ?array
     */
    public function toCategoryIDs(): ?array {
        if (IndustryTargetFilter::validateCategoryIDs($this->categoryIDs))  {
            if (!is_null($this->categoryIDs)) {
                return array_map(function ($value) {
                    return $value; /*int*/
                }, $this->categoryIDs);
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this IndustryTargetFilter::categoryIDs');
    }

    /**
     * @param array|null
     * @return bool
     * @throws Exception
     */
    public static function validateCategoryIDs(?array $value): bool {
        if (!is_null($value)) {
            if (!is_array($value)) {
                throw new Exception("Attribute Error:IndustryTargetFilter::categoryIDs");
            }
            array_walk($value, function($value_v) {
                if (!is_integer($value_v)) {
                    throw new Exception("Attribute Error:IndustryTargetFilter::categoryIDs");
                }
            });
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?array
     */
    public function getCategoryIDs(): ?array {
        if (IndustryTargetFilter::validateCategoryIDs($this->categoryIDs))  {
            return $this->categoryIDs;
        }
        throw new Exception('never get to getCategoryIDs IndustryTargetFilter::categoryIDs');
    }

    /**
     * @return ?array
     */
    public static function sampleCategoryIDs(): ?array {
        return  array(
            32 /*32:*/
        ); /* 32:categoryIDs*/
    }

    /**
     * @param ?array $value
     * @throws Exception
     * @return ?array
     */
    public static function fromGroupIDs(?array $value): ?array {
        if (!is_null($value)) {
            return  array_map(function ($value) {
                return $value; /*int*/
            }, $value);
        } else {
            return  null;
        }
    }

    /**
     * @throws Exception
     * @return ?array
     */
    public function toGroupIDs(): ?array {
        if (IndustryTargetFilter::validateGroupIDs($this->groupIDs))  {
            if (!is_null($this->groupIDs)) {
                return array_map(function ($value) {
                    return $value; /*int*/
                }, $this->groupIDs);
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this IndustryTargetFilter::groupIDs');
    }

    /**
     * @param array|null
     * @return bool
     * @throws Exception
     */
    public static function validateGroupIDs(?array $value): bool {
        if (!is_null($value)) {
            if (!is_array($value)) {
                throw new Exception("Attribute Error:IndustryTargetFilter::groupIDs");
            }
            array_walk($value, function($value_v) {
                if (!is_integer($value_v)) {
                    throw new Exception("Attribute Error:IndustryTargetFilter::groupIDs");
                }
            });
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?array
     */
    public function getGroupIDs(): ?array {
        if (IndustryTargetFilter::validateGroupIDs($this->groupIDs))  {
            return $this->groupIDs;
        }
        throw new Exception('never get to getGroupIDs IndustryTargetFilter::groupIDs');
    }

    /**
     * @return ?array
     */
    public static function sampleGroupIDs(): ?array {
        return  array(
            33 /*33:*/
        ); /* 33:groupIDs*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromName(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toName(): string {
        if (IndustryTargetFilter::validateName($this->name))  {
            return $this->name; /*string*/
        }
        throw new Exception('never get to this IndustryTargetFilter::name');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateName(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:IndustryTargetFilter::name");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getName(): string {
        if (IndustryTargetFilter::validateName($this->name))  {
            return $this->name;
        }
        throw new Exception('never get to getName IndustryTargetFilter::name');
    }

    /**
     * @return string
     */
    public static function sampleName(): string {
        return 'IndustryTargetFilter::name::34'; /*34:name*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return IndustryTargetFilter::validateKey($this->key)
        || IndustryTargetFilter::validateCategoryIDs($this->categoryIDs)
        || IndustryTargetFilter::validateGroupIDs($this->groupIDs)
        || IndustryTargetFilter::validateName($this->name);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'_key'} = $this->toKey();
        $out->{'categoryIDs'} = $this->toCategoryIDs();
        $out->{'groupIDs'} = $this->toGroupIDs();
        $out->{'name'} = $this->toName();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return IndustryTargetFilter
     * @throws Exception
     */
    public static function from(stdClass $obj): IndustryTargetFilter {
        return new IndustryTargetFilter(
         IndustryTargetFilter::fromKey($obj->{'_key'})
        ,IndustryTargetFilter::fromCategoryIDs($obj->{'categoryIDs'})
        ,IndustryTargetFilter::fromGroupIDs($obj->{'groupIDs'})
        ,IndustryTargetFilter::fromName($obj->{'name'})
        );
    }

    /**
     * @return IndustryTargetFilter
     */
    public static function sample(): IndustryTargetFilter {
        return new IndustryTargetFilter(
         IndustryTargetFilter::sampleKey()
        ,IndustryTargetFilter::sampleCategoryIDs()
        ,IndustryTargetFilter::sampleGroupIDs()
        ,IndustryTargetFilter::sampleName()
        );
    }
}
from dataclasses import dataclass
from typing import Any, TypeVar, Callable, Type, cast


T = TypeVar("T")


def from_int(x: Any) -> int:
    assert isinstance(x, int) and not isinstance(x, bool)
    return x


def from_str(x: Any) -> str:
    assert isinstance(x, str)
    return x


def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
    assert isinstance(x, list)
    return [f(y) for y in 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()


@dataclass
class IndustryTargetFilter:
    key: int
    name: str
    category_i_ds: list[int] | None = None
    group_i_ds: list[int] | None = None

    @staticmethod
    def from_dict(obj: Any) -> 'IndustryTargetFilter':
        assert isinstance(obj, dict)
        key = from_int(obj.get("_key"))
        name = from_str(obj.get("name"))
        category_i_ds = from_union([lambda x: from_list(from_int, x), from_none], obj.get("categoryIDs"))
        group_i_ds = from_union([lambda x: from_list(from_int, x), from_none], obj.get("groupIDs"))
        return IndustryTargetFilter(key, name, category_i_ds, group_i_ds)

    def to_dict(self) -> dict:
        result: dict = {}
        result["_key"] = from_int(self.key)
        result["name"] = from_str(self.name)
        if self.category_i_ds is not None:
            result["categoryIDs"] = from_union([lambda x: from_list(from_int, x), from_none], self.category_i_ds)
        if self.group_i_ds is not None:
            result["groupIDs"] = from_union([lambda x: from_list(from_int, x), from_none], self.group_i_ds)
        return result


def industry_target_filter_from_dict(s: Any) -> IndustryTargetFilter:
    return IndustryTargetFilter.from_dict(s)


def industry_target_filter_to_dict(x: IndustryTargetFilter) -> Any:
    return to_class(IndustryTargetFilter, x)
// To parse this data:
//
//   import { Convert, IndustryTargetFilter } from "./IndustryTargetFilter";
//
//   const industryTargetFilter = Convert.toIndustryTargetFilter(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.

export interface IndustryTargetFilter {
    _key:         number;
    categoryIDs?: [number, ...number[]];
    groupIDs?:    [number, ...number[]];
    name:         string;
    [property: string]: unknown;
}

// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
    public static toIndustryTargetFilter(json: string): IndustryTargetFilter {
        return cast(JSON.parse(json), r("IndustryTargetFilter"));
    }

    public static industryTargetFilterToJson(value: IndustryTargetFilter): string {
        return JSON.stringify(uncast(value, r("IndustryTargetFilter")), 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 = {
    "IndustryTargetFilter": o([
        { json: "_key", js: "_key", typ: 0 },
        { json: "categoryIDs", js: "categoryIDs", typ: u(undefined, a(0)) },
        { json: "groupIDs", js: "groupIDs", typ: u(undefined, a(0)) },
        { json: "name", js: "name", typ: "" },
    ], "any"),
};