Skip to content

Commit

Permalink
fix: allied express local with proper schema sample
Browse files Browse the repository at this point in the history
  • Loading branch information
danh91 committed Feb 23, 2024
1 parent 9c4803c commit 535de06
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def parse_shipment_response(
messages = error.parse_error_response(response, settings)
shipment = (
_extract_details(response, settings, ctx=_response.ctx)
if not response.is_error and "result" in (response.data or {})
if not response.is_error and "result" in (response.response or {})
else None
)

Expand All @@ -34,7 +34,7 @@ def _extract_details(
shipment: shipping.LabelResponseType = lib.to_object(
shipping.LabelResponseType, data.response
)
label = shipment.soapenvBody.ns1getLabelResponse.result
label = shipment.result or shipment.soapenvBody.ns1getLabelResponse.result

return models.ShipmentDetails(
carrier_id=settings.carrier_id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from attr import s
from typing import Optional
from typing import Optional, Any
from jstruct import JStruct


Expand All @@ -18,7 +18,7 @@ class PriceType:
jobCode: Optional[DiscountClassType] = JStruct[DiscountClassType]
netPrice: Optional[str] = None
rateCode: Optional[DiscountClassType] = JStruct[DiscountClassType]
reason: Optional[str] = None
reason: Any = None


@s(auto_attribs=True)
Expand All @@ -29,7 +29,7 @@ class PriceDetailType:
@s(auto_attribs=True)
class Ns1GetLabelResponseType:
xmlnsns1: Optional[str] = None
result: Optional[str] = None
result: Any = None


@s(auto_attribs=True)
Expand All @@ -41,4 +41,5 @@ class SoapenvBodyType:
class LabelResponseType:
Tracking: Optional[str] = None
pricedetail: Optional[PriceDetailType] = JStruct[PriceDetailType]
result: Optional[str] = None
soapenvBody: Optional[SoapenvBodyType] = JStruct[SoapenvBodyType]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Tracking": "AET1021116",
"Tracking": "AET1520983",
"price_detail": {
"price": {
"chargeQuantity": "0",
Expand All @@ -8,21 +8,22 @@
"@xsi:nil": "1"
},
"discountRate": "0.0",
"grossPrice": "0.0",
"grossPrice": "14.21",
"jobCode": {
"@xsi:nil": "1"
},
"netPrice": "0.0",
"netPrice": "14.21",
"rateCode": {
"@xsi:nil": "1"
},
"reason": "No Hire time found"
"reason": null
}
},
"result": "CnN0YXJ0eHJlZgoxNDUwMQolJUVPRgo=",
"soapenv:Body": {
"ns1:getLabelResponse": {
"@xmlns:ns1": "http://neptune.alliedexpress.com.au/ttws-ejb",
"result": "CnN0YXJ0eHJlZgoxNDUwMQolJUVPRgo="
"result": null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def test_parse_error_response(self):
"docs": {"label": ANY},
"label_type": "PDF",
"meta": {"postal_code": "6155"},
"shipment_identifier": "AET1021116",
"tracking_number": "AET1021116",
"shipment_identifier": "AET1520983",
"tracking_number": "AET1520983",
},
[],
]
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_parse_error_response(self):
ShipmentCancelRequest = {"shipmentno": "123456789", "postalcode": "12345"}

ShipmentResponse = """{
"Tracking": "AET1021116",
"Tracking": "AET1520983",
"price_detail": {
"price": {
"chargeQuantity": "0",
Expand All @@ -250,21 +250,22 @@ def test_parse_error_response(self):
"@xsi:nil": "1"
},
"discountRate": "0.0",
"grossPrice": "0.0",
"grossPrice": "14.21",
"jobCode": {
"@xsi:nil": "1"
},
"netPrice": "0.0",
"netPrice": "14.21",
"rateCode": {
"@xsi:nil": "1"
},
"reason": "No Hire time found"
"reason": null
}
},
"result": "JVBERi0xLjMKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvUGFnZXMKL0NvdW50IDIKL0tpZHMgWyA0IDAgUiA5IDAgUiBdCj4+CmVuZG9iagoyIDAgb2JqCjw8Ci9Qcm9kdWNlciAocHlwZGYpCj4+CmVuZG9iagozIDAgb2JqCjw8Ci9UeXBlIC9DYXRhbG9nCi9QYWdlcyAxIDAgUgo+PgplbmRvYmoKNCAwIG9iago8PAovQ29udGVudHMgNSAwIFIKL01lZGlhQm94IFsgMCAwIDQxOS41Mjc2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VPRgo="
"result": null
}
}
}
Expand Down

0 comments on commit 535de06

Please sign in to comment.