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

Commit

Permalink
Don't serialize None
Browse files Browse the repository at this point in the history
  • Loading branch information
Diane Huxley committed Dec 8, 2023
1 parent 0c20c25 commit 2d1b91b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ jsonschema = "0.17.1"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
type-safe-id = { version = "0.2.1", features = ["serde"] }
thiserror = "1.0.50"
thiserror = "1.0.50"
serde_with = "3.4.0"
2 changes: 2 additions & 0 deletions crates/protocol/src/message/close.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ::serde::{Deserialize, Serialize};
use chrono::Utc;
use serde_with::skip_serializing_none;
use type_safe_id::{DynamicType, TypeSafeId};

use super::{Message, MessageError, MessageKind, MessageMetadata};
Expand Down Expand Up @@ -37,6 +38,7 @@ impl Close {
/// See [Quote](https://github.com/TBD54566975/tbdex/tree/main/specs/protocol#close) for more
/// information.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
pub struct CloseData {
/// an explanation of why the exchange is being closed/completed
Expand Down
1 change: 0 additions & 1 deletion crates/protocol/src/message/order_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl OrderStatus {
#[serde(rename_all = "camelCase")]
pub struct OrderStatusData {
/// Current status of Order that's being executed
order_status: String,
}

Expand Down
6 changes: 6 additions & 0 deletions crates/protocol/src/message/quote.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ::serde::{Deserialize, Serialize};
use chrono::{DateTime, Utc};
use serde_with::skip_serializing_none;
use type_safe_id::{DynamicType, TypeSafeId};

use super::{Message, MessageError, MessageKind, MessageMetadata};
Expand Down Expand Up @@ -35,6 +36,7 @@ impl Quote {
/// See [Quote](https://github.com/TBD54566975/tbdex/tree/main/specs/protocol#quote) for more
/// information.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
pub struct QuoteData {
/// When this quote expires. Expressed as ISO8601
Expand All @@ -48,6 +50,7 @@ pub struct QuoteData {
}

#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
pub struct QuoteDetails {
/// ISO 3166 currency code string
Expand All @@ -59,6 +62,7 @@ pub struct QuoteDetails {
}

#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
pub struct PaymentInstructions {
/// Link or Instruction describing how to pay the PFI.
Expand All @@ -68,6 +72,8 @@ pub struct PaymentInstructions {
}

#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[skip_serializing_none]

#[serde(rename_all = "camelCase")]
pub struct PaymentInstruction {
/// Link or Instruction describing how to pay the PFI.
Expand Down
3 changes: 3 additions & 0 deletions crates/protocol/src/resource/offering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use credentials::pex::v2::PresentationDefinition;
use jsonschema::{Draft, JSONSchema};
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use serde_with::skip_serializing_none;

/// Struct that interacts with an [`Offering`] [`Resource`]
pub struct Offering;
Expand Down Expand Up @@ -55,6 +56,7 @@ pub struct OfferingData {
}

#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
pub struct CurrencyDetails {
/// ISO 3166 currency code string
Expand All @@ -66,6 +68,7 @@ pub struct CurrencyDetails {
}

#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
pub struct PaymentMethod {
/// Type of payment method (i.e. `DEBIT_CARD`, `BITCOIN_ADDRESS`, `SQUARE_PAY`)
Expand Down

0 comments on commit 2d1b91b

Please sign in to comment.