Skip to content

Commit

Permalink
Adding closet item info
Browse files Browse the repository at this point in the history
  • Loading branch information
appreciate-devon committed Jun 28, 2023
1 parent efeea1c commit 1549736
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion src/core/routes/closet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,78 @@ async fn post_paginate_list(
)))
}

#[derive(Deserialize)]
struct PostListItemRequest {}

async fn post_list_item(
_req: Json<PostListItemRequest>,
args: web::Path<(Uuid, Uuid)>,
authorization: Option<Authorization>,
) -> Result<HttpResponse, ClosetError> {
let authorization: Authorization = authorization.unwrap_or(Authorization::empty());
let (owner_id, _) = if let Authorization::Bearer(BearerFields {
owner_id,
raw_value,
}) = authorization
{
(owner_id, raw_value)
} else {
return Ok(HttpResponse::Unauthorized().json(json!({})));
};

let list_id = args.0;
let item_id = args.1;

log::warn!("Stubbing out item response for {}", owner_id);

Ok(HttpResponse::Ok().json(json!(
{
"type": "list",
"list_id": list_id,
"id": item_id,
"elements": [
{
"type": "brand_info",
"brand_variant_name": "Louis Vuitton",
"product_name": "Capucines BB"
},
{
"type": "resale",
"value": "4795.00",
"currency": "USD"
},
{
"type": "moderation",
"status": "verified"
},
{
"type": "coverage"
},
{
"type": "status",
"entries": [
{ "type": "coverage_active", "created_at": "2023-06-28T00:00:00Z" },
{ "type": "receipt_added", "created_at": "2023-06-25T00:00:00Z" },
{ "type": "closet_added", "created_at": "2023-06-20T00:00:00Z" }
]
}
]
}
)))
}

pub fn configure(server: &mut web::ServiceConfig, hostname: String) {
let host_route = || web::route().guard(guard::Host(hostname.clone()));
server.route(
"/lists",
host_route().guard(guard::Post()).to(post_paginate_lists),
);
server.route(
"/list/{id}",
"/list/{list_id}",
host_route().guard(guard::Post()).to(post_paginate_list),
);
server.route(
"/list/{list_id}/item/{item_id}",
host_route().guard(guard::Post()).to(post_list_item),
);
}

0 comments on commit 1549736

Please sign in to comment.