From 2f01e3bc66dc04fbe0b982a8d312018c1147dae3 Mon Sep 17 00:00:00 2001 From: Joe Prosser Date: Wed, 3 Apr 2024 14:48:48 +0100 Subject: [PATCH] feat(api): support entity spans format --- CHANGELOG.md | 1 + api/src/resources/comment.rs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8be9efe..97b301b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Add `get emails` - Added support for `--auto-increase-up-to` when creating quotas. +- Support spans format for entities # v0.22.2 diff --git a/api/src/resources/comment.rs b/api/src/resources/comment.rs index 0bf3209..1188882 100644 --- a/api/src/resources/comment.rs +++ b/api/src/resources/comment.rs @@ -775,12 +775,26 @@ fn should_skip_serializing_entities(maybe_entities: &Option) -> bool { } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq)] -pub struct NewEntity { +#[serde(untagged)] +pub enum NewEntity { + WithSpan(NewEntityWithSpan), + WithSpans(NewEntityWithSpans), +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq)] +pub struct NewEntityWithSpan { pub name: EntityName, pub formatted_value: String, pub span: NewEntitySpan, } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq)] +pub struct NewEntityWithSpans { + pub name: EntityName, + pub formatted_value: String, + pub spans: Vec, +} + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize, Eq)] pub struct NewEntitySpan { content_part: String, @@ -793,7 +807,7 @@ pub struct NewEntitySpan { pub struct Entity { pub name: EntityName, pub formatted_value: String, - pub span: EntitySpan, + pub spans: Vec, } #[derive(Debug, PartialEq, Clone, Deserialize, Serialize, Eq)]