Skip to content

[Shipping labels] Add endpoint to fetch shipments #13995

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

Open
wants to merge 14 commits into
base: trunk
Choose a base branch
from

Conversation

irfano
Copy link
Contributor

@irfano irfano commented Apr 30, 2025

Description

This PR adds the config endpoint to fetch shipments. It does not include any UI changes.

New endpoint: GET /wp-json/wcshipping/v1/config/label-purchase/$orderId

I decided to fetch the config endpoint (which includes shipments data) on the order detail screen and cache the response. Later, we’ll use the shipments data on this screen. Then, on the create shipment screen, I’ll use the cached shipments and won’t fetch them again. This is consistent with how the shipment screen handles order data.

Steps to reproduce

You can debug and check the shipments parameter added in this PR to verify that the shipments are fetched successfully.

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@irfano irfano added type: task An internally driven task. feature: shipping labels Related to creating, ordering, or printing shipping labels. labels Apr 30, 2025
@irfano irfano added this to the 22.3 milestone Apr 30, 2025
) {
suspend operator fun invoke(order: Order): List<ShippableItemModel> {
val refunds = orderDetailRepository.getOrderRefunds(order.id)
val noRefundedProducts = refunds.getNonRefundedProducts(order.items)

val shipments = configDataStore.observeConfig(order.id).first()?.shipments // TODO Use this in the UI
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can test the output of this PR by debugging this shipment.

@dangermattic
Copy link
Collaborator

dangermattic commented Apr 30, 2025

1 Warning
⚠️ This PR is assigned to the milestone 22.3. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed this file because it was storing StoreOptions, not Configuration.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Apr 30, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit1053e9e
Direct Downloadwoocommerce-wear-prototype-build-pr13995-1053e9e.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Apr 30, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit1053e9e
Direct Downloadwoocommerce-prototype-build-pr13995-1053e9e.apk

@irfano irfano force-pushed the issue/WOOMOB-416-split-shipment-config-endpoint branch from dd100e8 to 753c079 Compare April 30, 2025 22:57
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 22.22222% with 42 lines in your changes missing coverage. Please review.

Project coverage is 38.26%. Comparing base (d16f51a) to head (1053e9e).
Report is 10 commits behind head on trunk.

Files with missing lines Patch % Lines
...oid/ui/orders/wooshippinglabels/networking/DTOs.kt 0.00% 15 Missing ⚠️
...inglabels/datasource/WooShippingConfigDataStore.kt 0.00% 11 Missing ⚠️
...inglabels/networking/WooShippingLabelRestClient.kt 0.00% 7 Missing ⚠️
...inglabels/networking/WooShippingLabelRepository.kt 0.00% 6 Missing ⚠️
...els/datasource/WooShippingStoreOptionsDataStore.kt 0.00% 2 Missing ⚠️
...d/ui/orders/wooshippinglabels/GetShippableItems.kt 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #13995      +/-   ##
============================================
- Coverage     38.27%   38.26%   -0.01%     
- Complexity     9488     9490       +2     
============================================
  Files          2118     2119       +1     
  Lines        116345   116394      +49     
  Branches      14933    14937       +4     
============================================
+ Hits          44532    44542      +10     
- Misses        67743    67781      +38     
- Partials       4070     4071       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: shipping labels Related to creating, ordering, or printing shipping labels. type: task An internally driven task. unit-tests-exemption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants