Skip to content

Commit

Permalink
products_v2: fix archived and drop delete
Browse files Browse the repository at this point in the history
  • Loading branch information
danielspofford committed Oct 10, 2023
1 parent 13c71eb commit 7d8e76b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/api/products_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub struct ProductV2 {

#[derive(Debug, Serialize)]
pub struct CreateProductV2Params {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub archived: Option<bool>,
pub name: String,
pub organization_prn: String,
}
Expand Down Expand Up @@ -66,13 +69,6 @@ pub struct UpdateProductV2Response {
pub product: ProductV2,
}

pub struct DeleteProductV2Params {
pub product_prn: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct DeleteProductV2Response {}

pub struct ProductsV2Api<'a>(pub &'a Api);

impl<'a> ProductsV2Api<'a> {
Expand Down Expand Up @@ -131,14 +127,4 @@ impl<'a> ProductsV2Api<'a> {
)
.await
}

pub async fn delete(
&'a self,
params: DeleteProductV2Params,
) -> Result<Option<DeleteProductV2Response>, Error> {
let product_prn: String = params.product_prn;
self.0
.execute(Method::DELETE, format!("/products/{product_prn}"), None)
.await
}
}
2 changes: 2 additions & 0 deletions tests/products_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ async fn create_product() {
.create();

let params = CreateProductV2Params {
archived: None,
name: expected_name.to_string(),
organization_prn: expected_organization_prn.to_string(),
};

match api.products_v2().create(params).await.unwrap() {
Some(product) => {
assert_eq!(product.product.name, expected_name.to_string());
assert_eq!(product.product.archived, false);
}
_ => panic!(),
}
Expand Down

0 comments on commit 7d8e76b

Please sign in to comment.