-
Notifications
You must be signed in to change notification settings - Fork 117
Dynamic Dashboard: Integrate new endpoint for product stock in Networking layer #12756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me 👍🏼
I think it will be useful to add a sample json and test to show how this deals with the case where plugins change the type for sku
/stockQuantity
, as well as the parent
case for manageStock
. But It's not a blocker for this PR.
struct ProductStockListMapper: Mapper { | ||
/// Site Identifier associated to the products that will be parsed. | ||
/// | ||
/// We're injecting this field via `JSONDecoder.userInfo` because SiteID is not returned in any of the Product Endpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 TIL about getting siteID this way.
// could be returned as well (typically with variations) — we need to account for this. | ||
// A "parent" value means that stock mgmt is turned on + managed at the parent product-level, therefore | ||
// we need to set this var as `true` in this situation. | ||
// See: https://github.com/woocommerce/woocommerce-ios/issues/884 for more deets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great research here as well.
let name = try container.decode(String.self, forKey: .name) | ||
|
||
// Even though a plain install of WooCommerce Core provides String values, | ||
// some plugins alter the field value from String to Int or Decimal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great research to find how plugins might alter this value.
/// The card's availability state for the site. | ||
/// To be set externally based on each card's availability check. | ||
public let availability: AvailabilityState | ||
|
||
/// User-changeable setting in the Customize screen, whether to enable or disable an available card. | ||
/// An available card will become invisible on the Dashboard, but stay visible on Customize, if `enabled` is set to false. | ||
public let enabled: Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! I had included this is one of my PRs but let's get this one first instead.
Thanks @hafizrahman for the reviews!
Good point! I added the mock responses and tests for these cases in 32ceaec. |
Part of #12748
Description
This PR updates the Networking layer to integrate the new endpoint
wc-analytics/reports/stock
. Changes include:ProductStock
.ProductsRemote
with a new method to fetch stock list.Testing instructions
The endpoint hasn't been integrated yet so just CI passing is sufficient.
Screenshots
N/A
RELEASE-NOTES.txt
if necessary.