Created
March 9, 2020 02:32
-
-
Save ucarion/f624905ccef2e7f4b20f242b95ee4d1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"definitions": { | |
"name": { | |
"metadata": { | |
"description": "A proper name.\n\nNote that this is a string, and not some object with first/given name or a last/family name. We have users across many cultures, and some of these cultures use mononyms or otherwise don't map onto these concepts." | |
}, | |
"type": "string" | |
}, | |
"location": { | |
"metadata": { | |
"description": "A latitude / longitude pair indicating a position on Earth" | |
}, | |
"properties": { | |
"lat": { "metadata": { "description": "Latitude" }, "type": "string" }, | |
"lng": { "metadata": { "description": "Longitude" }, "type": "string" } | |
} | |
} | |
}, | |
"metadata": { | |
"description": "A user represents a person in our system." | |
}, | |
"properties": { | |
"id": { | |
"metadata": { | |
"description": "The ID of the user in our database." | |
}, | |
"type": "string" | |
}, | |
"name": { | |
"metadata": { | |
"description": "The user's name." | |
}, | |
"ref": "name" | |
}, | |
"labels": { | |
"metadata": { | |
"description": "Free-form labels that we have put on the user." | |
}, | |
"values": { | |
"type": "string" | |
} | |
}, | |
"preferences": { | |
"metadata": { | |
"description": "Some preferences the user has indicated to us." | |
}, | |
"properties": { | |
"do_not_track": { | |
"metadata": { "description": "User preferences around do-not-track" }, | |
"discriminator": "version", | |
"mapping": { | |
"v0": { | |
"metadata": { | |
"description": "Our pre-GDPR do-not-track settings" | |
}, | |
"properties": { | |
"do_not_track": { | |
"metadata": { | |
"description": "An all-or-nothing do-not-track setting" | |
}, | |
"type": "boolean" | |
} | |
} | |
}, | |
"v1": { | |
"metadata": { | |
"description": "Our post-GDPR do-not-track settings" | |
}, | |
"properties": { | |
"do_not_track": { | |
"metadata": { | |
"description": "A multi-level do-not-track setting", | |
"enumDescriptions": { | |
"ALL": "All forms of tracking permitted.", | |
"ESSENTIAL_ONLY": "Only essentialy forms of tracking permitted.", | |
"NONE": "No forms forms of tracking permitted." | |
} | |
}, | |
"enum": ["ALL", "ESSENTIAL_ONLY", "NONE"] | |
}, | |
"opt_out_channels": { | |
"metadata": { | |
"description": "Channels the user has opted out of tracking for." | |
}, | |
"elements": { "type": "string" } | |
} | |
} | |
} | |
} | |
} | |
}, | |
"optionalProperties": { | |
"title": { | |
"metadata": { | |
"description": "A title we should use when addressing the user formally.", | |
"enumDescriptions": { | |
"MR": "Refer to this user as 'Mr.'", | |
"MRS": "Refer to this user as 'Mrs.'", | |
"MS": "Refer to this user as 'Ms.'", | |
"REV": "Refer to this user as 'Rev.'", | |
"HRH": "Refer to this user as 'His/Her Royal Highness'" | |
} | |
}, | |
"enum": ["MR", "MRS", "MS", "REV", "HRH"] | |
} | |
} | |
} | |
}, | |
"optionalProperties": { | |
"first_known_location": { | |
"metadata": { | |
"description": "The first known location of this user" | |
}, | |
"ref": "location" | |
}, | |
"last_known_location": { | |
"metadata": { | |
"description": "The last known location of this user" | |
}, | |
"ref": "location" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use chrono::{DateTime, Utc}; | |
use serde::{Deserialize, Serialize}; | |
/// A proper name. | |
/// | |
/// Note that this is a string, and not some object with first/given name or a last/family name. We have users across many cultures, and some of these cultures use mononyms or otherwise don't map onto these concepts. | |
pub type Name = String; | |
/// User preferences around do-not-track | |
#[derive(Debug, Serialize, Deserialize)] | |
#[serde(tag = "version")] | |
pub enum PreferencesDoNotTrack { | |
/// Our pre-GDPR do-not-track settings | |
#[serde(rename = "v0")] | |
V0(PreferencesDoNotTrackV0), | |
/// Our post-GDPR do-not-track settings | |
#[serde(rename = "v1")] | |
V1(PreferencesDoNotTrackV1), | |
} | |
/// A multi-level do-not-track setting | |
#[derive(Debug, Serialize, Deserialize)] | |
pub enum PreferencesDoNotTrackV1DoNotTrack { | |
/// All forms of tracking permitted. | |
#[serde(rename = "ALL")] | |
All, | |
/// Only essentialy forms of tracking permitted. | |
#[serde(rename = "ESSENTIAL_ONLY")] | |
EssentialOnly, | |
/// No forms forms of tracking permitted. | |
#[serde(rename = "NONE")] | |
None, | |
} | |
/// A title we should use when addressing the user formally. | |
#[derive(Debug, Serialize, Deserialize)] | |
pub enum PreferencesTitle { | |
/// Refer to this user as 'His/Her Royal Highness' | |
#[serde(rename = "HRH")] | |
Hrh, | |
/// Refer to this user as 'Mr.' | |
#[serde(rename = "MR")] | |
Mr, | |
/// Refer to this user as 'Mrs.' | |
#[serde(rename = "MRS")] | |
Mrs, | |
/// Refer to this user as 'Ms.' | |
#[serde(rename = "MS")] | |
Ms, | |
/// Refer to this user as 'Rev.' | |
#[serde(rename = "REV")] | |
Rev, | |
} | |
/// A latitude / longitude pair indicating a position on Earth | |
#[derive(Debug, Serialize, Deserialize)] | |
#[serde(deny_unknown_fields)] | |
pub struct Location { | |
/// Latitude | |
#[serde(rename = "lat")] | |
lat: String, | |
/// Longitude | |
#[serde(rename = "lng")] | |
lng: String, | |
} | |
/// Some preferences the user has indicated to us. | |
#[derive(Debug, Serialize, Deserialize)] | |
#[serde(deny_unknown_fields)] | |
pub struct Preferences { | |
/// User preferences around do-not-track | |
#[serde(rename = "do_not_track")] | |
do_not_track: PreferencesDoNotTrack, | |
/// A title we should use when addressing the user formally. | |
#[serde(rename = "title")] | |
title: Option<PreferencesTitle>, | |
} | |
/// Our pre-GDPR do-not-track settings | |
#[derive(Debug, Serialize, Deserialize)] | |
#[serde(deny_unknown_fields)] | |
pub struct PreferencesDoNotTrackV0 { | |
/// An all-or-nothing do-not-track setting | |
#[serde(rename = "do_not_track")] | |
do_not_track: bool, | |
} | |
/// Our post-GDPR do-not-track settings | |
#[derive(Debug, Serialize, Deserialize)] | |
#[serde(deny_unknown_fields)] | |
pub struct PreferencesDoNotTrackV1 { | |
/// A multi-level do-not-track setting | |
#[serde(rename = "do_not_track")] | |
do_not_track: PreferencesDoNotTrackV1DoNotTrack, | |
/// Channels the user has opted out of tracking for. | |
#[serde(rename = "opt_out_channels")] | |
opt_out_channels: Vec<String>, | |
} | |
/// A user represents a person in our system. | |
#[derive(Debug, Serialize, Deserialize)] | |
#[serde(deny_unknown_fields)] | |
pub struct User { | |
/// The first known location of this user | |
#[serde(rename = "first_known_location")] | |
first_known_location: Option<Location>, | |
/// The ID of the user in our database. | |
#[serde(rename = "id")] | |
id: String, | |
/// Free-form labels that we have put on the user. | |
#[serde(rename = "labels")] | |
labels: HashMap<String, String>, | |
/// The last known location of this user | |
#[serde(rename = "last_known_location")] | |
last_known_location: Option<Location>, | |
/// The user's name. | |
#[serde(rename = "name")] | |
name: Name, | |
/// Some preferences the user has indicated to us. | |
#[serde(rename = "preferences")] | |
preferences: Preferences, | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment