Skip to content

Commit

Permalink
fix: move well-known-did to public api (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-iskryzhytskyi authored Sep 17, 2024
1 parent 37b8317 commit 3639a31
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions affinidi-messaging-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod conversions;
pub mod errors;
pub mod messages;
pub mod protocols;
pub mod public;
mod resolvers;
pub mod transports;

Expand Down
1 change: 0 additions & 1 deletion affinidi-messaging-sdk/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub mod list;
pub mod pack;
pub mod sending;
pub mod unpack;
pub mod well_known_did;

/// Generic response structure for all responses from the ATM API
#[derive(Serialize, Deserialize, Debug)]
Expand Down
1 change: 1 addition & 0 deletions affinidi-messaging-sdk/src/public/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod well_known_did;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tracing::{debug, span, Level};
impl<'c> ATM<'c> {
/// Returns a list of messages that are stored in the ATM
/// - messages : List of message IDs to retrieve
pub async fn well_known_did_json(&mut self) -> Result<SuccessResponse<String>, ATMError> {
pub async fn well_known_did_json(&mut self) -> Result<String, ATMError> {
let _span = span!(Level::DEBUG, "well_known_did_json").entered();

debug!("Sending well_known_did request");
Expand Down Expand Up @@ -35,15 +35,22 @@ impl<'c> ATM<'c> {
let body = serde_json::from_str::<SuccessResponse<String>>(&body)
.ok()
.unwrap();

if !status.is_success() {
return Err(ATMError::TransportError(format!(
"Status not successful. status({}), response({:?})",
status, body
)));
}

debug!("API response: body({:?})", body);
let did = if let Some(did) = body.data {
did
} else {
return Err(ATMError::TransportError("No did found".to_string()));
};

debug!("API response: did({})", did);

Ok(body)
Ok(did)
}
}

0 comments on commit 3639a31

Please sign in to comment.