diff --git a/CHANGELOG.md b/CHANGELOG.md index fff29f24..bcaa24ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## Next Release + +- Adds new `Claim` service for filing claims on EasyPost shipments and insurances + ## v9.3.0 (2024-07-12) - Adds new `shipment.recommend_ship_date`, `smartrate.recommend_ship_date`, and `smartrate.estimate_delivery_date` functions diff --git a/easypost/easypost_client.py b/easypost/easypost_client.py index 9cf12766..262833c1 100644 --- a/easypost/easypost_client.py +++ b/easypost/easypost_client.py @@ -18,6 +18,7 @@ BillingService, CarrierAccountService, CarrierMetadataService, + ClaimService, CustomsInfoService, CustomsItemService, EndShipperService, @@ -62,6 +63,7 @@ def __init__( self.billing = BillingService(self) self.carrier_account = CarrierAccountService(self) self.carrier_metadata = CarrierMetadataService(self) + self.claim = ClaimService(self) self.customs_info = CustomsInfoService(self) self.customs_item = CustomsItemService(self) self.end_shipper = EndShipperService(self) diff --git a/easypost/easypost_object.py b/easypost/easypost_object.py index 61bb09d5..abc17d8c 100644 --- a/easypost/easypost_object.py +++ b/easypost/easypost_object.py @@ -18,6 +18,7 @@ "brd": "Brand", "ca": "CarrierAccount", "cfrep": "Report", + "clm": "Claim", "cstinfo": "CustomsInfo", "cstitem": "CustomsItem", "es": "EndShipper", diff --git a/easypost/models/__init__.py b/easypost/models/__init__.py index 79320a7d..9df262ba 100644 --- a/easypost/models/__init__.py +++ b/easypost/models/__init__.py @@ -5,6 +5,7 @@ from easypost.models.billing import Billing from easypost.models.brand import Brand from easypost.models.carrier_account import CarrierAccount +from easypost.models.claim import Claim from easypost.models.customs_info import CustomsInfo from easypost.models.customs_item import CustomsItem from easypost.models.end_shipper import EndShipper diff --git a/easypost/models/claim.py b/easypost/models/claim.py new file mode 100644 index 00000000..c0c6dd69 --- /dev/null +++ b/easypost/models/claim.py @@ -0,0 +1,5 @@ +from easypost.easypost_object import EasyPostObject + + +class Claim(EasyPostObject): + pass diff --git a/easypost/services/__init__.py b/easypost/services/__init__.py index 66e8346b..f042f517 100644 --- a/easypost/services/__init__.py +++ b/easypost/services/__init__.py @@ -7,6 +7,7 @@ from easypost.services.billing_service import BillingService from easypost.services.carrier_account_service import CarrierAccountService from easypost.services.carrier_metadata_service import CarrierMetadataService +from easypost.services.claim_service import ClaimService from easypost.services.customs_info_service import CustomsInfoService from easypost.services.customs_item_service import CustomsItemService from easypost.services.end_shipper_service import EndShipperService diff --git a/easypost/services/base_service.py b/easypost/services/base_service.py index 203aa5f2..b9499d06 100644 --- a/easypost/services/base_service.py +++ b/easypost/services/base_service.py @@ -42,47 +42,51 @@ def _instance_url(self, class_name: str, id: str) -> str: """Generate an instance URL based on a class name and ID.""" return f"{self._class_url(class_name)}/{id}" - def _create_resource(self, class_name: str, **params) -> Any: + def _create_resource(self, class_name: str, beta: bool = False, **params) -> Any: """Create an EasyPost object via the EasyPost API.""" url = self._class_url(class_name) wrapped_params = {self._snakecase_name(class_name): params} - response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params) + response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params, beta=beta) return convert_to_easypost_object(response=response) - def _all_resources(self, class_name: str, filters: Optional[Dict[str, Any]] = None, **params) -> Any: + def _all_resources( + self, class_name: str, filters: Optional[Dict[str, Any]] = None, beta: bool = False, **params + ) -> Any: """Retrieve a list of EasyPostObjects from the EasyPost API.""" url = self._class_url(class_name) - response = Requestor(self._client).request(method=RequestMethod.GET, url=url, params=params) + response = Requestor(self._client).request(method=RequestMethod.GET, url=url, params=params, beta=beta) if filters: # presence of filters indicates we are dealing with a paginated response response[_FILTERS_KEY] = filters # Save the filters used to reference in potential get_next_page call return convert_to_easypost_object(response=response) - def _retrieve_resource(self, class_name: str, id: str) -> Any: + def _retrieve_resource(self, class_name: str, id: str, beta: bool = False) -> Any: """Retrieve an object from the EasyPost API.""" url = self._instance_url(class_name, id) - response = Requestor(self._client).request(method=RequestMethod.GET, url=url) + response = Requestor(self._client).request(method=RequestMethod.GET, url=url, beta=beta) return convert_to_easypost_object(response=response) - def _update_resource(self, class_name: str, id: str, method: RequestMethod = RequestMethod.PATCH, **params) -> Any: + def _update_resource( + self, class_name: str, id: str, method: RequestMethod = RequestMethod.PATCH, beta: bool = False, **params + ) -> Any: """Update an EasyPost object via the EasyPost API.""" url = self._instance_url(class_name, id) wrapped_params = {self._snakecase_name(class_name): params} - response = Requestor(self._client).request(method=method, url=url, params=wrapped_params) + response = Requestor(self._client).request(method=method, url=url, params=wrapped_params, beta=beta) return convert_to_easypost_object(response=response) - def _delete_resource(self, class_name: str, id: str) -> Any: + def _delete_resource(self, class_name: str, id: str, beta: bool = False) -> Any: """Delete an EasyPost object via the EasyPost API.""" url = self._instance_url(class_name, id) - response = Requestor(self._client).request(method=RequestMethod.DELETE, url=url) + response = Requestor(self._client).request(method=RequestMethod.DELETE, url=url, beta=beta) return convert_to_easypost_object(response=response) diff --git a/easypost/services/claim_service.py b/easypost/services/claim_service.py new file mode 100644 index 00000000..8604dd4f --- /dev/null +++ b/easypost/services/claim_service.py @@ -0,0 +1,70 @@ +from typing import ( + Any, + Dict, + Optional, +) + +from easypost.easypost_object import convert_to_easypost_object +from easypost.models import Claim +from easypost.requestor import ( + RequestMethod, + Requestor, +) +from easypost.services.base_service import BaseService + + +class ClaimService(BaseService): + def __init__(self, client): + self._client = client + self._model_class = Claim.__name__ + + def create(self, **params) -> Claim: + """Create a Claim.""" + url = "/claims" + + response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=params, beta=False) + + return convert_to_easypost_object(response=response) + + def all(self, **params) -> Dict[str, Any]: + """Retrieve a list of Claims.""" + filters = { + "key": "claims", + } + + return self._all_resources(class_name=self._model_class, filters=filters, beta=False, **params) + + def retrieve(self, id: str) -> Claim: + """Retrieve a Claim.""" + return self._retrieve_resource(class_name=self._model_class, id=id, beta=False) + + def get_next_page( + self, + claims: Dict[str, Any], + page_size: int, + optional_params: Optional[Dict[str, Any]] = None, + ) -> Dict[str, Any]: + """Retrieve the next page of the list Claim response.""" + self._check_has_next_page(collection=claims) + + params = { + "before_id": claims["claims"][-1].id, + "page_size": page_size, + } + + if optional_params: + params.update(optional_params) + + return self.all(**params) + + def cancel(self, id: str) -> Claim: + """Cancel a Claim.""" + url = f"/claims/{id}/cancel" + + response = Requestor(self._client).request( + method=RequestMethod.POST, + url=url, + beta=False, + ) + + return convert_to_easypost_object(response=response) diff --git a/examples b/examples index b9fde9be..bcfb3b90 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit b9fde9bead7750256bc986802841ce7576eee0a4 +Subproject commit bcfb3b900550b99e9e4ded9acf4fbd35f1df349f diff --git a/tests/cassettes/test_claim_all.yaml b/tests/cassettes/test_claim_all.yaml new file mode 100644 index 00000000..99e291f7 --- /dev/null +++ b/tests/cassettes/test_claim_all.yaml @@ -0,0 +1,128 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + authorization: + - + user-agent: + - + method: GET + uri: https://api.easypost.com/v2/claims?page_size=5 + response: + body: + string: '{"claims": [{"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/7b9b0171ae7b4e258f765822e7cddb71.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/2cd9fdd33a7d40fc84ac8f87c3da1f86.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/d3aebbc42e884769ad810c92c26ad8ad.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:40", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-23T17:53:40"}], + "id": "clm_097e86d630e44e83b736c48c1271fed3", "insurance_amount": "100.00", + "insurance_id": "ins_33a9255ab9f443c18a1c1876bc6e25a4", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-23T17:53:40", "tracking_code": "9400100110368066361841", "type": + "damage", "updated_at": "2024-07-23T17:53:40"}, {"approved_amount": null, + "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/836a3784a67e429ca0d30f10f64cb0bc.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/a1316f8afc5843d7b2d1370dfb7e73d3.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/4d3502f6a6e64972913e43fc4191b4cd.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:36", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-23T17:53:36"}], + "id": "clm_097eb623597146bab94e9ef701364d4f", "insurance_amount": "100.00", + "insurance_id": "ins_6aa59cf8618843c09b4707e1f3f74486", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-23T17:53:36", "tracking_code": "9400100110368066361827", "type": + "damage", "updated_at": "2024-07-23T17:53:36"}, {"approved_amount": null, + "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/7280de6a4ce249e6af34cfd8fc2c8613.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/9faca9b590ed4616aaa385e717969828.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/5c641ae1e5a54a53ab6ded433ebfabdc.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:10:33", "description": "Test description", "history": [{"status": + "cancelled", "status_detail": "Claim cancellation was requested.", "timestamp": + "2024-07-23T17:12:03"}, {"status": "submitted", "status_detail": "Claim was + created.", "timestamp": "2024-07-23T17:10:33"}], "id": "clm_097e39b748d24c32a0bd61840fc0763f", + "insurance_amount": "249.99", "insurance_id": "ins_d15880e5772c4373aec497744fa4da54", + "mode": "test", "object": "Claim", "payment_method": "easypost_wallet", "recipient_name": + null, "requested_amount": "100.00", "salvage_value": null, "shipment_id": + "shp_09a808dae97442f3aa7fbd994a3533d4", "status": "cancelled", "status_detail": + "Claim cancellation was requested.", "status_timestamp": "2024-07-23T17:12:03", + "tracking_code": "9470100110368066351889", "type": "damage", "updated_at": + "2024-07-23T17:12:03"}, {"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/1d0c4ff3d71c4f5d8ec5c21bcfeaf419.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/8f78018b1c6941cdafd1ca9d36579e40.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/973d2a48b6b04423b1d112dff79e85e3.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-22T20:47:51", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-22T20:47:51"}], + "id": "clm_097ed32c795141499bb0a5e17a4fe24f", "insurance_amount": "249.99", + "insurance_id": "ins_fa5c89fcf765494b921a96c4e4004476", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_5bcff1867a1f4a29a67db9a84a2082c5", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-22T20:47:51", "tracking_code": "9434600110368065978707", "type": + "damage", "updated_at": "2024-07-22T20:47:51"}, {"approved_amount": null, + "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/1d0c4ff3d71c4f5d8ec5c21bcfeaf419.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/8f78018b1c6941cdafd1ca9d36579e40.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/973d2a48b6b04423b1d112dff79e85e3.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-22T20:47:51", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-22T20:47:51"}], + "id": "clm_097ed32c795141499bb0a5e17a4fe24f", "insurance_amount": "249.99", + "insurance_id": "ins_fa5c89fcf765494b921a96c4e4004476", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_5bcff1867a1f4a29a67db9a84a2082c5", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-22T20:47:51", "tracking_code": "9434600110368065978707", "type": + "damage", "updated_at": "2024-07-22T20:47:51"}], "has_more": true}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '5708' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 4764841f669fee25f41d2db300528ce6 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb35nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.053691' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_claim_cancel.yaml b/tests/cassettes/test_claim_cancel.yaml new file mode 100644 index 00000000..9d533a23 --- /dev/null +++ b/tests/cassettes/test_claim_cancel.yaml @@ -0,0 +1,705 @@ +interactions: +- request: + body: '{"shipment": {"from_address": {"name": "Jack Sparrow", "street1": "388 + Townsend St", "street2": "Apt 20", "city": "San Francisco", "state": "CA", "zip": + "94107", "country": "US", "email": "test@example.com", "phone": "5555555555"}, + "to_address": {"name": "Elizabeth Swan", "street1": "179 N Harbor Dr", "city": + "Redondo Beach", "state": "CA", "zip": "90277", "country": "US", "email": "test@example.com", + "phone": "5555555555"}, "parcel": {"length": 10, "width": 8, "height": 4, "weight": + 15.4}, "customs_info": {"eel_pfc": "NOEEI 30.37(a)", "customs_certify": true, + "customs_signer": "Steve Brule", "contents_type": "merchandise", "contents_explanation": + "", "restriction_type": "none", "non_delivery_option": "return", "customs_items": + [{"description": "Sweet shirts", "quantity": 2, "weight": 11, "value": 23.25, + "hs_tariff_number": "654321", "origin_country": "US"}]}, "options": {"label_format": + "PNG", "invoice_number": "123"}, "reference": "123"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '954' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments + response: + body: + string: '{"created_at": "2024-07-23T17:53:42Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + null, "updated_at": "2024-07-23T17:53:42Z", "batch_id": null, "batch_status": + null, "batch_message": null, "customs_info": {"id": "cstinfo_e367a8bdacc349f1aa99400ee0522aa9", + "object": "CustomsInfo", "created_at": "2024-07-23T17:53:42Z", "updated_at": + "2024-07-23T17:53:42Z", "contents_explanation": "", "contents_type": "merchandise", + "customs_certify": true, "customs_signer": "Steve Brule", "eel_pfc": "NOEEI + 30.37(a)", "non_delivery_option": "return", "restriction_comments": null, + "restriction_type": "none", "mode": "test", "declaration": null, "customs_items": + [{"id": "cstitem_9a7ad631dbb14255a0cd76209f3c4d76", "object": "CustomsItem", + "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "description": "Sweet shirts", "hs_tariff_number": "654321", "origin_country": + "US", "quantity": 2, "value": "23.25", "weight": 11.0, "code": null, "mode": + "test", "manufacturer": null, "currency": null, "eccn": null, "printed_commodity_identifier": + null}]}, "from_address": {"id": "adr_7f98d03a491c11efa416ac1f6bc53342", "object": + "Address", "created_at": "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:42+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": null, "order_id": null, "parcel": {"id": "prcl_638b6dd2ce5548ec85d67b255accfbd2", + "object": "Parcel", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": null, "rates": [{"id": "rate_f5af06c34647410c94997ff78cf3d5eb", + "object": "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_6f47529b84714dc88fb651a807aa6353", + "object": "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_bbe31567958340158fffe99976c707a1", + "object": "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": null, "tracker": null, "to_address": {"id": "adr_7f960d15491c11efb81cac1f6bc539ae", + "object": "Address", "created_at": "2024-07-23T17:53:42+00:00", "updated_at": + "2024-07-23T17:53:42+00:00", "name": "Elizabeth Swan", "company": null, "street1": + "179 N Harbor Dr", "street2": null, "city": "Redondo Beach", "state": "CA", + "zip": "90277", "country": "US", "phone": "", "email": "", + "mode": "test", "carrier_facility": null, "residential": null, "federal_tax_id": + null, "state_tax_id": null, "verifications": {}}, "usps_zone": 4, "return_address": + {"id": "adr_7f98d03a491c11efa416ac1f6bc53342", "object": "Address", "created_at": + "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:42+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7f960d15491c11efb81cac1f6bc539ae", "object": + "Address", "created_at": "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:42+00:00", + "name": "Elizabeth Swan", "company": null, "street1": "179 N Harbor Dr", "street2": + null, "city": "Redondo Beach", "state": "CA", "zip": "90277", "country": "US", + "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "forms": [], "fees": [], "id": "shp_82fecc386f314823ad6b1a35365b7f4e", + "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '6912' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + location: + - /api/v2/shipments/shp_82fecc386f314823ad6b1a35365b7f4e + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648423669fee25f40ba25a00528d65 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb40nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.738361' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 201 + message: Created +- request: + body: '{"rate": {"id": "rate_bbe31567958340158fffe99976c707a1"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '57' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments/shp_82fecc386f314823ad6b1a35365b7f4e/buy + response: + body: + string: '{"created_at": "2024-07-23T17:53:42Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + "9400100110368066361872", "updated_at": "2024-07-23T17:53:43Z", "batch_id": + null, "batch_status": null, "batch_message": null, "customs_info": {"id": + "cstinfo_e367a8bdacc349f1aa99400ee0522aa9", "object": "CustomsInfo", "created_at": + "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", "contents_explanation": + "", "contents_type": "merchandise", "customs_certify": true, "customs_signer": + "Steve Brule", "eel_pfc": "NOEEI 30.37(a)", "non_delivery_option": "return", + "restriction_comments": null, "restriction_type": "none", "mode": "test", + "declaration": null, "customs_items": [{"id": "cstitem_9a7ad631dbb14255a0cd76209f3c4d76", + "object": "CustomsItem", "created_at": "2024-07-23T17:53:42Z", "updated_at": + "2024-07-23T17:53:42Z", "description": "Sweet shirts", "hs_tariff_number": + "654321", "origin_country": "US", "quantity": 2, "value": "23.25", "weight": + 11.0, "code": null, "mode": "test", "manufacturer": null, "currency": null, + "eccn": null, "printed_commodity_identifier": null}]}, "from_address": {"id": + "adr_7f98d03a491c11efa416ac1f6bc53342", "object": "Address", "created_at": + "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:42+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": null, "order_id": null, "parcel": {"id": "prcl_638b6dd2ce5548ec85d67b255accfbd2", + "object": "Parcel", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": {"object": "PostageLabel", "id": "pl_29c24685eef84a2e8540c4da72373ca6", + "created_at": "2024-07-23T17:53:43Z", "updated_at": "2024-07-23T17:53:43Z", + "date_advance": 0, "integrated_form": "none", "label_date": "2024-07-23T17:53:43Z", + "label_resolution": 300, "label_size": "4x6", "label_type": "default", "label_file_type": + "image/png", "label_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20240723/e89d129a870fc84ffeaa8325ad6c2b40f7.png", + "label_pdf_url": null, "label_zpl_url": null, "label_epl2_url": null, "label_file": + null}, "rates": [{"id": "rate_f5af06c34647410c94997ff78cf3d5eb", "object": + "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_6f47529b84714dc88fb651a807aa6353", + "object": "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_bbe31567958340158fffe99976c707a1", + "object": "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": {"id": "rate_bbe31567958340158fffe99976c707a1", "object": + "Rate", "created_at": "2024-07-23T17:53:43Z", "updated_at": "2024-07-23T17:53:43Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, "tracker": {"id": "trk_094807d115c14008b09588e9a336d226", + "object": "Tracker", "mode": "test", "tracking_code": "9400100110368066361872", + "status": "unknown", "status_detail": "unknown", "created_at": "2024-07-23T17:53:43Z", + "updated_at": "2024-07-23T17:53:43Z", "signed_by": null, "weight": null, "est_delivery_date": + null, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier": "USPS", + "tracking_details": [], "fees": [], "carrier_detail": null, "public_url": + "https://track.easypost.com/djE6dHJrXzA5NDgwN2QxMTVjMTQwMDhiMDk1ODhlOWEzMzZkMjI2"}, + "to_address": {"id": "adr_7f960d15491c11efb81cac1f6bc539ae", "object": "Address", + "created_at": "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:43+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + "", "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "usps_zone": + 4, "return_address": {"id": "adr_7f98d03a491c11efa416ac1f6bc53342", "object": + "Address", "created_at": "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:42+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7f960d15491c11efb81cac1f6bc539ae", "object": + "Address", "created_at": "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:43+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + "", "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "forms": + [], "fees": [{"object": "Fee", "type": "LabelFee", "amount": "0.00000", "charged": + true, "refunded": false}, {"object": "Fee", "type": "PostageFee", "amount": + "5.93000", "charged": true, "refunded": false}], "id": "shp_82fecc386f314823ad6b1a35365b7f4e", + "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '9037' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648423669fee26f40ba25a00528e11 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb40nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '1.069427' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: '{"amount": "100.00"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments/shp_82fecc386f314823ad6b1a35365b7f4e/insure + response: + body: + string: '{"created_at": "2024-07-23T17:53:42Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + "9400100110368066361872", "updated_at": "2024-07-23T17:53:43Z", "batch_id": + null, "batch_status": null, "batch_message": null, "customs_info": {"id": + "cstinfo_e367a8bdacc349f1aa99400ee0522aa9", "object": "CustomsInfo", "created_at": + "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", "contents_explanation": + "", "contents_type": "merchandise", "customs_certify": true, "customs_signer": + "Steve Brule", "eel_pfc": "NOEEI 30.37(a)", "non_delivery_option": "return", + "restriction_comments": null, "restriction_type": "none", "mode": "test", + "declaration": null, "customs_items": [{"id": "cstitem_9a7ad631dbb14255a0cd76209f3c4d76", + "object": "CustomsItem", "created_at": "2024-07-23T17:53:42Z", "updated_at": + "2024-07-23T17:53:42Z", "description": "Sweet shirts", "hs_tariff_number": + "654321", "origin_country": "US", "quantity": 2, "value": "23.25", "weight": + 11.0, "code": null, "mode": "test", "manufacturer": null, "currency": null, + "eccn": null, "printed_commodity_identifier": null}]}, "from_address": {"id": + "adr_7f98d03a491c11efa416ac1f6bc53342", "object": "Address", "created_at": + "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:42+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": "100.00", "order_id": null, "parcel": {"id": "prcl_638b6dd2ce5548ec85d67b255accfbd2", + "object": "Parcel", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": {"object": "PostageLabel", "id": "pl_29c24685eef84a2e8540c4da72373ca6", + "created_at": "2024-07-23T17:53:43Z", "updated_at": "2024-07-23T17:53:43Z", + "date_advance": 0, "integrated_form": "none", "label_date": "2024-07-23T17:53:43Z", + "label_resolution": 300, "label_size": "4x6", "label_type": "default", "label_file_type": + "image/png", "label_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20240723/e89d129a870fc84ffeaa8325ad6c2b40f7.png", + "label_pdf_url": null, "label_zpl_url": null, "label_epl2_url": null, "label_file": + null}, "rates": [{"id": "rate_f5af06c34647410c94997ff78cf3d5eb", "object": + "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_6f47529b84714dc88fb651a807aa6353", + "object": "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_bbe31567958340158fffe99976c707a1", + "object": "Rate", "created_at": "2024-07-23T17:53:42Z", "updated_at": "2024-07-23T17:53:42Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": {"id": "rate_bbe31567958340158fffe99976c707a1", "object": + "Rate", "created_at": "2024-07-23T17:53:43Z", "updated_at": "2024-07-23T17:53:43Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, "tracker": {"id": "trk_094807d115c14008b09588e9a336d226", + "object": "Tracker", "mode": "test", "tracking_code": "9400100110368066361872", + "status": "pre_transit", "status_detail": "status_update", "created_at": "2024-07-23T17:53:43Z", + "updated_at": "2024-07-23T17:53:43Z", "signed_by": null, "weight": null, "est_delivery_date": + "2024-07-23T17:53:43Z", "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", + "carrier": "USPS", "tracking_details": [{"object": "TrackingDetail", "message": + "Pre-Shipment Info Sent to USPS", "description": "", "status": "pre_transit", + "status_detail": "status_update", "datetime": "2024-06-23T17:53:43Z", "source": + "USPS", "carrier_code": "", "tracking_location": {"object": "TrackingLocation", + "city": null, "state": null, "country": null, "zip": null}}, {"object": "TrackingDetail", + "message": "Shipping Label Created", "description": "", "status": "pre_transit", + "status_detail": "status_update", "datetime": "2024-06-24T06:30:43Z", "source": + "USPS", "carrier_code": "", "tracking_location": {"object": "TrackingLocation", + "city": "HOUSTON", "state": "TX", "country": null, "zip": "77063"}}], "fees": + [], "carrier_detail": {"object": "CarrierDetail", "service": "First-Class + Package Service", "container_type": null, "est_delivery_date_local": null, + "est_delivery_time_local": null, "origin_location": "HOUSTON TX, 77001", "origin_tracking_location": + {"object": "TrackingLocation", "city": "HOUSTON", "state": "TX", "country": + null, "zip": "77063"}, "destination_location": "CHARLESTON SC, 29401", "destination_tracking_location": + null, "guaranteed_delivery_date": null, "alternate_identifier": null, "initial_delivery_attempt": + null}, "public_url": "https://track.easypost.com/djE6dHJrXzA5NDgwN2QxMTVjMTQwMDhiMDk1ODhlOWEzMzZkMjI2"}, + "to_address": {"id": "adr_7f960d15491c11efb81cac1f6bc539ae", "object": "Address", + "created_at": "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:43+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + null, "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "usps_zone": + 4, "return_address": {"id": "adr_7f98d03a491c11efa416ac1f6bc53342", "object": + "Address", "created_at": "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:42+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7f960d15491c11efb81cac1f6bc539ae", "object": + "Address", "created_at": "2024-07-23T17:53:42+00:00", "updated_at": "2024-07-23T17:53:43+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + null, "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "forms": + [], "fees": [{"object": "Fee", "type": "LabelFee", "amount": "0.00000", "charged": + true, "refunded": false}, {"object": "Fee", "type": "PostageFee", "amount": + "5.93000", "charged": true, "refunded": false}, {"object": "Fee", "type": + "InsuranceFee", "amount": "1.00000", "charged": true, "refunded": false}], + "id": "shp_82fecc386f314823ad6b1a35365b7f4e", "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '10261' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648423669fee27f40ba25a00528f1c + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb39nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.267550' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: '{"type": "damage", "email_evidence_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "invoice_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "supporting_documentation_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "description": "Test description", "contact_email": "test@example.com", "tracking_code": + "9400100110368066361872", "amount": "100.00"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '618' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/claims + response: + body: + string: '{"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/533eff379afa47759cdc14f19e190fc7.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/4715d1ddc5e448ad924c029d8407b9e4.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/987f3e1a094044219e640163b1074ff7.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:44", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-23T17:53:44"}], + "id": "clm_097eda66d06e42ec84449bbd34671a7d", "insurance_amount": "100.00", + "insurance_id": "ins_8d75d3dcf398461aaa330e48dbd4c19e", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_82fecc386f314823ad6b1a35365b7f4e", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-23T17:53:44", "tracking_code": "9400100110368066361872", "type": + "damage", "updated_at": "2024-07-23T17:53:44"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '1111' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648423669fee28f40ba25a00528f52 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb36nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.823459' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 201 + message: Created +- request: + body: '{}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/claims/clm_097eda66d06e42ec84449bbd34671a7d/cancel + response: + body: + string: '{"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/533eff379afa47759cdc14f19e190fc7.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/4715d1ddc5e448ad924c029d8407b9e4.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/987f3e1a094044219e640163b1074ff7.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:44", "description": "Test description", "history": [{"status": + "cancelled", "status_detail": "Claim cancellation was requested.", "timestamp": + "2024-07-23T17:53:45"}, {"status": "submitted", "status_detail": "Claim was + created.", "timestamp": "2024-07-23T17:53:44"}], "id": "clm_097eda66d06e42ec84449bbd34671a7d", + "insurance_amount": "100.00", "insurance_id": "ins_8d75d3dcf398461aaa330e48dbd4c19e", + "mode": "test", "object": "Claim", "payment_method": "easypost_wallet", "recipient_name": + null, "requested_amount": "100.00", "salvage_value": null, "shipment_id": + "shp_82fecc386f314823ad6b1a35365b7f4e", "status": "cancelled", "status_detail": + "Claim cancellation was requested.", "status_timestamp": "2024-07-23T17:53:45", + "tracking_code": "9400100110368066361872", "type": "damage", "updated_at": + "2024-07-23T17:53:45"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '1235' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648423669fee29f40ba25a00529016 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb34nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.042985' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_claim_create.yaml b/tests/cassettes/test_claim_create.yaml new file mode 100644 index 00000000..3c18f830 --- /dev/null +++ b/tests/cassettes/test_claim_create.yaml @@ -0,0 +1,626 @@ +interactions: +- request: + body: '{"shipment": {"from_address": {"name": "Jack Sparrow", "street1": "388 + Townsend St", "street2": "Apt 20", "city": "San Francisco", "state": "CA", "zip": + "94107", "country": "US", "email": "test@example.com", "phone": "5555555555"}, + "to_address": {"name": "Elizabeth Swan", "street1": "179 N Harbor Dr", "city": + "Redondo Beach", "state": "CA", "zip": "90277", "country": "US", "email": "test@example.com", + "phone": "5555555555"}, "parcel": {"length": 10, "width": 8, "height": 4, "weight": + 15.4}, "customs_info": {"eel_pfc": "NOEEI 30.37(a)", "customs_certify": true, + "customs_signer": "Steve Brule", "contents_type": "merchandise", "contents_explanation": + "", "restriction_type": "none", "non_delivery_option": "return", "customs_items": + [{"description": "Sweet shirts", "quantity": 2, "weight": 11, "value": 23.25, + "hs_tariff_number": "654321", "origin_country": "US"}]}, "options": {"label_format": + "PNG", "invoice_number": "123"}, "reference": "123"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '954' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments + response: + body: + string: '{"created_at": "2024-07-23T17:53:34Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + null, "updated_at": "2024-07-23T17:53:34Z", "batch_id": null, "batch_status": + null, "batch_message": null, "customs_info": {"id": "cstinfo_cd7d8756bb1c462fb4497cc48a3e9a26", + "object": "CustomsInfo", "created_at": "2024-07-23T17:53:34Z", "updated_at": + "2024-07-23T17:53:34Z", "contents_explanation": "", "contents_type": "merchandise", + "customs_certify": true, "customs_signer": "Steve Brule", "eel_pfc": "NOEEI + 30.37(a)", "non_delivery_option": "return", "restriction_comments": null, + "restriction_type": "none", "mode": "test", "declaration": null, "customs_items": + [{"id": "cstitem_629ef3e844fd4e8f8b63a19a0e7d413f", "object": "CustomsItem", + "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "description": "Sweet shirts", "hs_tariff_number": "654321", "origin_country": + "US", "quantity": 2, "value": "23.25", "weight": 11.0, "code": null, "mode": + "test", "manufacturer": null, "currency": null, "eccn": null, "printed_commodity_identifier": + null}]}, "from_address": {"id": "adr_7ae4b187491c11efb529ac1f6bc539ae", "object": + "Address", "created_at": "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:34+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": null, "order_id": null, "parcel": {"id": "prcl_cc4cec1b603649ba8dab40990c48b080", + "object": "Parcel", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": null, "rates": [{"id": "rate_323b536e3901476c844419020d496965", + "object": "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_2572bc64788d47aa8389a4e5d8a0e1b6", + "object": "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_ec61cdb04bbf404e9724c18745a1493c", + "object": "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": null, "tracker": null, "to_address": {"id": "adr_7ae1fcad491c11efb015ac1f6bc539aa", + "object": "Address", "created_at": "2024-07-23T17:53:34+00:00", "updated_at": + "2024-07-23T17:53:34+00:00", "name": "Elizabeth Swan", "company": null, "street1": + "179 N Harbor Dr", "street2": null, "city": "Redondo Beach", "state": "CA", + "zip": "90277", "country": "US", "phone": "", "email": "", + "mode": "test", "carrier_facility": null, "residential": null, "federal_tax_id": + null, "state_tax_id": null, "verifications": {}}, "usps_zone": 4, "return_address": + {"id": "adr_7ae4b187491c11efb529ac1f6bc539ae", "object": "Address", "created_at": + "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:34+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7ae1fcad491c11efb015ac1f6bc539aa", "object": + "Address", "created_at": "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:34+00:00", + "name": "Elizabeth Swan", "company": null, "street1": "179 N Harbor Dr", "street2": + null, "city": "Redondo Beach", "state": "CA", "zip": "90277", "country": "US", + "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "forms": [], "fees": [], "id": "shp_d692021679d54c0c9da828499fb1a8de", + "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '6912' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + location: + - /api/v2/shipments/shp_d692021679d54c0c9da828499fb1a8de + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648425669fee1ef40c2a10005285e1 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb53nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb4nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.870562' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 201 + message: Created +- request: + body: '{"rate": {"id": "rate_ec61cdb04bbf404e9724c18745a1493c"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '57' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments/shp_d692021679d54c0c9da828499fb1a8de/buy + response: + body: + string: '{"created_at": "2024-07-23T17:53:34Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + "9400100110368066361827", "updated_at": "2024-07-23T17:53:35Z", "batch_id": + null, "batch_status": null, "batch_message": null, "customs_info": {"id": + "cstinfo_cd7d8756bb1c462fb4497cc48a3e9a26", "object": "CustomsInfo", "created_at": + "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", "contents_explanation": + "", "contents_type": "merchandise", "customs_certify": true, "customs_signer": + "Steve Brule", "eel_pfc": "NOEEI 30.37(a)", "non_delivery_option": "return", + "restriction_comments": null, "restriction_type": "none", "mode": "test", + "declaration": null, "customs_items": [{"id": "cstitem_629ef3e844fd4e8f8b63a19a0e7d413f", + "object": "CustomsItem", "created_at": "2024-07-23T17:53:34Z", "updated_at": + "2024-07-23T17:53:34Z", "description": "Sweet shirts", "hs_tariff_number": + "654321", "origin_country": "US", "quantity": 2, "value": "23.25", "weight": + 11.0, "code": null, "mode": "test", "manufacturer": null, "currency": null, + "eccn": null, "printed_commodity_identifier": null}]}, "from_address": {"id": + "adr_7ae4b187491c11efb529ac1f6bc539ae", "object": "Address", "created_at": + "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:34+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": null, "order_id": null, "parcel": {"id": "prcl_cc4cec1b603649ba8dab40990c48b080", + "object": "Parcel", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": {"object": "PostageLabel", "id": "pl_d5acf6e211c3407a88885e813c0b0977", + "created_at": "2024-07-23T17:53:35Z", "updated_at": "2024-07-23T17:53:35Z", + "date_advance": 0, "integrated_form": "none", "label_date": "2024-07-23T17:53:35Z", + "label_resolution": 300, "label_size": "4x6", "label_type": "default", "label_file_type": + "image/png", "label_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20240723/e887e526fb4a5c4354a3d78a0d7f54e942.png", + "label_pdf_url": null, "label_zpl_url": null, "label_epl2_url": null, "label_file": + null}, "rates": [{"id": "rate_323b536e3901476c844419020d496965", "object": + "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_2572bc64788d47aa8389a4e5d8a0e1b6", + "object": "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_ec61cdb04bbf404e9724c18745a1493c", + "object": "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": {"id": "rate_ec61cdb04bbf404e9724c18745a1493c", "object": + "Rate", "created_at": "2024-07-23T17:53:35Z", "updated_at": "2024-07-23T17:53:35Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, "tracker": {"id": "trk_40df1d2c30a74d65b09c6fe5fb904cc0", + "object": "Tracker", "mode": "test", "tracking_code": "9400100110368066361827", + "status": "unknown", "status_detail": "unknown", "created_at": "2024-07-23T17:53:35Z", + "updated_at": "2024-07-23T17:53:35Z", "signed_by": null, "weight": null, "est_delivery_date": + null, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier": "USPS", + "tracking_details": [], "fees": [], "carrier_detail": null, "public_url": + "https://track.easypost.com/djE6dHJrXzQwZGYxZDJjMzBhNzRkNjViMDljNmZlNWZiOTA0Y2Mw"}, + "to_address": {"id": "adr_7ae1fcad491c11efb015ac1f6bc539aa", "object": "Address", + "created_at": "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:35+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + "", "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "usps_zone": + 4, "return_address": {"id": "adr_7ae4b187491c11efb529ac1f6bc539ae", "object": + "Address", "created_at": "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:34+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7ae1fcad491c11efb015ac1f6bc539aa", "object": + "Address", "created_at": "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:35+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + "", "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "forms": + [], "fees": [{"object": "Fee", "type": "LabelFee", "amount": "0.00000", "charged": + true, "refunded": false}, {"object": "Fee", "type": "PostageFee", "amount": + "5.93000", "charged": true, "refunded": false}], "id": "shp_d692021679d54c0c9da828499fb1a8de", + "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '9037' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648425669fee1ff40c2a10005286cb + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb42nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.873316' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: '{"amount": "100.00"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments/shp_d692021679d54c0c9da828499fb1a8de/insure + response: + body: + string: '{"created_at": "2024-07-23T17:53:34Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + "9400100110368066361827", "updated_at": "2024-07-23T17:53:35Z", "batch_id": + null, "batch_status": null, "batch_message": null, "customs_info": {"id": + "cstinfo_cd7d8756bb1c462fb4497cc48a3e9a26", "object": "CustomsInfo", "created_at": + "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", "contents_explanation": + "", "contents_type": "merchandise", "customs_certify": true, "customs_signer": + "Steve Brule", "eel_pfc": "NOEEI 30.37(a)", "non_delivery_option": "return", + "restriction_comments": null, "restriction_type": "none", "mode": "test", + "declaration": null, "customs_items": [{"id": "cstitem_629ef3e844fd4e8f8b63a19a0e7d413f", + "object": "CustomsItem", "created_at": "2024-07-23T17:53:34Z", "updated_at": + "2024-07-23T17:53:34Z", "description": "Sweet shirts", "hs_tariff_number": + "654321", "origin_country": "US", "quantity": 2, "value": "23.25", "weight": + 11.0, "code": null, "mode": "test", "manufacturer": null, "currency": null, + "eccn": null, "printed_commodity_identifier": null}]}, "from_address": {"id": + "adr_7ae4b187491c11efb529ac1f6bc539ae", "object": "Address", "created_at": + "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:34+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": "100.00", "order_id": null, "parcel": {"id": "prcl_cc4cec1b603649ba8dab40990c48b080", + "object": "Parcel", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": {"object": "PostageLabel", "id": "pl_d5acf6e211c3407a88885e813c0b0977", + "created_at": "2024-07-23T17:53:35Z", "updated_at": "2024-07-23T17:53:35Z", + "date_advance": 0, "integrated_form": "none", "label_date": "2024-07-23T17:53:35Z", + "label_resolution": 300, "label_size": "4x6", "label_type": "default", "label_file_type": + "image/png", "label_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20240723/e887e526fb4a5c4354a3d78a0d7f54e942.png", + "label_pdf_url": null, "label_zpl_url": null, "label_epl2_url": null, "label_file": + null}, "rates": [{"id": "rate_323b536e3901476c844419020d496965", "object": + "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_2572bc64788d47aa8389a4e5d8a0e1b6", + "object": "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_ec61cdb04bbf404e9724c18745a1493c", + "object": "Rate", "created_at": "2024-07-23T17:53:34Z", "updated_at": "2024-07-23T17:53:34Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": {"id": "rate_ec61cdb04bbf404e9724c18745a1493c", "object": + "Rate", "created_at": "2024-07-23T17:53:35Z", "updated_at": "2024-07-23T17:53:35Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, "tracker": {"id": "trk_40df1d2c30a74d65b09c6fe5fb904cc0", + "object": "Tracker", "mode": "test", "tracking_code": "9400100110368066361827", + "status": "pre_transit", "status_detail": "status_update", "created_at": "2024-07-23T17:53:35Z", + "updated_at": "2024-07-23T17:53:35Z", "signed_by": null, "weight": null, "est_delivery_date": + "2024-07-23T17:53:35Z", "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", + "carrier": "USPS", "tracking_details": [{"object": "TrackingDetail", "message": + "Pre-Shipment Info Sent to USPS", "description": "", "status": "pre_transit", + "status_detail": "status_update", "datetime": "2024-06-23T17:53:35Z", "source": + "USPS", "carrier_code": "", "tracking_location": {"object": "TrackingLocation", + "city": null, "state": null, "country": null, "zip": null}}, {"object": "TrackingDetail", + "message": "Shipping Label Created", "description": "", "status": "pre_transit", + "status_detail": "status_update", "datetime": "2024-06-24T06:30:35Z", "source": + "USPS", "carrier_code": "", "tracking_location": {"object": "TrackingLocation", + "city": "HOUSTON", "state": "TX", "country": null, "zip": "77063"}}], "fees": + [], "carrier_detail": {"object": "CarrierDetail", "service": "First-Class + Package Service", "container_type": null, "est_delivery_date_local": null, + "est_delivery_time_local": null, "origin_location": "HOUSTON TX, 77001", "origin_tracking_location": + {"object": "TrackingLocation", "city": "HOUSTON", "state": "TX", "country": + null, "zip": "77063"}, "destination_location": "CHARLESTON SC, 29401", "destination_tracking_location": + null, "guaranteed_delivery_date": null, "alternate_identifier": null, "initial_delivery_attempt": + null}, "public_url": "https://track.easypost.com/djE6dHJrXzQwZGYxZDJjMzBhNzRkNjViMDljNmZlNWZiOTA0Y2Mw"}, + "to_address": {"id": "adr_7ae1fcad491c11efb015ac1f6bc539aa", "object": "Address", + "created_at": "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:35+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + null, "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "usps_zone": + 4, "return_address": {"id": "adr_7ae4b187491c11efb529ac1f6bc539ae", "object": + "Address", "created_at": "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:34+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7ae1fcad491c11efb015ac1f6bc539aa", "object": + "Address", "created_at": "2024-07-23T17:53:34+00:00", "updated_at": "2024-07-23T17:53:35+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + null, "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "forms": + [], "fees": [{"object": "Fee", "type": "LabelFee", "amount": "0.00000", "charged": + true, "refunded": false}, {"object": "Fee", "type": "PostageFee", "amount": + "5.93000", "charged": true, "refunded": false}, {"object": "Fee", "type": + "InsuranceFee", "amount": "1.00000", "charged": true, "refunded": false}], + "id": "shp_d692021679d54c0c9da828499fb1a8de", "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '10261' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648425669fee20f40c2a100052881a + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb53nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.259690' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: '{"type": "damage", "email_evidence_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "invoice_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "supporting_documentation_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "description": "Test description", "contact_email": "test@example.com", "tracking_code": + "9400100110368066361827", "amount": "100.00"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '618' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/claims + response: + body: + string: '{"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/836a3784a67e429ca0d30f10f64cb0bc.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/a1316f8afc5843d7b2d1370dfb7e73d3.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/4d3502f6a6e64972913e43fc4191b4cd.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:36", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-23T17:53:36"}], + "id": "clm_097eb623597146bab94e9ef701364d4f", "insurance_amount": "100.00", + "insurance_id": "ins_6aa59cf8618843c09b4707e1f3f74486", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-23T17:53:36", "tracking_code": "9400100110368066361827", "type": + "damage", "updated_at": "2024-07-23T17:53:36"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '1111' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 47648425669fee20f40c2a1000528877 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb35nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb4nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.832179' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 201 + message: Created +version: 1 diff --git a/tests/cassettes/test_claim_get_next_page.yaml b/tests/cassettes/test_claim_get_next_page.yaml new file mode 100644 index 00000000..e34f2dc0 --- /dev/null +++ b/tests/cassettes/test_claim_get_next_page.yaml @@ -0,0 +1,253 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + authorization: + - + user-agent: + - + method: GET + uri: https://api.easypost.com/v2/claims?page_size=5 + response: + body: + string: '{"claims": [{"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/7b9b0171ae7b4e258f765822e7cddb71.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/2cd9fdd33a7d40fc84ac8f87c3da1f86.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/d3aebbc42e884769ad810c92c26ad8ad.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:40", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-23T17:53:40"}], + "id": "clm_097e86d630e44e83b736c48c1271fed3", "insurance_amount": "100.00", + "insurance_id": "ins_33a9255ab9f443c18a1c1876bc6e25a4", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-23T17:53:40", "tracking_code": "9400100110368066361841", "type": + "damage", "updated_at": "2024-07-23T17:53:40"}, {"approved_amount": null, + "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/836a3784a67e429ca0d30f10f64cb0bc.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/a1316f8afc5843d7b2d1370dfb7e73d3.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/4d3502f6a6e64972913e43fc4191b4cd.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:36", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-23T17:53:36"}], + "id": "clm_097eb623597146bab94e9ef701364d4f", "insurance_amount": "100.00", + "insurance_id": "ins_6aa59cf8618843c09b4707e1f3f74486", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_d692021679d54c0c9da828499fb1a8de", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-23T17:53:36", "tracking_code": "9400100110368066361827", "type": + "damage", "updated_at": "2024-07-23T17:53:36"}, {"approved_amount": null, + "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/7280de6a4ce249e6af34cfd8fc2c8613.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/9faca9b590ed4616aaa385e717969828.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/5c641ae1e5a54a53ab6ded433ebfabdc.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:10:33", "description": "Test description", "history": [{"status": + "cancelled", "status_detail": "Claim cancellation was requested.", "timestamp": + "2024-07-23T17:12:03"}, {"status": "submitted", "status_detail": "Claim was + created.", "timestamp": "2024-07-23T17:10:33"}], "id": "clm_097e39b748d24c32a0bd61840fc0763f", + "insurance_amount": "249.99", "insurance_id": "ins_d15880e5772c4373aec497744fa4da54", + "mode": "test", "object": "Claim", "payment_method": "easypost_wallet", "recipient_name": + null, "requested_amount": "100.00", "salvage_value": null, "shipment_id": + "shp_09a808dae97442f3aa7fbd994a3533d4", "status": "cancelled", "status_detail": + "Claim cancellation was requested.", "status_timestamp": "2024-07-23T17:12:03", + "tracking_code": "9470100110368066351889", "type": "damage", "updated_at": + "2024-07-23T17:12:03"}, {"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/1d0c4ff3d71c4f5d8ec5c21bcfeaf419.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/8f78018b1c6941cdafd1ca9d36579e40.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/973d2a48b6b04423b1d112dff79e85e3.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-22T20:47:51", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-22T20:47:51"}], + "id": "clm_097ed32c795141499bb0a5e17a4fe24f", "insurance_amount": "249.99", + "insurance_id": "ins_fa5c89fcf765494b921a96c4e4004476", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_5bcff1867a1f4a29a67db9a84a2082c5", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-22T20:47:51", "tracking_code": "9434600110368065978707", "type": + "damage", "updated_at": "2024-07-22T20:47:51"}, {"approved_amount": null, + "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/1d0c4ff3d71c4f5d8ec5c21bcfeaf419.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/8f78018b1c6941cdafd1ca9d36579e40.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/973d2a48b6b04423b1d112dff79e85e3.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-22T20:47:51", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-22T20:47:51"}], + "id": "clm_097ed32c795141499bb0a5e17a4fe24f", "insurance_amount": "249.99", + "insurance_id": "ins_fa5c89fcf765494b921a96c4e4004476", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_5bcff1867a1f4a29a67db9a84a2082c5", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-22T20:47:51", "tracking_code": "9434600110368065978707", "type": + "damage", "updated_at": "2024-07-22T20:47:51"}], "has_more": true}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '5708' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 4764841f669fee25f3f51d6000528d1b + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb39nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb4nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.053317' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + authorization: + - + user-agent: + - + method: GET + uri: https://api.easypost.com/v2/claims?before_id=clm_097ed32c795141499bb0a5e17a4fe24f&page_size=5 + response: + body: + string: '{"claims": [{"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/5b940a68e4a5493e8d5ae50c79ead964.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/2a238f773957479199496ee7633187b8.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/0281745ca44e4c88a632f9534c2c709d.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-22T18:44:23", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-22T18:44:23"}], + "id": "clm_097e05da0f9740569d4c7dde98b45814", "insurance_amount": "100.00", + "insurance_id": "ins_aabfdf1ee3f243c79e8b43d5f7f2aa0c", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": null, "status": "submitted", + "status_detail": "Claim was created.", "status_timestamp": "2024-07-22T18:44:23", + "tracking_code": "EZ1000000001", "type": "damage", "updated_at": "2024-07-22T18:44:23"}, + {"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/5b940a68e4a5493e8d5ae50c79ead964.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/2a238f773957479199496ee7633187b8.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/0281745ca44e4c88a632f9534c2c709d.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-22T18:44:23", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-22T18:44:23"}], + "id": "clm_097e05da0f9740569d4c7dde98b45814", "insurance_amount": "100.00", + "insurance_id": "ins_aabfdf1ee3f243c79e8b43d5f7f2aa0c", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": null, "status": "submitted", + "status_detail": "Claim was created.", "status_timestamp": "2024-07-22T18:44:23", + "tracking_code": "EZ1000000001", "type": "damage", "updated_at": "2024-07-22T18:44:23"}, + {"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/6a130e0b3b8843219e47f80843efcce9.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/1fa2701e863546a58eb58cf9dc5f6d49.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/b29a5ab5b35346759ed2c29416cc20f2.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-22T16:32:17", "description": "Test description", "history": [{"status": + "cancelled", "status_detail": "Claim cancellation was requested.", "timestamp": + "2024-07-22T16:32:19"}, {"status": "submitted", "status_detail": "Claim was + created.", "timestamp": "2024-07-22T16:32:17"}], "id": "clm_097e808661fb4cc4b4ac46398a8ad518", + "insurance_amount": "100.00", "insurance_id": "ins_1a8fe50291ec4863984ca525ffe4a91c", + "mode": "test", "object": "Claim", "payment_method": "easypost_wallet", "recipient_name": + null, "requested_amount": "100.00", "salvage_value": null, "shipment_id": + "shp_d97b685262564a868a1590d9e2ffb135", "status": "cancelled", "status_detail": + "Claim cancellation was requested.", "status_timestamp": "2024-07-22T16:32:19", + "tracking_code": "9400100110368065903004", "type": "damage", "updated_at": + "2024-07-22T16:32:18"}, {"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/6a130e0b3b8843219e47f80843efcce9.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/1fa2701e863546a58eb58cf9dc5f6d49.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240722/b29a5ab5b35346759ed2c29416cc20f2.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-22T16:32:17", "description": "Test description", "history": [{"status": + "cancelled", "status_detail": "Claim cancellation was requested.", "timestamp": + "2024-07-22T16:32:19"}, {"status": "submitted", "status_detail": "Claim was + created.", "timestamp": "2024-07-22T16:32:17"}], "id": "clm_097e808661fb4cc4b4ac46398a8ad518", + "insurance_amount": "100.00", "insurance_id": "ins_1a8fe50291ec4863984ca525ffe4a91c", + "mode": "test", "object": "Claim", "payment_method": "easypost_wallet", "recipient_name": + null, "requested_amount": "100.00", "salvage_value": null, "shipment_id": + "shp_d97b685262564a868a1590d9e2ffb135", "status": "cancelled", "status_detail": + "Claim cancellation was requested.", "status_timestamp": "2024-07-22T16:32:19", + "tracking_code": "9400100110368065903004", "type": "damage", "updated_at": + "2024-07-22T16:32:18"}, {"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240719/eb92a18cf4af448a8579205cb66d6f0e.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240719/7a478fb2bba54c2ebedf646f407c727e.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240719/d73c07b94055482e8ecd28e639c27f16.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-19T16:41:18", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-19T16:41:18"}], + "id": "clm_097d4ac66cf34e2796582f93e38d4391", "insurance_amount": "202.00", + "insurance_id": "ins_71819f699e1945d7b8c4391ec2369105", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_047b530addde44df8e783d49daa640dc", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-19T16:41:18", "tracking_code": "9405500110368064043766", "type": + "damage", "updated_at": "2024-07-19T16:41:18"}], "has_more": true}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '5744' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 4764841f669fee25f3f51d6000528d34 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb41nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb1nuq fa152d4755 + x-runtime: + - '0.057857' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_claim_retrieve.yaml b/tests/cassettes/test_claim_retrieve.yaml new file mode 100644 index 00000000..6899c5a7 --- /dev/null +++ b/tests/cassettes/test_claim_retrieve.yaml @@ -0,0 +1,699 @@ +interactions: +- request: + body: '{"shipment": {"from_address": {"name": "Jack Sparrow", "street1": "388 + Townsend St", "street2": "Apt 20", "city": "San Francisco", "state": "CA", "zip": + "94107", "country": "US", "email": "test@example.com", "phone": "5555555555"}, + "to_address": {"name": "Elizabeth Swan", "street1": "179 N Harbor Dr", "city": + "Redondo Beach", "state": "CA", "zip": "90277", "country": "US", "email": "test@example.com", + "phone": "5555555555"}, "parcel": {"length": 10, "width": 8, "height": 4, "weight": + 15.4}, "customs_info": {"eel_pfc": "NOEEI 30.37(a)", "customs_certify": true, + "customs_signer": "Steve Brule", "contents_type": "merchandise", "contents_explanation": + "", "restriction_type": "none", "non_delivery_option": "return", "customs_items": + [{"description": "Sweet shirts", "quantity": 2, "weight": 11, "value": 23.25, + "hs_tariff_number": "654321", "origin_country": "US"}]}, "options": {"label_format": + "PNG", "invoice_number": "123"}, "reference": "123"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '954' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments + response: + body: + string: '{"created_at": "2024-07-23T17:53:37Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + null, "updated_at": "2024-07-23T17:53:38Z", "batch_id": null, "batch_status": + null, "batch_message": null, "customs_info": {"id": "cstinfo_cb84e72ba6024be28ce53aaa6ebf4b90", + "object": "CustomsInfo", "created_at": "2024-07-23T17:53:37Z", "updated_at": + "2024-07-23T17:53:37Z", "contents_explanation": "", "contents_type": "merchandise", + "customs_certify": true, "customs_signer": "Steve Brule", "eel_pfc": "NOEEI + 30.37(a)", "non_delivery_option": "return", "restriction_comments": null, + "restriction_type": "none", "mode": "test", "declaration": null, "customs_items": + [{"id": "cstitem_7aac30723e7140e59ca169984646fd6e", "object": "CustomsItem", + "created_at": "2024-07-23T17:53:37Z", "updated_at": "2024-07-23T17:53:37Z", + "description": "Sweet shirts", "hs_tariff_number": "654321", "origin_country": + "US", "quantity": 2, "value": "23.25", "weight": 11.0, "code": null, "mode": + "test", "manufacturer": null, "currency": null, "eccn": null, "printed_commodity_identifier": + null}]}, "from_address": {"id": "adr_7d0d0fd8491c11efa2a9ac1f6bc53342", "object": + "Address", "created_at": "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:37+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": null, "order_id": null, "parcel": {"id": "prcl_b3606916731c48cbb7a1601d5c2452bf", + "object": "Parcel", "created_at": "2024-07-23T17:53:37Z", "updated_at": "2024-07-23T17:53:37Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": null, "rates": [{"id": "rate_49ba5166623649699e55e33c464e058f", + "object": "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_037cb76299c84c54904f046ff477d8de", + "object": "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_058244a3b26240f19927dbe382843161", + "object": "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": null, "tracker": null, "to_address": {"id": "adr_7d0ab012491c11ef98423cecef1b359e", + "object": "Address", "created_at": "2024-07-23T17:53:37+00:00", "updated_at": + "2024-07-23T17:53:37+00:00", "name": "Elizabeth Swan", "company": null, "street1": + "179 N Harbor Dr", "street2": null, "city": "Redondo Beach", "state": "CA", + "zip": "90277", "country": "US", "phone": "", "email": "", + "mode": "test", "carrier_facility": null, "residential": null, "federal_tax_id": + null, "state_tax_id": null, "verifications": {}}, "usps_zone": 4, "return_address": + {"id": "adr_7d0d0fd8491c11efa2a9ac1f6bc53342", "object": "Address", "created_at": + "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:37+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7d0ab012491c11ef98423cecef1b359e", "object": + "Address", "created_at": "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:37+00:00", + "name": "Elizabeth Swan", "company": null, "street1": "179 N Harbor Dr", "street2": + null, "city": "Redondo Beach", "state": "CA", "zip": "90277", "country": "US", + "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "forms": [], "fees": [], "id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", + "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '6912' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + location: + - /api/v2/shipments/shp_8ae4d3d1cf78409fbabd93c5b13c5f98 + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 6558653e669fee21f42f358e00532b0d + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb36nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb2nuq fa152d4755 + x-runtime: + - '0.844359' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 201 + message: Created +- request: + body: '{"rate": {"id": "rate_058244a3b26240f19927dbe382843161"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '57' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments/shp_8ae4d3d1cf78409fbabd93c5b13c5f98/buy + response: + body: + string: '{"created_at": "2024-07-23T17:53:37Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + "9400100110368066361841", "updated_at": "2024-07-23T17:53:39Z", "batch_id": + null, "batch_status": null, "batch_message": null, "customs_info": {"id": + "cstinfo_cb84e72ba6024be28ce53aaa6ebf4b90", "object": "CustomsInfo", "created_at": + "2024-07-23T17:53:37Z", "updated_at": "2024-07-23T17:53:37Z", "contents_explanation": + "", "contents_type": "merchandise", "customs_certify": true, "customs_signer": + "Steve Brule", "eel_pfc": "NOEEI 30.37(a)", "non_delivery_option": "return", + "restriction_comments": null, "restriction_type": "none", "mode": "test", + "declaration": null, "customs_items": [{"id": "cstitem_7aac30723e7140e59ca169984646fd6e", + "object": "CustomsItem", "created_at": "2024-07-23T17:53:37Z", "updated_at": + "2024-07-23T17:53:37Z", "description": "Sweet shirts", "hs_tariff_number": + "654321", "origin_country": "US", "quantity": 2, "value": "23.25", "weight": + 11.0, "code": null, "mode": "test", "manufacturer": null, "currency": null, + "eccn": null, "printed_commodity_identifier": null}]}, "from_address": {"id": + "adr_7d0d0fd8491c11efa2a9ac1f6bc53342", "object": "Address", "created_at": + "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:37+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": null, "order_id": null, "parcel": {"id": "prcl_b3606916731c48cbb7a1601d5c2452bf", + "object": "Parcel", "created_at": "2024-07-23T17:53:37Z", "updated_at": "2024-07-23T17:53:37Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": {"object": "PostageLabel", "id": "pl_1f1920b4945f4bd0a4bd4238b33b7a28", + "created_at": "2024-07-23T17:53:39Z", "updated_at": "2024-07-23T17:53:39Z", + "date_advance": 0, "integrated_form": "none", "label_date": "2024-07-23T17:53:39Z", + "label_resolution": 300, "label_size": "4x6", "label_type": "default", "label_file_type": + "image/png", "label_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20240723/e891a90c2cd34d4f99b06c274eb20fa007.png", + "label_pdf_url": null, "label_zpl_url": null, "label_epl2_url": null, "label_file": + null}, "rates": [{"id": "rate_49ba5166623649699e55e33c464e058f", "object": + "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_037cb76299c84c54904f046ff477d8de", + "object": "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_058244a3b26240f19927dbe382843161", + "object": "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": {"id": "rate_058244a3b26240f19927dbe382843161", "object": + "Rate", "created_at": "2024-07-23T17:53:39Z", "updated_at": "2024-07-23T17:53:39Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, "tracker": {"id": "trk_50a3f6c393cf407cb7e82a16e753f932", + "object": "Tracker", "mode": "test", "tracking_code": "9400100110368066361841", + "status": "unknown", "status_detail": "unknown", "created_at": "2024-07-23T17:53:39Z", + "updated_at": "2024-07-23T17:53:39Z", "signed_by": null, "weight": null, "est_delivery_date": + null, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier": "USPS", + "tracking_details": [], "fees": [], "carrier_detail": null, "public_url": + "https://track.easypost.com/djE6dHJrXzUwYTNmNmMzOTNjZjQwN2NiN2U4MmExNmU3NTNmOTMy"}, + "to_address": {"id": "adr_7d0ab012491c11ef98423cecef1b359e", "object": "Address", + "created_at": "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:38+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + "", "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "usps_zone": + 4, "return_address": {"id": "adr_7d0d0fd8491c11efa2a9ac1f6bc53342", "object": + "Address", "created_at": "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:37+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7d0ab012491c11ef98423cecef1b359e", "object": + "Address", "created_at": "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:38+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + "", "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "forms": + [], "fees": [{"object": "Fee", "type": "LabelFee", "amount": "0.00000", "charged": + true, "refunded": false}, {"object": "Fee", "type": "PostageFee", "amount": + "5.93000", "charged": true, "refunded": false}], "id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", + "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '9037' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 6558653e669fee22f42f358e00532c25 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb41nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb2nuq fa152d4755 + x-runtime: + - '1.035889' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: '{"amount": "100.00"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/shipments/shp_8ae4d3d1cf78409fbabd93c5b13c5f98/insure + response: + body: + string: '{"created_at": "2024-07-23T17:53:37Z", "is_return": false, "messages": + [{"carrier": "DhlEcs", "carrier_account_id": "ca_99007e1aeb66421faf82676f1199481e", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_711d8c4f9be54801b984e5dc9f2b5a7c", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_b1a0a1bc45844159812e0224d53948ea", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c7b4cfaf671b4984b84023d77561394a", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_a5e4cb81d1b4481d812f4511ba8dfbb1", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_c3cbbd21bc97400bbbaed6d030909476", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "DhlEcs", "carrier_account_id": "ca_0d64fd488c1444cf9bc16f858703e28f", + "type": "rate_error", "message": "shipment.customs_info.customs_items.0.code: + field required"}, {"carrier": "UPS", "carrier_account_id": "ca_4f4f19e3b533485296d62721584e096d", + "type": "rate_error", "message": "Invalid Access License number"}, {"carrier": + "UPS", "carrier_account_id": "ca_bee3d0b00e4844f0bafe77518fecef83", "type": + "rate_error", "message": "Invalid Access License number"}, {"carrier": "UPS", + "carrier_account_id": "ca_2b156a7d1fdb444c96fd53ecc409a6fa", "type": "rate_error", + "message": "Invalid Access License number"}, {"carrier": "UPS", "carrier_account_id": + "ca_725c14e27c1544a6af0c90d4208f70d3", "type": "rate_error", "message": "Invalid + Access License number"}], "mode": "test", "options": {"label_format": "PNG", + "invoice_number": "123", "currency": "USD", "payment": {"type": "SENDER"}, + "date_advance": 0}, "reference": "123", "status": "unknown", "tracking_code": + "9400100110368066361841", "updated_at": "2024-07-23T17:53:39Z", "batch_id": + null, "batch_status": null, "batch_message": null, "customs_info": {"id": + "cstinfo_cb84e72ba6024be28ce53aaa6ebf4b90", "object": "CustomsInfo", "created_at": + "2024-07-23T17:53:37Z", "updated_at": "2024-07-23T17:53:37Z", "contents_explanation": + "", "contents_type": "merchandise", "customs_certify": true, "customs_signer": + "Steve Brule", "eel_pfc": "NOEEI 30.37(a)", "non_delivery_option": "return", + "restriction_comments": null, "restriction_type": "none", "mode": "test", + "declaration": null, "customs_items": [{"id": "cstitem_7aac30723e7140e59ca169984646fd6e", + "object": "CustomsItem", "created_at": "2024-07-23T17:53:37Z", "updated_at": + "2024-07-23T17:53:37Z", "description": "Sweet shirts", "hs_tariff_number": + "654321", "origin_country": "US", "quantity": 2, "value": "23.25", "weight": + 11.0, "code": null, "mode": "test", "manufacturer": null, "currency": null, + "eccn": null, "printed_commodity_identifier": null}]}, "from_address": {"id": + "adr_7d0d0fd8491c11efa2a9ac1f6bc53342", "object": "Address", "created_at": + "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:37+00:00", "name": + "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "insurance": "100.00", "order_id": null, "parcel": {"id": "prcl_b3606916731c48cbb7a1601d5c2452bf", + "object": "Parcel", "created_at": "2024-07-23T17:53:37Z", "updated_at": "2024-07-23T17:53:37Z", + "length": 10.0, "width": 8.0, "height": 4.0, "predefined_package": null, "weight": + 15.4, "mode": "test"}, "postage_label": {"object": "PostageLabel", "id": "pl_1f1920b4945f4bd0a4bd4238b33b7a28", + "created_at": "2024-07-23T17:53:39Z", "updated_at": "2024-07-23T17:53:39Z", + "date_advance": 0, "integrated_form": "none", "label_date": "2024-07-23T17:53:39Z", + "label_resolution": 300, "label_size": "4x6", "label_type": "default", "label_file_type": + "image/png", "label_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20240723/e891a90c2cd34d4f99b06c274eb20fa007.png", + "label_pdf_url": null, "label_zpl_url": null, "label_epl2_url": null, "label_file": + null}, "rates": [{"id": "rate_49ba5166623649699e55e33c464e058f", "object": + "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "Express", "carrier": "USPS", "rate": "33.10", + "currency": "USD", "retail_rate": "37.90", "retail_currency": "USD", "list_rate": + "33.10", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_037cb76299c84c54904f046ff477d8de", + "object": "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "Priority", "carrier": "USPS", "rate": "6.90", + "currency": "USD", "retail_rate": "9.80", "retail_currency": "USD", "list_rate": + "8.25", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 2, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 2, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, {"id": "rate_058244a3b26240f19927dbe382843161", + "object": "Rate", "created_at": "2024-07-23T17:53:38Z", "updated_at": "2024-07-23T17:53:38Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}], "refund_status": null, "scan_form": + null, "selected_rate": {"id": "rate_058244a3b26240f19927dbe382843161", "object": + "Rate", "created_at": "2024-07-23T17:53:39Z", "updated_at": "2024-07-23T17:53:39Z", + "mode": "test", "service": "GroundAdvantage", "carrier": "USPS", "rate": "5.93", + "currency": "USD", "retail_rate": "8.45", "retail_currency": "USD", "list_rate": + "6.40", "list_currency": "USD", "billing_type": "easypost", "delivery_days": + 3, "delivery_date": null, "delivery_date_guaranteed": false, "est_delivery_days": + 3, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "carrier_account_id": + "ca_b25657e9896e4d63ac8151ac346ac41e"}, "tracker": {"id": "trk_50a3f6c393cf407cb7e82a16e753f932", + "object": "Tracker", "mode": "test", "tracking_code": "9400100110368066361841", + "status": "pre_transit", "status_detail": "status_update", "created_at": "2024-07-23T17:53:39Z", + "updated_at": "2024-07-23T17:53:39Z", "signed_by": null, "weight": null, "est_delivery_date": + "2024-07-23T17:53:39Z", "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", + "carrier": "USPS", "tracking_details": [{"object": "TrackingDetail", "message": + "Pre-Shipment Info Sent to USPS", "description": "", "status": "pre_transit", + "status_detail": "status_update", "datetime": "2024-06-23T17:53:39Z", "source": + "USPS", "carrier_code": "", "tracking_location": {"object": "TrackingLocation", + "city": null, "state": null, "country": null, "zip": null}}, {"object": "TrackingDetail", + "message": "Shipping Label Created", "description": "", "status": "pre_transit", + "status_detail": "status_update", "datetime": "2024-06-24T06:30:39Z", "source": + "USPS", "carrier_code": "", "tracking_location": {"object": "TrackingLocation", + "city": "HOUSTON", "state": "TX", "country": null, "zip": "77063"}}], "fees": + [], "carrier_detail": {"object": "CarrierDetail", "service": "First-Class + Package Service", "container_type": null, "est_delivery_date_local": null, + "est_delivery_time_local": null, "origin_location": "HOUSTON TX, 77001", "origin_tracking_location": + {"object": "TrackingLocation", "city": "HOUSTON", "state": "TX", "country": + null, "zip": "77063"}, "destination_location": "CHARLESTON SC, 29401", "destination_tracking_location": + null, "guaranteed_delivery_date": null, "alternate_identifier": null, "initial_delivery_attempt": + null}, "public_url": "https://track.easypost.com/djE6dHJrXzUwYTNmNmMzOTNjZjQwN2NiN2U4MmExNmU3NTNmOTMy"}, + "to_address": {"id": "adr_7d0ab012491c11ef98423cecef1b359e", "object": "Address", + "created_at": "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:38+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + null, "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "usps_zone": + 4, "return_address": {"id": "adr_7d0d0fd8491c11efa2a9ac1f6bc53342", "object": + "Address", "created_at": "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:37+00:00", + "name": "Jack Sparrow", "company": null, "street1": "388 Townsend St", "street2": + "Apt 20", "city": "San Francisco", "state": "CA", "zip": "94107", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": + {}}, "buyer_address": {"id": "adr_7d0ab012491c11ef98423cecef1b359e", "object": + "Address", "created_at": "2024-07-23T17:53:37+00:00", "updated_at": "2024-07-23T17:53:38+00:00", + "name": "ELIZABETH SWAN", "company": null, "street1": "179 N HARBOR DR", "street2": + null, "city": "REDONDO BEACH", "state": "CA", "zip": "90277-2506", "country": + "US", "phone": "", "email": "", "mode": "test", "carrier_facility": + null, "residential": false, "federal_tax_id": null, "state_tax_id": null, + "verifications": {"zip4": {"success": true, "errors": [], "details": null}, + "delivery": {"success": true, "errors": [], "details": {"latitude": 33.8436, + "longitude": -118.39177, "time_zone": "America/Los_Angeles"}}}}, "forms": + [], "fees": [{"object": "Fee", "type": "LabelFee", "amount": "0.00000", "charged": + true, "refunded": false}, {"object": "Fee", "type": "PostageFee", "amount": + "5.93000", "charged": true, "refunded": false}, {"object": "Fee", "type": + "InsuranceFee", "amount": "1.00000", "charged": true, "refunded": false}], + "id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", "object": "Shipment"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '10261' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 6558653e669fee23f42f358e00532d68 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb39nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb4nuq c0f5e722d1 + - extlb2nuq fa152d4755 + x-runtime: + - '0.274140' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: '{"type": "damage", "email_evidence_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "invoice_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "supporting_documentation_attachments": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAeUlEQVR42mP8//8/AwAI/AL+4Q7AIAAAAABJRU5ErkJggg=="], + "description": "Test description", "contact_email": "test@example.com", "tracking_code": + "9400100110368066361841", "amount": "100.00"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '618' + Content-Type: + - application/json + authorization: + - + user-agent: + - + method: POST + uri: https://api.easypost.com/v2/claims + response: + body: + string: '{"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/7b9b0171ae7b4e258f765822e7cddb71.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/2cd9fdd33a7d40fc84ac8f87c3da1f86.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/d3aebbc42e884769ad810c92c26ad8ad.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:40", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-23T17:53:40"}], + "id": "clm_097e86d630e44e83b736c48c1271fed3", "insurance_amount": "100.00", + "insurance_id": "ins_33a9255ab9f443c18a1c1876bc6e25a4", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-23T17:53:40", "tracking_code": "9400100110368066361841", "type": + "damage", "updated_at": "2024-07-23T17:53:40"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '1111' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 6558653e669fee24f42f358e00532dbd + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb41nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb4nuq c0f5e722d1 + - extlb2nuq fa152d4755 + x-runtime: + - '0.844779' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + authorization: + - + user-agent: + - + method: GET + uri: https://api.easypost.com/v2/claims/clm_097e86d630e44e83b736c48c1271fed3 + response: + body: + string: '{"approved_amount": null, "attachments": ["https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/7b9b0171ae7b4e258f765822e7cddb71.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/2cd9fdd33a7d40fc84ac8f87c3da1f86.png", + "https://easypost-files.s3-us-west-2.amazonaws.com/insurance/20240723/d3aebbc42e884769ad810c92c26ad8ad.png"], + "check_delivery_address": null, "contact_email": "test@example.com", "created_at": + "2024-07-23T17:53:40", "description": "Test description", "history": [{"status": + "submitted", "status_detail": "Claim was created.", "timestamp": "2024-07-23T17:53:40"}], + "id": "clm_097e86d630e44e83b736c48c1271fed3", "insurance_amount": "100.00", + "insurance_id": "ins_33a9255ab9f443c18a1c1876bc6e25a4", "mode": "test", "object": + "Claim", "payment_method": "easypost_wallet", "recipient_name": null, "requested_amount": + "100.00", "salvage_value": null, "shipment_id": "shp_8ae4d3d1cf78409fbabd93c5b13c5f98", + "status": "submitted", "status_detail": "Claim was created.", "status_timestamp": + "2024-07-23T17:53:40", "tracking_code": "9400100110368066361841", "type": + "damage", "updated_at": "2024-07-23T17:53:40"}' + headers: + cache-control: + - private, no-cache, no-store + content-length: + - '1111' + content-type: + - application/json; charset=utf-8 + expires: + - '0' + pragma: + - no-cache + referrer-policy: + - strict-origin-when-cross-origin + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + transfer-encoding: + - chunked + x-backend: + - easypost + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-ep-request-uuid: + - 6558653e669fee24f42f358e00532ec8 + x-frame-options: + - SAMEORIGIN + x-node: + - bigweb34nuq + x-permitted-cross-domain-policies: + - none + x-proxied: + - intlb3nuq c0f5e722d1 + - extlb2nuq fa152d4755 + x-runtime: + - '0.035588' + x-version-label: + - easypost-202407231702-040a3c7b8f-master + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/tests/conftest.py b/tests/conftest.py index a5b836d2..6b2dbad4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -306,6 +306,13 @@ def basic_insurance(): return read_fixture_data()["insurances"]["basic"] +@pytest.fixture +def basic_claim(): + """This fixture will require you to append a `tracking_code` key with the shipment's tracking code, + and a `amount` key with the insurance amount.""" + return read_fixture_data()["claims"]["basic"] + + @pytest.fixture def basic_order(): return read_fixture_data()["orders"]["basic"] diff --git a/tests/test_claim.py b/tests/test_claim.py new file mode 100644 index 00000000..1cc38f3b --- /dev/null +++ b/tests/test_claim.py @@ -0,0 +1,103 @@ +import pytest +from easypost.constant import ( + _FILTERS_KEY, + _TEST_FAILED_INTENTIONALLY_ERROR, + NO_MORE_PAGES_ERROR, +) +from easypost.models import ( + Claim, + Shipment, +) + + +def _prepare_insured_shipment(client, shipment_data, claim_amount) -> Shipment: + shipment = client.shipment.create(**shipment_data) + rate = shipment.lowest_rate() + purchased_shipment = client.shipment.buy(shipment.id, rate=rate) + _ = client.shipment.insure(shipment.id, amount=claim_amount) + + return purchased_shipment + + +@pytest.mark.vcr() +def test_claim_create(full_shipment, basic_claim, test_client): + claim_amount = "100.00" + + insured_shipment = _prepare_insured_shipment(test_client, full_shipment, claim_amount) + + claim_data = basic_claim + claim_data["tracking_code"] = insured_shipment.tracking_code + claim_data["amount"] = claim_amount + + claim = test_client.claim.create(**claim_data) + + assert isinstance(claim, Claim) + assert str.startswith(claim.id, "clm_") + assert claim.type == claim_data["type"] + + +@pytest.mark.vcr() +def test_claim_retrieve(full_shipment, basic_claim, test_client): + claim_amount = "100.00" + + insured_shipment = _prepare_insured_shipment(test_client, full_shipment, claim_amount) + + claim_data = basic_claim + claim_data["tracking_code"] = insured_shipment.tracking_code + claim_data["amount"] = claim_amount + + claim = test_client.claim.create(**claim_data) + + retrieved_claim = test_client.claim.retrieve(claim.id) + + assert isinstance(retrieved_claim, Claim) + # status changes between creation and retrieval, so we can't compare the whole object + assert claim.id == retrieved_claim.id + + +@pytest.mark.vcr() +def test_claim_all(page_size, test_client): + claims = test_client.claim.all(page_size=page_size) + + claim_array = claims["claims"] + + assert len(claim_array) <= page_size + assert claims["has_more"] is not None + assert all(isinstance(claim, Claim) for claim in claim_array) + + +@pytest.mark.vcr() +def test_claim_get_next_page(page_size, test_client): + try: + first_page = test_client.claim.all(page_size=page_size) + next_page = test_client.claim.get_next_page(claims=first_page, page_size=page_size) + + first_id_of_first_page = first_page["claims"][0].id + first_id_of_second_page = next_page["claims"][0].id + + assert first_id_of_first_page != first_id_of_second_page + + # Verify that the filters are being passed along for behind-the-scenes reference + assert first_page[_FILTERS_KEY] == next_page[_FILTERS_KEY] + except Exception as e: + if e.message != NO_MORE_PAGES_ERROR: + raise Exception(_TEST_FAILED_INTENTIONALLY_ERROR) + + +@pytest.mark.vcr() +def test_claim_cancel(test_client, full_shipment, basic_claim): + claim_amount = "100.00" + + insured_shipment = _prepare_insured_shipment(test_client, full_shipment, claim_amount) + + claim_data = basic_claim + claim_data["tracking_code"] = insured_shipment.tracking_code + claim_data["amount"] = claim_amount + + claim = test_client.claim.create(**claim_data) + + cancelled_claim = test_client.claim.cancel(id=claim.id) + + assert isinstance(cancelled_claim, Claim) + assert str.startswith(cancelled_claim.id, "clm_") + assert cancelled_claim.status == "cancelled"