-
Notifications
You must be signed in to change notification settings - Fork 5
Add tracking request SCAC auto-detect option #272
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
Changes from all commits
0b67f6d
545567f
70efd0a
5e37901
0ebf393
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1308,10 +1308,17 @@ | |
| }, | ||
| "scac": { | ||
| "type": "string", | ||
| "description": "The carrier SCAC to use for this tracking request. Required unless `auto_detect_vocc_scac` is `true`.", | ||
| "example": "MSCU", | ||
| "minLength": 4, | ||
| "maxLength": 4 | ||
| }, | ||
| "auto_detect_vocc_scac": { | ||
| "type": "boolean", | ||
| "description": "Set to `true` to have Terminal49 infer the carrier SCAC from `request_number` when `scac` is not supplied. Detection is asynchronous: the tracking request is created immediately (HTTP `201`) with `status: \"pending\"` and `scac: null`. If a carrier is inferred, the request transitions to `status: \"created\"` with the detected `scac` populated. If no supported carrier can be inferred, it transitions to `status: \"failed\"` with `failed_reason: \"scac_auto_detect_failed\"` and no shipment is created. Poll the tracking request or use webhooks to observe the outcome — the create response does not include the detected `scac`.", | ||
| "default": false, | ||
| "example": true | ||
|
Comment on lines
+1316
to
+1320
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding Useful? React with 👍 / 👎. |
||
| }, | ||
| "ref_numbers": { | ||
| "type": "array", | ||
| "description": "Optional list of reference numbers to be added to the shipment when tracking request completes", | ||
|
|
@@ -1329,8 +1336,7 @@ | |
| }, | ||
| "required": [ | ||
| "request_type", | ||
| "request_number", | ||
| "scac" | ||
| "request_number" | ||
| ] | ||
|
Comment on lines
1337
to
1340
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With Prompt To Fix With AIThis is a comment left during a code review.
Path: docs/openapi.json
Line: 1346-1349
Comment:
**Missing Conditional SCAC Requirement**
With `scac` removed from `required`, the schema accepts a create request that has only `request_type` and `request_number`. That conflicts with the documented contract that callers must supply either `scac` or `auto_detect_vocc_scac: true`, so generated clients and validators can now allow a request the API is expected to reject.
How can I resolve this? If you propose a fix, please make it concise.
Comment on lines
1337
to
1340
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With the required list now only containing Useful? React with 👍 / 👎. |
||
| }, | ||
| "relationships": { | ||
|
|
@@ -1399,6 +1405,21 @@ | |
| "type": "tracking_request" | ||
| } | ||
| } | ||
| }, | ||
| "Example: Auto-detect carrier SCAC": { | ||
| "value": { | ||
| "data": { | ||
| "attributes": { | ||
| "request_type": "bill_of_lading", | ||
| "request_number": "MEDUFR030802", | ||
| "auto_detect_vocc_scac": true, | ||
| "ref_numbers": [ | ||
| "PO12345" | ||
| ] | ||
| }, | ||
| "type": "tracking_request" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1410,7 +1431,7 @@ | |
| "authorization": [] | ||
| } | ||
| ], | ||
| "description": "To track an ocean shipment, you create a new tracking request. \nTwo attributes are required to track a shipment. A `bill of lading/booking number` and a shipping line `SCAC`. \n\nOnce a tracking request is created we will attempt to fetch the shipment details and it's related containers from the shipping line. If the attempt is successful we will create in new shipment object including any related container objects. We will send a `tracking_request.succeeded` webhook notification to your webhooks. \n\nIf the attempt to fetch fails then we will send a `tracking_request.failed` webhook notification to your `webhooks`. \n\nA `tracking_request.succeeded` or `tracking_request.failed` webhook notificaiton will only be sent if you have atleast one active webhook. <br /><br /><Info>This endpoint is limited to 100 tracking requests per minute.</Info>", | ||
| "description": "To track an ocean shipment, create a new tracking request. `request_type` and `request_number` are always required. Supply either a shipping line `scac` or set `auto_detect_vocc_scac` to `true` to have Terminal49 infer the SCAC from the request number before creating the tracking request.\n\nAuto-detection uses the same carrier prediction capability as the Infer Tracking Number endpoint and runs asynchronously. The tracking request is created immediately (HTTP `201`) with `status: \"pending\"`; if no supported carrier can be inferred it transitions to `status: \"failed\"` with `failed_reason: \"scac_auto_detect_failed\"` and no shipment is created. Once a tracking request is created we will attempt to fetch the shipment details and its related containers from the shipping line. If the attempt is successful we will create a new shipment object including any related container objects. We will send a `tracking_request.succeeded` webhook notification to your webhooks.\n\nIf the attempt to fetch fails then we will send a `tracking_request.failed` webhook notification to your `webhooks`.\n\nA `tracking_request.succeeded` or `tracking_request.failed` webhook notification will only be sent if you have at least one active webhook. <br /><br /><Info>This endpoint is limited to 100 tracking requests per minute.</Info>", | ||
| "tags": [ | ||
| "Tracking Requests" | ||
| ], | ||
|
|
@@ -12131,9 +12152,10 @@ | |
| "shipping_line_unreachable", | ||
| "unrecognized_response", | ||
| "data_unavailable", | ||
| "scac_auto_detect_failed", | ||
| null | ||
| ], | ||
| "description": "If the tracking request has failed, or is currently failing, the last reason we were unable to complete the request", | ||
| "description": "If the tracking request has failed, or is currently failing, the last reason we were unable to complete the request. `scac_auto_detect_failed` means `auto_detect_vocc_scac` was set but no supported carrier SCAC could be inferred from the request number.", | ||
| "nullable": true | ||
| }, | ||
| "request_type": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,7 @@ export class TrackingRequestManager extends BaseManager { | |
| requestType: TrackingRequestType; | ||
| requestNumber: string; | ||
| scac?: string; | ||
| autoDetectVoccScac?: boolean; | ||
| refNumbers?: string[]; | ||
| shipmentTags?: string[]; | ||
| }): Promise<any> { | ||
|
|
@@ -119,16 +120,23 @@ export class TrackingRequestManager extends BaseManager { | |
| ); | ||
| } | ||
|
|
||
| const attributes: Record<string, unknown> = { | ||
| request_type: params.requestType, | ||
| request_number: params.requestNumber, | ||
| scac: params.scac ?? '', | ||
| ref_numbers: params.refNumbers, | ||
| shipment_tags: params.shipmentTags, | ||
| }; | ||
|
|
||
| if (params.autoDetectVoccScac) { | ||
| attributes.auto_detect_vocc_scac = true; | ||
| if (!params.scac) delete attributes.scac; | ||
| } | ||
|
Comment on lines
+131
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When callers pass both Prompt To Fix With AIThis is a comment left during a code review.
Path: sdks/typescript-sdk/src/client/managers/tracking-requests.ts
Line: 131-134
Comment:
**Conflicting SCAC Detection Payload**
When callers pass both `autoDetectVoccScac: true` and a non-empty `scac`, this branch sends both `auto_detect_vocc_scac` and `scac`. The documented auto-detect contract applies when `scac` is not supplied, so this reachable SDK call can produce an ambiguous request that the API may reject or resolve differently than the caller intended.
How can I resolve this? If you propose a fix, please make it concise.
Comment on lines
+131
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When callers pass both Useful? React with 👍 / 👎. |
||
|
|
||
| const payload = { | ||
| data: { | ||
| type: 'tracking_request' as const, | ||
| attributes: { | ||
| request_type: params.requestType, | ||
| request_number: params.requestNumber, | ||
| scac: params.scac ?? '', | ||
| ref_numbers: params.refNumbers, | ||
| shipment_tags: params.shipmentTags, | ||
| }, | ||
| attributes, | ||
| }, | ||
| }; | ||
|
|
||
|
|
||
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.
When auto-detect is used, this new description says the 201 response can return
status: "pending"withscac: null, but the response still references#/components/schemas/tracking_request, whoseattributes.scacremains a required string. Generated clients or validators built from this OpenAPI will reject or mis-type valid pending/failed auto-detect responses, so the tracking request response schema needs to allow a null or absent SCAC for those states.Useful? React with 👍 / 👎.