Skip to content
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

Added update_shipment_tracking_details and list_shipment_boxes #1615

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions sp_api/api/fulfillment_inbound/fulfillment_inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,3 +1570,64 @@ def set_prep_details(self, **kwargs) -> ApiResponse:

return self._request(kwargs.pop('path'), data=kwargs)

@sp_endpoint('/inbound/fba/<version>/inboundPlans/{}/shipments/{}/boxes', method='GET')
def list_shipment_boxes(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse:
"""
list_shipment_boxes(self, **kwargs) -> ApiResponse:

Provides a paginated list of box packages in a shipment.

**Usage Plan:**

| Rate (requests per second) | Burst |
| ---- | ---- |
| 2 | 30 |

The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API.
Args:

pageSize:string | *OPTIONAL Identifier of a shipment. A shipment contains the boxes and units being inbounded.
paginationToken: | *OPTIONAL A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the pagination returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result.

Returns:
ApiResponse:
"""

return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId), params=kwargs)

@sp_endpoint('/inbound/fba/<version>/inboundPlans/{}/shipments/{}/trackingDetails', method='PUT')
def update_shipment_tracking_details(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse:
"""
Comment on lines +1598 to +1600
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider adding validation for the required 'body' parameter

The method should validate that the body parameter is present and contains the required structure before making the request to prevent silent failures.

Suggested change
@sp_endpoint('/inbound/fba/<version>/inboundPlans/{}/shipments/{}/trackingDetails', method='PUT')
def update_shipment_tracking_details(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse:
"""
@sp_endpoint('/inbound/fba/<version>/inboundPlans/{}/shipments/{}/trackingDetails', method='PUT')
def update_shipment_tracking_details(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse:
"""Updates the tracking details for a shipment.
Args:
inboundPlanId (str): The identifier for the inbound plan.
shipmentId (str): The identifier for the shipment.
**kwargs: Additional arguments
body (dict): Required. The request body containing tracking details.
Must contain:
- trackingDetails (list): List of tracking information
Returns:
ApiResponse
Raises:
ValueError: If the required body parameter or its required structure is missing
"""
if 'body' not in kwargs:
raise ValueError("The 'body' parameter is required for updating tracking details")
if not isinstance(kwargs['body'].get('trackingDetails'), list):
raise ValueError("The 'body' must contain 'trackingDetails' as a list")

update_shipment_tracking_details(self, **kwargs) -> ApiResponse:

Updates a shipment's tracking details.

**Usage Plan:**

| Rate (requests per second) | Burst |
| ---- | ---- |
| 2 | 2 |

The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API.
Args:

body: | * REQUIRED {
'trackingDetails': [
ltlTrackingDetail: [
billOfLadingNumber: string,
freightBillNumber: string<array>
],
spdTrackingDetail: [
spdTrackingItems:[
boxId: string,
trackingId: string,
]
],
],
}

Returns:
ApiResponse:
"""

return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId), data=kwargs)
Loading