From a4de4ef5599d13c5994500f643ebf801e78819db Mon Sep 17 00:00:00 2001 From: jchen293 Date: Mon, 8 Apr 2024 13:58:06 -0400 Subject: [PATCH] re-record cassettee and add another assertion --- tests/cassettes/TestInsuranceRefund.yaml | 63 ++++++++++++------------ tests/insurance_test.go | 1 + 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/cassettes/TestInsuranceRefund.yaml b/tests/cassettes/TestInsuranceRefund.yaml index 9b36fa3..493bb23 100644 --- a/tests/cassettes/TestInsuranceRefund.yaml +++ b/tests/cassettes/TestInsuranceRefund.yaml @@ -18,18 +18,18 @@ interactions: url: https://api.easypost.com/v2/insurances method: POST response: - body: '{"amount":"100.00000","created_at":"2024-04-04T16:43:58Z","fee":{"amount":"1.00000","charged":true,"object":"Fee","refunded":false,"type":"InsuranceFee"},"from_address":{"carrier_facility":null,"city":"SAN - FRANCISCO","company":null,"country":"US","created_at":"2024-04-04T16:43:58+00:00","email":"REDACTED","federal_tax_id":null,"id":"adr_8847027bf2a211eeb73fac1f6bc53342","mode":"test","name":"JACK + body: '{"amount":"100.00000","created_at":"2024-04-08T17:57:03Z","fee":{"amount":"1.00000","charged":true,"object":"Fee","refunded":false,"type":"InsuranceFee"},"from_address":{"carrier_facility":null,"city":"SAN + FRANCISCO","company":null,"country":"US","created_at":"2024-04-08T17:57:03+00:00","email":"REDACTED","federal_tax_id":null,"id":"adr_68251b87f5d111ee9712ac1f6bc53342","mode":"test","name":"JACK SPARROW","object":"Address","phone":"REDACTED","residential":true,"state":"CA","state_tax_id":null,"street1":"388 - TOWNSEND ST APT 20","street2":"","updated_at":"2024-04-04T16:43:58+00:00","verifications":{"delivery":{"details":{"latitude":37.77551,"longitude":-122.39697,"time_zone":"America/Los_Angeles"},"errors":[],"success":true},"zip4":{"details":null,"errors":[],"success":true}},"zip":"94107-1670"},"id":"ins_134ab85c12134a0a9b45f3bc7ba9e85c","messages":[],"mode":"test","object":"Insurance","provider":"easypost","provider_id":null,"reference":null,"shipment_id":null,"status":"pending","to_address":{"carrier_facility":null,"city":"REDONDO - BEACH","company":null,"country":"US","created_at":"2024-04-04T16:43:57+00:00","email":"REDACTED","federal_tax_id":null,"id":"adr_88416b59f2a211ee9ad83cecef1b359e","mode":"test","name":"ELIZABETH + TOWNSEND ST APT 20","street2":"","updated_at":"2024-04-08T17:57:03+00:00","verifications":{"delivery":{"details":{"latitude":37.77551,"longitude":-122.39697,"time_zone":"America/Los_Angeles"},"errors":[],"success":true},"zip4":{"details":null,"errors":[],"success":true}},"zip":"94107-1670"},"id":"ins_9e630a5091fe4a158ac78f92167f3fce","messages":[],"mode":"test","object":"Insurance","provider":"easypost","provider_id":null,"reference":null,"shipment_id":null,"status":"pending","to_address":{"carrier_facility":null,"city":"REDONDO + BEACH","company":null,"country":"US","created_at":"2024-04-08T17:57:03+00:00","email":"REDACTED","federal_tax_id":null,"id":"adr_681fcddbf5d111eeac823cecef1b359e","mode":"test","name":"ELIZABETH SWAN","object":"Address","phone":"REDACTED","residential":false,"state":"CA","state_tax_id":null,"street1":"179 - N HARBOR DR","street2":"","updated_at":"2024-04-04T16:43:57+00:00","verifications":{"delivery":{"details":{"latitude":33.8436,"longitude":-118.39177,"time_zone":"America/Los_Angeles"},"errors":[],"success":true},"zip4":{"details":null,"errors":[],"success":true}},"zip":"90277-2506"},"tracker":{"carrier":"USPS","carrier_detail":{"alternate_identifier":null,"container_type":null,"destination_location":"CHARLESTON + N HARBOR DR","street2":"","updated_at":"2024-04-08T17:57:03+00:00","verifications":{"delivery":{"details":{"latitude":33.8436,"longitude":-118.39177,"time_zone":"America/Los_Angeles"},"errors":[],"success":true},"zip4":{"details":null,"errors":[],"success":true}},"zip":"90277-2506"},"tracker":{"carrier":"USPS","carrier_detail":{"alternate_identifier":null,"container_type":null,"destination_location":"CHARLESTON SC, 29401","destination_tracking_location":null,"est_delivery_date_local":null,"est_delivery_time_local":null,"guaranteed_delivery_date":null,"initial_delivery_attempt":null,"object":"CarrierDetail","origin_location":"HOUSTON TX, 77001","origin_tracking_location":{"city":"HOUSTON","country":null,"object":"TrackingLocation","state":"TX","zip":"77063"},"service":"First-Class - Package Service"},"created_at":"2024-04-04T16:40:56Z","est_delivery_date":"2024-04-04T16:40:56Z","fees":[],"finalized":true,"id":"trk_9e3524de40064c12a4681ec0134c61e1","is_return":false,"mode":"test","object":"Tracker","public_url":"https://track.easypost.com/djE6dHJrXzllMzUyNGRlNDAwNjRjMTJhNDY4MWVjMDEzNGM2MWUx","shipment_id":null,"signed_by":null,"status":"pre_transit","status_detail":"status_update","tracking_code":"EZ1000000001","tracking_details":[{"carrier_code":"","datetime":"2024-03-04T16:40:56Z","description":"","message":"Pre-Shipment - Info Sent to USPS","object":"TrackingDetail","source":"USPS","status":"pre_transit","status_detail":"status_update","tracking_location":{"city":null,"country":null,"object":"TrackingLocation","state":null,"zip":null}},{"carrier_code":"","datetime":"2024-03-05T05:17:56Z","description":"","message":"Shipping - Label Created","object":"TrackingDetail","source":"USPS","status":"pre_transit","status_detail":"status_update","tracking_location":{"city":"HOUSTON","country":null,"object":"TrackingLocation","state":"TX","zip":"77063"}}],"updated_at":"2024-04-04T16:40:56Z","weight":null},"tracking_code":"EZ1000000001","updated_at":"2024-04-04T16:43:58Z"}' + Package Service"},"created_at":"2024-04-08T17:54:50Z","est_delivery_date":"2024-04-08T17:54:50Z","fees":[],"finalized":true,"id":"trk_f36a7ce2330f43348702140d85edc9db","is_return":false,"mode":"test","object":"Tracker","public_url":"https://track.easypost.com/djE6dHJrX2YzNmE3Y2UyMzMwZjQzMzQ4NzAyMTQwZDg1ZWRjOWRi","shipment_id":null,"signed_by":null,"status":"pre_transit","status_detail":"status_update","tracking_code":"EZ1000000001","tracking_details":[{"carrier_code":"","datetime":"2024-03-08T17:54:50Z","description":"","message":"Pre-Shipment + Info Sent to USPS","object":"TrackingDetail","source":"USPS","status":"pre_transit","status_detail":"status_update","tracking_location":{"city":null,"country":null,"object":"TrackingLocation","state":null,"zip":null}},{"carrier_code":"","datetime":"2024-03-09T06:31:50Z","description":"","message":"Shipping + Label Created","object":"TrackingDetail","source":"USPS","status":"pre_transit","status_detail":"status_update","tracking_location":{"city":"HOUSTON","country":null,"object":"TrackingLocation","state":"TX","zip":"77063"}}],"updated_at":"2024-04-08T17:54:50Z","weight":null},"tracking_code":"EZ1000000001","updated_at":"2024-04-08T17:57:03Z"}' headers: Cache-Control: - private, no-cache, no-store @@ -38,7 +38,7 @@ interactions: Expires: - "0" Location: - - /api/v2/insurances/ins_134ab85c12134a0a9b45f3bc7ba9e85c + - /api/v2/insurances/ins_9e630a5091fe4a158ac78f92167f3fce Pragma: - no-cache Referrer-Policy: @@ -47,27 +47,25 @@ interactions: - max-age=31536000; includeSubDomains; preload X-Backend: - easypost - X-Canary: - - direct X-Content-Type-Options: - nosniff X-Download-Options: - noopen X-Ep-Request-Uuid: - - 57918bbe660ed8cde786a2bc007157e2 + - 295ee62166142fefe799e56500924611 X-Frame-Options: - SAMEORIGIN X-Node: - - bigweb43nuq + - bigweb38nuq X-Permitted-Cross-Domain-Policies: - none X-Proxied: - - intlb3nuq 39c21b8207 - - extlb1nuq 60566a9ec2 + - intlb4nuq 39c21b8207 + - extlb2nuq 60566a9ec2 X-Runtime: - - "0.224278" + - "0.185811" X-Version-Label: - - easypost-202404041612-01938f7c7e-master + - easypost-202404081732-cdcb81b7f6-master X-Xss-Protection: - 1; mode=block status: 201 Created @@ -81,21 +79,22 @@ interactions: - REDACTED User-Agent: - REDACTED - url: https://api.easypost.com/v2/insurances/ins_134ab85c12134a0a9b45f3bc7ba9e85c/refund + url: https://api.easypost.com/v2/insurances/ins_9e630a5091fe4a158ac78f92167f3fce/refund method: POST response: - body: '{"amount":"100.00000","created_at":"2024-04-04T16:43:58Z","fee":{"amount":"1.00000","charged":true,"object":"Fee","refunded":false,"type":"InsuranceFee"},"from_address":{"carrier_facility":null,"city":"SAN - FRANCISCO","company":null,"country":"US","created_at":"2024-04-04T16:43:58+00:00","email":"REDACTED","federal_tax_id":null,"id":"adr_8847027bf2a211eeb73fac1f6bc53342","mode":"test","name":"JACK + body: '{"amount":"100.00000","created_at":"2024-04-08T17:57:03Z","fee":{"amount":"1.00000","charged":true,"object":"Fee","refunded":false,"type":"InsuranceFee"},"from_address":{"carrier_facility":null,"city":"SAN + FRANCISCO","company":null,"country":"US","created_at":"2024-04-08T17:57:03+00:00","email":"REDACTED","federal_tax_id":null,"id":"adr_68251b87f5d111ee9712ac1f6bc53342","mode":"test","name":"JACK SPARROW","object":"Address","phone":"REDACTED","residential":true,"state":"CA","state_tax_id":null,"street1":"388 - TOWNSEND ST APT 20","street2":null,"updated_at":"2024-04-04T16:43:58+00:00","verifications":{"delivery":{"details":{"latitude":37.77551,"longitude":-122.39697,"time_zone":"America/Los_Angeles"},"errors":[],"success":true},"zip4":{"details":null,"errors":[],"success":true}},"zip":"94107-1670"},"id":"ins_134ab85c12134a0a9b45f3bc7ba9e85c","messages":[],"mode":"test","object":"Insurance","provider":"easypost","provider_id":null,"reference":null,"shipment_id":null,"status":"cancelled","to_address":{"carrier_facility":null,"city":"REDONDO - BEACH","company":null,"country":"US","created_at":"2024-04-04T16:43:57+00:00","email":"REDACTED","federal_tax_id":null,"id":"adr_88416b59f2a211ee9ad83cecef1b359e","mode":"test","name":"ELIZABETH + TOWNSEND ST APT 20","street2":null,"updated_at":"2024-04-08T17:57:03+00:00","verifications":{"delivery":{"details":{"latitude":37.77551,"longitude":-122.39697,"time_zone":"America/Los_Angeles"},"errors":[],"success":true},"zip4":{"details":null,"errors":[],"success":true}},"zip":"94107-1670"},"id":"ins_9e630a5091fe4a158ac78f92167f3fce","messages":["Insurance + was cancelled by the user."],"mode":"test","object":"Insurance","provider":"easypost","provider_id":null,"reference":null,"shipment_id":null,"status":"cancelled","to_address":{"carrier_facility":null,"city":"REDONDO + BEACH","company":null,"country":"US","created_at":"2024-04-08T17:57:03+00:00","email":"REDACTED","federal_tax_id":null,"id":"adr_681fcddbf5d111eeac823cecef1b359e","mode":"test","name":"ELIZABETH SWAN","object":"Address","phone":"REDACTED","residential":false,"state":"CA","state_tax_id":null,"street1":"179 - N HARBOR DR","street2":null,"updated_at":"2024-04-04T16:43:57+00:00","verifications":{"delivery":{"details":{"latitude":33.8436,"longitude":-118.39177,"time_zone":"America/Los_Angeles"},"errors":[],"success":true},"zip4":{"details":null,"errors":[],"success":true}},"zip":"90277-2506"},"tracker":{"carrier":"USPS","carrier_detail":{"alternate_identifier":null,"container_type":null,"destination_location":"CHARLESTON + N HARBOR DR","street2":null,"updated_at":"2024-04-08T17:57:03+00:00","verifications":{"delivery":{"details":{"latitude":33.8436,"longitude":-118.39177,"time_zone":"America/Los_Angeles"},"errors":[],"success":true},"zip4":{"details":null,"errors":[],"success":true}},"zip":"90277-2506"},"tracker":{"carrier":"USPS","carrier_detail":{"alternate_identifier":null,"container_type":null,"destination_location":"CHARLESTON SC, 29401","destination_tracking_location":null,"est_delivery_date_local":null,"est_delivery_time_local":null,"guaranteed_delivery_date":null,"initial_delivery_attempt":null,"object":"CarrierDetail","origin_location":"HOUSTON TX, 77001","origin_tracking_location":{"city":"HOUSTON","country":null,"object":"TrackingLocation","state":"TX","zip":"77063"},"service":"First-Class - Package Service"},"created_at":"2024-04-04T16:43:58Z","est_delivery_date":"2024-04-04T16:43:58Z","fees":[],"finalized":true,"id":"trk_84a66fa679d1464a97ac23973925c94f","is_return":false,"mode":"test","object":"Tracker","public_url":"https://track.easypost.com/djE6dHJrXzg0YTY2ZmE2NzlkMTQ2NGE5N2FjMjM5NzM5MjVjOTRm","shipment_id":null,"signed_by":null,"status":"pre_transit","status_detail":"status_update","tracking_code":"EZ1000000001","tracking_details":[{"carrier_code":"","datetime":"2024-03-04T16:43:58Z","description":"","message":"Pre-Shipment - Info Sent to USPS","object":"TrackingDetail","source":"USPS","status":"pre_transit","status_detail":"status_update","tracking_location":{"city":null,"country":null,"object":"TrackingLocation","state":null,"zip":null}},{"carrier_code":"","datetime":"2024-03-05T05:20:58Z","description":"","message":"Shipping - Label Created","object":"TrackingDetail","source":"USPS","status":"pre_transit","status_detail":"status_update","tracking_location":{"city":"HOUSTON","country":null,"object":"TrackingLocation","state":"TX","zip":"77063"}}],"updated_at":"2024-04-04T16:43:58Z","weight":null},"tracking_code":"EZ1000000001","updated_at":"2024-04-04T16:43:58Z"}' + Package Service"},"created_at":"2024-04-08T17:57:04Z","est_delivery_date":"2024-04-08T17:57:04Z","fees":[],"finalized":true,"id":"trk_7f7d4c306afd4be2b6bd9a4404f1845f","is_return":false,"mode":"test","object":"Tracker","public_url":"https://track.easypost.com/djE6dHJrXzdmN2Q0YzMwNmFmZDRiZTJiNmJkOWE0NDA0ZjE4NDVm","shipment_id":null,"signed_by":null,"status":"pre_transit","status_detail":"status_update","tracking_code":"EZ1000000001","tracking_details":[{"carrier_code":"","datetime":"2024-03-08T17:57:04Z","description":"","message":"Pre-Shipment + Info Sent to USPS","object":"TrackingDetail","source":"USPS","status":"pre_transit","status_detail":"status_update","tracking_location":{"city":null,"country":null,"object":"TrackingLocation","state":null,"zip":null}},{"carrier_code":"","datetime":"2024-03-09T06:34:04Z","description":"","message":"Shipping + Label Created","object":"TrackingDetail","source":"USPS","status":"pre_transit","status_detail":"status_update","tracking_location":{"city":"HOUSTON","country":null,"object":"TrackingLocation","state":"TX","zip":"77063"}}],"updated_at":"2024-04-08T17:57:04Z","weight":null},"tracking_code":"EZ1000000001","updated_at":"2024-04-08T17:57:04Z"}' headers: Cache-Control: - private, no-cache, no-store @@ -116,20 +115,20 @@ interactions: X-Download-Options: - noopen X-Ep-Request-Uuid: - - 57918bbe660ed8cee786a2bc00715831 + - 295ee62166142ff0e799e5650092464e X-Frame-Options: - SAMEORIGIN X-Node: - - bigweb33nuq + - bigweb40nuq X-Permitted-Cross-Domain-Policies: - none X-Proxied: - - intlb4nuq 39c21b8207 - - extlb1nuq 60566a9ec2 + - intlb3nuq 39c21b8207 + - extlb2nuq 60566a9ec2 X-Runtime: - - "0.087370" + - "0.092726" X-Version-Label: - - easypost-202404041612-01938f7c7e-master + - easypost-202404081732-cdcb81b7f6-master X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/tests/insurance_test.go b/tests/insurance_test.go index 7d48bba..48087f5 100644 --- a/tests/insurance_test.go +++ b/tests/insurance_test.go @@ -105,4 +105,5 @@ func (c *ClientTests) TestInsuranceRefund() { assert.Equal(reflect.TypeOf(&easypost.Insurance{}), reflect.TypeOf(refundInsurance)) assert.True(strings.HasPrefix(refundInsurance.ID, "ins_")) assert.Equal("cancelled", refundInsurance.Status) + assert.Equal("Insurance was cancelled by the user.", refundInsurance.Messages[0]) }