Skip to content

Commit

Permalink
remove strip option setters
Browse files Browse the repository at this point in the history
Signed-off-by: George Mulhearn <[email protected]>
  • Loading branch information
gmulhearn-anonyome committed Sep 26, 2023
1 parent afe8814 commit 21b2796
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ pub type IssueCredentialV2 = MsgParts<IssueCredentialV2Content, IssueCredentialV

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)]
pub struct IssueCredentialV2Content {
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub goal_code: Option<String>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub replacement_id: Option<String>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
pub formats: Vec<AttachmentFormatSpecifier<IssueCredentialAttachmentFormatType>>,
Expand All @@ -29,11 +29,11 @@ pub struct IssueCredentialV2Content {
pub struct IssueCredentialV2Decorators {
#[serde(rename = "~thread")]
pub thread: Thread,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(rename = "~please_ack")]
#[serde(skip_serializing_if = "Option::is_none")]
pub please_ack: Option<PleaseAck>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(rename = "~timing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timing: Option<Timing>,
Expand Down Expand Up @@ -105,15 +105,15 @@ mod tests {
),
}])
.credentials_attach(vec![make_extended_attachment()])
.goal_code("goal.goal".to_owned())
.replacement_id("replacement-123".to_owned())
.comment("test_comment".to_owned())
.goal_code(Some("goal.goal".to_owned()))
.replacement_id(Some("replacement-123".to_owned()))
.comment(Some("test_comment".to_owned()))
.build();

let decorators = IssueCredentialV2Decorators::builder()
.thread(make_extended_thread())
.timing(make_extended_timing())
.please_ack(make_minimal_please_ack())
.timing(Some(make_extended_timing()))
.please_ack(Some(make_minimal_please_ack()))
.build();

let expected = json!({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ pub type OfferCredentialV2 = MsgParts<OfferCredentialV2Content, OfferCredentialV

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)]
pub struct OfferCredentialV2Content {
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub goal_code: Option<String>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub replacement_id: Option<String>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
pub credential_preview: CredentialPreviewV2,
Expand All @@ -28,11 +28,11 @@ pub struct OfferCredentialV2Content {

#[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)]
pub struct OfferCredentialV2Decorators {
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "~thread")]
pub thread: Option<Thread>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(rename = "~timing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timing: Option<Timing>,
Expand Down Expand Up @@ -118,14 +118,14 @@ mod tests {
),
}])
.offers_attach(vec![make_extended_attachment()])
.comment("test_comment".to_owned())
.replacement_id("replacement_id".to_owned())
.goal_code("goal.goal".to_owned())
.comment(Some("test_comment".to_owned()))
.replacement_id(Some("replacement_id".to_owned()))
.goal_code(Some("goal.goal".to_owned()))
.build();

let decorators = OfferCredentialV2Decorators::builder()
.thread(make_extended_thread())
.timing(make_extended_timing())
.thread(Some(make_extended_thread()))
.timing(Some(make_extended_timing()))
.build();

let expected = json!({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ pub type ProposeCredentialV2 = MsgParts<ProposeCredentialV2Content, ProposeCrede

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)]
pub struct ProposeCredentialV2Content {
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub goal_code: Option<String>, // TODO - spec does not specify what goal codes to use..
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub credential_preview: Option<CredentialPreviewV2>,
pub formats: Vec<AttachmentFormatSpecifier<ProposeCredentialAttachmentFormatType>>,
Expand All @@ -27,11 +27,11 @@ pub struct ProposeCredentialV2Content {

#[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)]
pub struct ProposeCredentialV2Decorators {
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "~thread")]
pub thread: Option<Thread>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(rename = "~timing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timing: Option<Timing>,
Expand Down Expand Up @@ -100,21 +100,21 @@ mod tests {
.build();
let preview = CredentialPreviewV2::new(vec![attribute]);
let content = ProposeCredentialV2Content::builder()
.credential_preview(preview)
.credential_preview(Some(preview))
.formats(vec![AttachmentFormatSpecifier {
attach_id: String::from("1"),
format: MaybeKnown::Known(
ProposeCredentialAttachmentFormatType::HyperledgerIndyCredentialFilter2_0,
),
}])
.filters_attach(vec![make_extended_attachment()])
.comment("test_comment".to_owned())
.goal_code("goal.goal".to_owned())
.comment(Some("test_comment".to_owned()))
.goal_code(Some("goal.goal".to_owned()))
.build();

let decorators = ProposeCredentialV2Decorators::builder()
.thread(make_extended_thread())
.timing(make_extended_timing())
.thread(Some(make_extended_thread()))
.timing(Some(make_extended_timing()))
.build();

let expected = json!({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub type RequestCredentialV2 = MsgParts<RequestCredentialV2Content, RequestCrede

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)]
pub struct RequestCredentialV2Content {
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub goal_code: Option<String>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
pub formats: Vec<AttachmentFormatSpecifier<RequestCredentialAttachmentFormatType>>,
Expand All @@ -24,11 +24,11 @@ pub struct RequestCredentialV2Content {

#[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)]
pub struct RequestCredentialV2Decorators {
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(rename = "~thread")]
#[serde(skip_serializing_if = "Option::is_none")]
pub thread: Option<Thread>,
#[builder(default, setter(strip_option))]
#[builder(default)]
#[serde(rename = "~timing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timing: Option<Timing>,
Expand Down Expand Up @@ -97,12 +97,12 @@ mod tests {
RequestCredentialAttachmentFormatType::HyperledgerIndyCredentialRequest2_0,
),
}])
.comment("test_comment".to_owned())
.goal_code("goal.goal".to_owned())
.comment(Some("test_comment".to_owned()))
.goal_code(Some("goal.goal".to_owned()))
.build();

let decorators = RequestCredentialV2Decorators::builder()
.thread(make_extended_thread())
.thread(Some(make_extended_thread()))
.build();

let expected = json!({
Expand Down

0 comments on commit 21b2796

Please sign in to comment.