summaryrefslogtreecommitdiff
path: root/dichroism/src/dtos/product_patch.rs
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-11-02 20:36:18 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-11-02 20:36:18 -0500
commitdcc96d0b349583e5d6a0f25ae1f7a3ffa3769788 (patch)
tree98a9cc9d322e309c05db400f4c536164bee4daac /dichroism/src/dtos/product_patch.rs
parent9480317011b57d3be7b903048f4a85d02979c7c7 (diff)
downloadtheglassyladies-dcc96d0b349583e5d6a0f25ae1f7a3ffa3769788.tar.xz
theglassyladies-dcc96d0b349583e5d6a0f25ae1f7a3ffa3769788.zip
swapped json payload url encoded images for multipart form data
Diffstat (limited to 'dichroism/src/dtos/product_patch.rs')
-rw-r--r--dichroism/src/dtos/product_patch.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/dichroism/src/dtos/product_patch.rs b/dichroism/src/dtos/product_patch.rs
index ed8bf1a..f231469 100644
--- a/dichroism/src/dtos/product_patch.rs
+++ b/dichroism/src/dtos/product_patch.rs
@@ -1,3 +1,5 @@
+use crate::models::Product;
+
#[derive(Debug, Deserialize)]
pub struct ProductPatch {
pub id: i32,
@@ -7,5 +9,23 @@ pub struct ProductPatch {
pub description: Option<String>,
pub featured: Option<bool>,
pub category_path: Option<String>,
- pub photo_data: Option<String>,
+ pub photo_set: Option<i32>,
+}
+
+impl ProductPatch {
+ pub fn patch(self, product: &mut Product) {
+ if let Some(name) = self.name {
+ product.name = name;
+ }
+ if let Some(category) = self.category_path {
+ product.category = category;
+ }
+ if let Some(description) = self.description {
+ product.description = description;
+ }
+
+ product.quantity = self.quantity.unwrap_or(product.quantity);
+ product.cents = self.cents.unwrap_or(product.cents);
+ product.featured = self.featured.unwrap_or(product.featured);
+ }
}