Skip to content

Commit

Permalink
fix: add type definitions and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mezotv committed Aug 29, 2024
1 parent 76cd63e commit e87955b
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 0 deletions.
61 changes: 61 additions & 0 deletions types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Types for Creator Database

**Purpose:**

This folder contains type definitions for the Creator Database JSON data in various programming languages. These type definitions can be used to provide strong typing and improve code maintainability when working with the database.

**Usage:**

1. **Choose the appropriate type definition file** based on the programming language you're using.
2. **Import or include the type definitions** in your project.
3. **Use the type definitions** to represent and manipulate the Creator Database data in your code.

**Example (TypeScript):**

```typescript
interface SocialMedia {
id: string | null;
name?: string | null;
username?: string | null;
partner?: boolean | null;
handle?: string | null;
}

interface Creator {
name: string;
aliases: string[] | null;
steam: SocialMedia | null;
discord: SocialMedia | null;
twitch: Omit<SocialMedia, 'name' | 'username' | 'handle'> | null;
youtube: Omit<SocialMedia, 'name' | 'username'> | null;
}

// Example

const honeypuu: Creator = {
name: "HoneyPuu",
aliases: null,
steam: {
id: "76561198405910426",
name: "HoneyPuu"
},
discord: {
id: "247064492427444224",
username: "honeypuu",
partner: false
},
twitch: {
id: "honeypuu",
partner: true
},
youtube: {
handle: "honeypuu",
id: "UC6lv714giE5fvmlUhS3d9gg",
partner: true
}
};
```

**Disclaimer:**

While we strive to provide accurate and up-to-date type definitions for the Creator Database, we cannot guarantee their correctness or completeness. It's always recommended to verify the data against the actual JSON structure.
62 changes: 62 additions & 0 deletions types/c#/CreatorClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
public partial class CreatorClass
{
[JsonProperty("aliases")]
public string[] Aliases { get; set; }

[JsonProperty("discord")]
public Discord Discord { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("steam")]
public Steam Steam { get; set; }

[JsonProperty("twitch")]
public Twitch Twitch { get; set; }

[JsonProperty("youtube")]
public Youtube Youtube { get; set; }
}

public partial class Discord
{
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("partner")]
public bool? Partner { get; set; }

[JsonProperty("username")]
public string Username { get; set; }
}

public partial class Steam
{
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("name")]
public string Name { get; set; }
}

public partial class Twitch
{
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("partner")]
public bool? Partner { get; set; }
}

public partial class Youtube
{
[JsonProperty("handle")]
public string Handle { get; set; }

[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("partner")]
public bool? Partner { get; set; }
}
32 changes: 32 additions & 0 deletions types/go/CreatorStruct.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

type Creator struct {
Aliases []string `json:"aliases"`
Discord *Discord `json:"discord"`
Name string `json:"name"`
Steam *Steam `json:"steam"`
Twitch *Twitch `json:"twitch"`
Youtube *Youtube `json:"youtube"`
}

type Discord struct {
ID *string `json:"id"`
Partner *bool `json:"partner"`
Username *string `json:"username"`
}

type Steam struct {
ID *string `json:"id"`
Name *string `json:"name"`
}

type Twitch struct {
ID *string `json:"id"`
Partner *bool `json:"partner"`
}

type Youtube struct {
Handle *string `json:"handle"`
ID *string `json:"id"`
Partner *bool `json:"partner"`
}
37 changes: 37 additions & 0 deletions types/rust/CreatorStruct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
pub struct CreatorStruct {
aliases: Option<Vec<String>>,
discord: Option<Discord>,
name: String,
steam: Option<Steam>,
twitch: Option<Twitch>,
youtube: Option<Youtube>,
}

#[derive(Serialize, Deserialize)]
pub struct Discord {
id: Option<String>,
partner: Option<bool>,
username: Option<String>,
}

#[derive(Serialize, Deserialize)]
pub struct Steam {
id: Option<String>,
name: Option<String>,
}

#[derive(Serialize, Deserialize)]
pub struct Twitch {
id: Option<String>,
partner: Option<bool>,
}

#[derive(Serialize, Deserialize)]
pub struct Youtube {
handle: Option<String>,
id: Option<String>,
partner: Option<bool>,
}

0 comments on commit e87955b

Please sign in to comment.