spatio_sdk/models/note.rs
1/*
2 * SpatioAPI
3 *
4 * The REST API that owns every resource in your Spatio workspace: notes, sheets, slides, tasks, calendar events, mail, chat, files, and contacts. SpatioMCP wraps this API; Spatio Desktop reads from it. You can call it directly from your own code. All requests must be authenticated with a Personal Access Token (`Authorization: Bearer pat_...`) or an OAuth 2.1 access token, and use HTTPS. Official SDKs (MIT, generated from this spec on every release): - TypeScript: https://github.com/spatio-labs/spatio-ts (`npm install @spatio-labs/spatio-ts`) - Python: https://github.com/spatio-labs/spatio-py (`pip install spatio-sdk`) - Go: https://github.com/spatio-labs/spatio-go (`go get github.com/spatio-labs/spatio-go`) This specification is generated from the platform-service Go source on every push to `main`. The spec, not hand-written documentation, is the source of truth: server stubs and SDKs are generated from it, and any drift between the spec and the running service fails CI.
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: hello@spatio.app
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Note : A markdown note. Notes belong to exactly one connected account (`accountId` + `provider`). The native provider stores notes in the Spatio database; external providers (Notion, Google Keep, etc.) store them upstream and round-trip through Spatio.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Note {
17 /// Stable provider id for the note.
18 #[serde(rename = "id")]
19 pub id: String,
20 /// Registered provider id (e.g. `native-notes`).
21 #[serde(rename = "provider", skip_serializing_if = "Option::is_none")]
22 pub provider: Option<String>,
23 /// Connected-account row this note belongs to.
24 #[serde(rename = "accountId", skip_serializing_if = "Option::is_none")]
25 pub account_id: Option<String>,
26 /// User id of the note's owner. Surfaced so the renderer can show \"Shared with you\" when `ownerUserId` differs from the viewer's id. Empty for non-native providers.
27 #[serde(rename = "ownerUserId", skip_serializing_if = "Option::is_none")]
28 pub owner_user_id: Option<String>,
29 #[serde(rename = "title")]
30 pub title: String,
31 /// Markdown body. The block tree at `/v1/notes/{id}/blocks` is the canonical structured representation; `content` is a flattened markdown view kept for clients that don't render blocks.
32 #[serde(rename = "content")]
33 pub content: String,
34 /// Emoji or short string used as the note's icon.
35 #[serde(rename = "icon", skip_serializing_if = "Option::is_none")]
36 pub icon: Option<String>,
37 /// URL of the note's cover image.
38 #[serde(rename = "coverImage", skip_serializing_if = "Option::is_none")]
39 pub cover_image: Option<String>,
40 /// Parent note id when notes are nested.
41 #[serde(rename = "parentId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
42 pub parent_id: Option<Option<String>>,
43 /// Free-form provider-specific properties (tags, etc.).
44 #[serde(rename = "properties", skip_serializing_if = "Option::is_none")]
45 pub properties: Option<std::collections::HashMap<String, serde_json::Value>>,
46 #[serde(rename = "archived")]
47 pub archived: bool,
48 #[serde(rename = "createdAt")]
49 pub created_at: chrono::DateTime<chrono::FixedOffset>,
50 #[serde(rename = "updatedAt")]
51 pub updated_at: chrono::DateTime<chrono::FixedOffset>,
52 /// User id of the most recent editor.
53 #[serde(rename = "lastEditedBy", skip_serializing_if = "Option::is_none")]
54 pub last_edited_by: Option<String>,
55}
56
57impl Note {
58 /// A markdown note. Notes belong to exactly one connected account (`accountId` + `provider`). The native provider stores notes in the Spatio database; external providers (Notion, Google Keep, etc.) store them upstream and round-trip through Spatio.
59 pub fn new(id: String, title: String, content: String, archived: bool, created_at: chrono::DateTime<chrono::FixedOffset>, updated_at: chrono::DateTime<chrono::FixedOffset>) -> Note {
60 Note {
61 id,
62 provider: None,
63 account_id: None,
64 owner_user_id: None,
65 title,
66 content,
67 icon: None,
68 cover_image: None,
69 parent_id: None,
70 properties: None,
71 archived,
72 created_at,
73 updated_at,
74 last_edited_by: None,
75 }
76 }
77}
78