Skip to content

Commit

Permalink
style: rename endpoint deserialization helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
nanderstabel committed May 13, 2024
1 parent a32e0bd commit f2e097d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions agent_api_rest/src/issuance/credential_issuer/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ mod tests {

use crate::{
app,
issuance::{credential_issuer::token::tests::token, credentials::CredentialsRequest, offers::tests::offers},
issuance::{
credential_issuer::token::tests::token, credentials::CredentialsEndpointRequest, offers::tests::offers,
},
tests::{BASE_URL, OFFER_ID},
};

Expand Down Expand Up @@ -189,14 +191,14 @@ mod tests {

// The 'backend' server can either opt for an already signed credential...
let credentials_endpoint_request = if is_self_signed {
CredentialsRequest {
CredentialsEndpointRequest {
offer_id: offer_id.clone(),
credential: json!(CREDENTIAL_JWT),
is_signed: true,
}
} else {
// ...or else, submitting the data that will be signed inside `UniCore`.
CredentialsRequest {
CredentialsEndpointRequest {
offer_id: offer_id.clone(),
credential: json!({
"credentialSubject": {
Expand Down
4 changes: 2 additions & 2 deletions agent_api_rest/src/issuance/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) async fn get_credentials(State(state): State<IssuanceState>, Path(cre

#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CredentialsRequest {
pub struct CredentialsEndpointRequest {
pub offer_id: String,
pub credential: Value,
#[serde(default)]
Expand All @@ -43,7 +43,7 @@ pub(crate) async fn credentials(
) -> Response {
info!("Request Body: {}", payload);

let Ok(CredentialsRequest {
let Ok(CredentialsEndpointRequest {
offer_id,
credential: data,
is_signed,
Expand Down
4 changes: 2 additions & 2 deletions agent_api_rest/src/issuance/offers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ use tracing::info;

#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OffersRequest {
pub struct OffersEndpointRequest {
pub offer_id: String,
}

#[axum_macros::debug_handler]
pub(crate) async fn offers(State(state): State<IssuanceState>, Json(payload): Json<Value>) -> Response {
info!("Request Body: {}", payload);

let Ok(OffersRequest { offer_id }) = serde_json::from_value(payload) else {
let Ok(OffersEndpointRequest { offer_id }) = serde_json::from_value(payload) else {
return (StatusCode::BAD_REQUEST, "invalid payload").into_response();
};

Expand Down
4 changes: 2 additions & 2 deletions agent_api_rest/src/verification/authorization_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) async fn get_authorization_requests(
}

#[derive(Deserialize, Serialize)]
pub struct AuthorizationRequestsRequest {
pub struct AuthorizationRequestsEndpointRequest {
pub nonce: String,
pub state: Option<String>,
pub presentation_definition_id: Option<String>,
Expand All @@ -47,7 +47,7 @@ pub(crate) async fn authorization_requests(
) -> Response {
info!("Request Body: {}", payload);

let Ok(AuthorizationRequestsRequest {
let Ok(AuthorizationRequestsEndpointRequest {
nonce,
state,
presentation_definition_id,
Expand Down

0 comments on commit f2e097d

Please sign in to comment.