I am new at rust and trying to change a post-statement, but it doesn't work.
Would be nice if someone could help me out.
actual code:
let sw_optionen = response["included"]
.as_array()
.unwrap()
.into_iter()
.filter(|&x| x["type"].as_str() == Some("property_group_option"))
.map(|x| x["id"].as_str() )
.collect::<Vec<_>>();
if sw_optionen.len() > 0 {
ops.insert(format!("10-delete-options-{}", f_produkt.id), json!({
"entity": "product",
"action": "delete",
"payload": [{
"id": shop_id,
"optionIds": sw_optionen
}],
}));
}
Post looks like:
"10-delete-options-105074867": {
"action": "delete",
"entity": "product",
"payload": [
{
"id": "830d1d89d48eafeb04a08a5a84fc47e7",
"optionIds": [
"2c696615ae56ca5c4d8f5f24ccec3e5a",
"7419bcabd82831d08913a4145efacff1",
"a5f68318a731c85c11b82d6d4a0f302b"
]
}
]
},
"10-delete-options-240298": {
"action": "delete",
"entity": "product",
"payload": [
{
"id": "f1ee7e507a23c350d5e68f08b2ceeee8",
"optionIds": [
"2c696615ae56ca5c4d8f5f24ccec3e5a",
"7e6cc32ab2a8bcf5ba3dbc70031d2207",
"97085da39dab960d2a166482b2ec30e0"
]
}
]
},
I am trying to change the code that the post looks like:
"10-delete-options-105074867": {
"action": "delete",
"entity": "product_options",
"payload": [
{"productId": "830d1d89d48eafeb04a08a5a84fc47e7", "optionIds": "2c696615ae56ca5c4d8f5f24ccec3e5a"},
{"productId": "830d1d89d48eafeb04a08a5a84fc47e7", "optionIds": "a5f68318a731c85c11b82d6d4a0f302b"}
]
},
"10-delete-options-240298": {
"action": "delete",
"entity": "product",
"payload": [
{"id": "f1ee7e507a23c350d5e68f08b2ceeee8","optionIds": "2c696615ae56ca5c4d8f5f24ccec3e5a"},
{"id": "f1ee7e507a23c350d5e68f08b2ceeee8","optionIds":"7e6cc32ab2a8bcf5ba3dbc70031d2207"},
{"id": "f1ee7e507a23c350d5e68f08b2ceeee8","optionIds":"97085da39dab960d2a166482b2ec30e0"}
]
},
I guess this should not be hard to change, but i am trying 2 Days now and not getting to the result i want. Pls help =)