Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Add entry_kinds and BasePersonaDataEntry trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinnstah committed Dec 13, 2023
1 parent c613971 commit b7d41d4
Show file tree
Hide file tree
Showing 14 changed files with 746 additions and 436 deletions.
4 changes: 4 additions & 0 deletions profile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ nutype = { version = "0.4.0", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "038ddee8b0f57aa90e36375c69946c4eb634efeb", features = [
"serde",
] }
identified_vec = { git = "https://github.com/Vinnstah/identified_vec.git", branch = "try-append-update", features = [
"serde",
] }
enum-as-inner = "0.6.0"

51 changes: 51 additions & 0 deletions profile/src/v100/entity/persona/persona_data/entry.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use super::entry_kinds::{
associated_url::AssociatedURL, company_name::CompanyName, credit_card::CreditCard,
date_of_birth::DateOfBirth, email_address::EmailAddress, name::Name, phone_number::PhoneNumber,
postal_address::PostalAddress,
};
use serde::{Deserialize, Serialize};

pub trait BasePersonaDataEntry {
fn embed(&self) -> Self;
fn description(&self) -> String;
}

#[derive(Serialize, Deserialize)]
pub enum Entry {
Name(Name),
DateOfBirth(DateOfBirth),
CompanyName(CompanyName),

EmailAddress(EmailAddress),
PhoneNumber(PhoneNumber),
Url(AssociatedURL),
PostalAddress(PostalAddress),
CreditCard(CreditCard),
}

impl BasePersonaDataEntry for Entry {
fn embed(&self) -> Self {
match self {
Self::Name(name) => Self::Name(name.embed()),
Self::CompanyName(company) => Self::CompanyName(company.embed()),
Self::CreditCard(credit_card) => Self::CreditCard(credit_card.embed()),
Self::DateOfBirth(date_of_birth) => Self::DateOfBirth(date_of_birth.embed()),
Self::EmailAddress(email) => Self::EmailAddress(email.embed()),
Self::PhoneNumber(phone) => Self::PhoneNumber(phone.embed()),
Self::PostalAddress(postal) => Self::PostalAddress(postal.embed()),
Self::Url(url) => Self::Url(url.embed()),
}
}
fn description(&self) -> String {
match self {
Self::Name(name) => name.description(),
Self::CompanyName(company) => company.description(),
Self::CreditCard(credit_card) => credit_card.description(),
Self::DateOfBirth(date_of_birth) => date_of_birth.description(),
Self::EmailAddress(email) => email.description(),
Self::PhoneNumber(phone) => phone.description(),
Self::PostalAddress(postal) => postal.description(),
Self::Url(url) => url.description(),
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::v100::entity::persona::persona_data::entry::BasePersonaDataEntry;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct AssociatedURL {}

impl BasePersonaDataEntry for AssociatedURL {
fn embed(&self) -> Self {
self.embed()
}

fn description(&self) -> String {
todo!()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::v100::entity::persona::persona_data::entry::BasePersonaDataEntry;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct CompanyName {}

impl BasePersonaDataEntry for CompanyName {
fn embed(&self) -> Self {
self.embed()
}

fn description(&self) -> String {
todo!()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::v100::entity::persona::persona_data::entry::BasePersonaDataEntry;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct CreditCard {}

impl BasePersonaDataEntry for CreditCard {
fn embed(&self) -> Self {
self.embed()
}

fn description(&self) -> String {
todo!()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::v100::entity::persona::persona_data::entry::BasePersonaDataEntry;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct DateOfBirth {}

impl BasePersonaDataEntry for DateOfBirth {
fn embed(&self) -> Self {
self.embed()
}

fn description(&self) -> String {
todo!()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::v100::entity::persona::persona_data::entry::BasePersonaDataEntry;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct EmailAddress {}

impl BasePersonaDataEntry for EmailAddress {
fn embed(&self) -> Self {
self.embed()
}

fn description(&self) -> String {
todo!()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub mod associated_url;
pub mod company_name;
pub mod credit_card;
pub mod date_of_birth;
pub mod email_address;
pub mod name;
pub mod phone_number;
pub mod postal_address;
15 changes: 15 additions & 0 deletions profile/src/v100/entity/persona/persona_data/entry_kinds/name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::v100::entity::persona::persona_data::entry::BasePersonaDataEntry;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct Name {}

impl BasePersonaDataEntry for Name {
fn embed(&self) -> Self {
self.embed()
}

fn description(&self) -> String {
todo!()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::v100::entity::persona::persona_data::entry::BasePersonaDataEntry;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct PhoneNumber {}

impl BasePersonaDataEntry for PhoneNumber {
fn embed(&self) -> Self {
self.embed()
}

fn description(&self) -> String {
todo!()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::v100::entity::persona::persona_data::entry::BasePersonaDataEntry;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct PostalAddress {}

impl BasePersonaDataEntry for PostalAddress {
fn embed(&self) -> Self {
self.embed()
}

fn description(&self) -> String {
todo!()
}
}
Loading

0 comments on commit b7d41d4

Please sign in to comment.