From d9f5d37132ee361eeed833c36018a9b23446827e Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:48:11 -0600 Subject: [PATCH 1/3] TSM-90: cut over to source-generated types --- .eslintignore | 1 + .prettierignore | 1 + package.json | 2 +- src/index.ts | 3 + test/services/claim.test.js | 2 +- tsconfig.json | 12 +- types/Address/Address.d.ts | 194 --------- types/Address/AddressCreateParameters.d.ts | 30 -- types/Address/AddressListParameters.d.ts | 6 - types/Address/Verification.d.ts | 22 -- types/Address/VerificationDetails.d.ts | 19 - types/Address/Verifications.d.ts | 15 - types/Address/index.d.ts | 5 - types/ApiKey/ApiKey.d.ts | 90 ----- types/ApiKey/index.d.ts | 1 - types/Batch/Batch.d.ts | 181 --------- types/Batch/BatchCreateParameters.d.ts | 5 - types/Batch/BatchListParameters.d.ts | 6 - types/Batch/BatchShipment.d.ts | 26 -- types/Batch/BatchState.d.ts | 9 - types/Batch/BatchStatus.d.ts | 6 - types/Batch/BatchStatuses.d.ts | 3 - types/Batch/index.d.ts | 6 - types/Billing/Billing.d.ts | 37 -- types/Billing/index.d.ts | 1 - types/Brand/Brand.d.ts | 75 ---- types/Brand/index.d.ts | 1 - .../CarrierAccount/CarrierAccount.d.ts | 141 ------- .../CarrierAccountCreateParameters.d.ts | 7 - .../CarrierAccount/CarrierAccountField.d.ts | 24 -- .../CarrierAccount/CarrierAccountFields.d.ts | 26 -- types/Carrier/CarrierAccount/index.d.ts | 4 - .../CarrierMetadata/CarrierMetadata.d.ts | 63 --- types/Carrier/CarrierMetadata/index.d.ts | 1 - types/Carrier/CarrierType/CarrierType.d.ts | 47 --- .../CarrierType/CarrierTypeCredentials.d.ts | 19 - .../CarrierType/CarrierTypeFields.d.ts | 27 -- types/Carrier/CarrierType/index.d.ts | 3 - types/Carrier/index.d.ts | 3 - types/Claim/Claim.d.ts | 158 -------- types/Claim/ClaimCreateParameters.d.ts | 43 -- types/Claim/ClaimHistory.d.ts | 10 - types/Claim/ClaimPaymentMethod.d.ts | 1 - types/Claim/ClaimType.d.ts | 1 - types/Claim/index.d.ts | 4 - .../CustomerPortalAccountLink.d.ts | 40 -- ...omerPortalAccountLinkCreateParameters.d.ts | 21 - types/CustomerPortal/index.d.ts | 2 - types/Customs/CustomsInfo/CustomsInfo.d.ts | 109 ------ .../CustomsInfoCreateParameters.d.ts | 7 - types/Customs/CustomsInfo/index.d.ts | 1 - types/Customs/CustomsItem/CustomsItem.d.ts | 96 ----- .../CustomsItemCreateParameters.d.ts | 7 - types/Customs/CustomsItem/index.d.ts | 1 - types/Customs/index.d.ts | 2 - types/EasyPost.d.ts | 162 -------- types/Embeddable/EmbeddablesSession.d.ts | 40 -- .../EmbeddablesSessionCreateParameters.d.ts | 7 - types/Embeddable/index.d.ts | 2 - types/EndShipper/EndShipper.d.ts | 132 ------- .../EndShipperCreateParameters.d.ts | 7 - .../EndShipper/EndShipperListParameters.d.ts | 6 - types/EndShipper/index.d.ts | 2 - types/Event/Event.d.ts | 94 ----- types/Event/EventListParameters.d.ts | 6 - types/Event/Payload/Payload.d.ts | 47 --- .../Event/Payload/PayloadListParameters.d.ts | 6 - types/Event/Payload/index.d.ts | 1 - types/Event/index.d.ts | 1 - .../FedExRegistration/FedExRegistration.d.ts | 151 ------- types/FedExRegistration/index.d.ts | 1 - types/Fee/Fee.d.ts | 45 --- types/Fee/FeeType.d.ts | 1 - types/Fee/index.d.ts | 2 - types/Insurance/Insurance.d.ts | 176 --------- .../Insurance/InsuranceCreateParameters.d.ts | 26 -- types/Insurance/InsuranceStatus.d.ts | 1 - types/Insurance/index.d.ts | 3 - types/Luma/Luma.d.ts | 49 --- types/Luma/index.d.ts | 1 - types/Order/Order.d.ts | 137 ------- types/Order/OrderCreateParameters.d.ts | 14 - types/Order/index.d.ts | 2 - types/Parcel/Parcel.d.ts | 84 ---- types/Parcel/ParcelCreateParameters.d.ts | 28 -- types/Parcel/index.d.ts | 1 - types/PaymentMethod/PaymentMethod.d.ts | 68 ---- types/PaymentMethod/index.d.ts | 1 - types/Pickup/Pickup.d.ts | 201 ---------- types/Pickup/PickupCreateParameters.d.ts | 28 -- types/Pickup/PickupListParameters.d.ts | 6 - types/Pickup/PickupRate.d.ts | 31 -- types/Pickup/index.d.ts | 3 - types/Rate/Rate.d.ts | 95 ----- types/Rate/index.d.ts | 1 - types/Referral/Referral.d.ts | 126 ------ types/Referral/ReferralCreateParameters.d.ts | 7 - types/Referral/ReferralListParameters.d.ts | 6 - types/Referral/index.d.ts | 2 - types/Refund/Refund.d.ts | 102 ----- types/Refund/RefundCreateParameters.d.ts | 14 - types/Refund/RefundListParameters.d.ts | 6 - types/Refund/index.d.ts | 2 - types/Report/Report.d.ts | 135 ------- types/Report/ReportCreateParameters.d.ts | 8 - types/Report/ReportListParameters.d.ts | 6 - types/Report/ReportObjectType.d.ts | 7 - types/Report/index.d.ts | 2 - types/ScanForm/ScanForm.d.ts | 128 ------ types/ScanForm/ScanFormCreateParameters.d.ts | 6 - types/ScanForm/ScanFormListParameters.d.ts | 6 - types/ScanForm/index.d.ts | 1 - types/Shipment/Form.d.ts | 30 -- types/Shipment/Message.d.ts | 30 -- types/Shipment/Options/LabelFormat.d.ts | 1 - types/Shipment/Options/Options.d.ts | 365 ----------------- types/Shipment/Options/PrintCustomCode.d.ts | 52 --- types/Shipment/Options/index.d.ts | 3 - types/Shipment/PostageLabel.d.ts | 18 - types/Shipment/Shipment.d.ts | 368 ------------------ types/Shipment/ShipmentCreateParameters.d.ts | 26 -- types/Shipment/ShipmentListParameters.d.ts | 18 - types/Shipment/TaxIdentifier.d.ts | 18 - types/Shipment/index.d.ts | 9 - types/SmartRate/SmartRate.d.ts | 22 -- types/SmartRate/index.d.ts | 1 - types/Tracker/CarrierDetail.d.ts | 62 --- types/Tracker/Tracker.d.ts | 202 ---------- types/Tracker/TrackerCreateParameters.d.ts | 12 - types/Tracker/TrackerListParameters.d.ts | 14 - types/Tracker/TrackerStatus.d.ts | 11 - types/Tracker/TrackerStatusDetail.d.ts | 29 -- types/Tracker/TrackingDetail.d.ts | 39 -- types/Tracker/TrackingLocation.d.ts | 26 -- types/Tracker/index.d.ts | 7 - types/User/User.d.ts | 197 ---------- types/User/UserCreateParameters.d.ts | 4 - types/User/index.d.ts | 1 - types/Utility/Utils.d.ts | 49 --- types/Utility/index.d.ts | 1 - types/Webhook/Webhook.d.ts | 101 ----- types/Webhook/WebhookCreateParameters.d.ts | 5 - types/Webhook/WebhookListParameters.d.ts | 6 - types/Webhook/index.d.ts | 2 - types/base.d.ts | 32 -- types/constants.d.ts | 21 + types/easypost.d.ts | 199 ++++++++++ .../errors/AddressVerificationFieldError.d.ts | 26 -- types/errors/Error.d.ts | 27 -- types/errors/ErrorCode.d.ts | 173 -------- types/errors/FieldError.d.ts | 16 - types/errors/api/api_error.d.ts | 24 ++ types/errors/api/bad_request_error.d.ts | 12 + types/errors/api/external_api_error.d.ts | 10 + types/errors/api/forbidden_error.d.ts | 12 + types/errors/api/gateway_timeout_error.d.ts | 12 + types/errors/api/http_error.d.ts | 11 + types/errors/api/internal_server_error.d.ts | 12 + types/errors/api/invalid_request_error.d.ts | 12 + .../errors/api/method_not_allowed_error.d.ts | 12 + types/errors/api/not_found_error.d.ts | 12 + types/errors/api/payment_error.d.ts | 12 + types/errors/api/rate_limit_error.d.ts | 12 + types/errors/api/redirect_error.d.ts | 12 + .../errors/api/service_unavailable_error.d.ts | 12 + types/errors/api/timeout_error.d.ts | 12 + types/errors/api/unauthorized_error.d.ts | 12 + types/errors/api/unknown_api_error.d.ts | 12 + types/errors/easypost_error.d.ts | 13 + types/errors/error_handler.d.ts | 16 + .../general/end_of_pagination_error.d.ts | 10 + types/errors/general/filtering_error.d.ts | 9 + .../errors/general/invalid_object_error.d.ts | 9 + .../general/invalid_parameter_error.d.ts | 9 + .../general/missing_parameter_error.d.ts | 9 + .../general/signature_verification_error.d.ts | 9 + types/errors/index.d.ts | 4 - types/index.d.ts | 39 +- types/models/address.d.ts | 23 ++ types/models/api_key.d.ts | 10 + types/models/batch.d.ts | 16 + types/models/brand.d.ts | 16 + types/models/carrier_account.d.ts | 16 + types/models/carrier_type.d.ts | 10 + types/models/claim.d.ts | 27 ++ types/models/customs_info.d.ts | 18 + types/models/customs_item.d.ts | 16 + types/models/easypost_object.d.ts | 14 + types/models/end_shipper.d.ts | 18 + types/models/event.d.ts | 14 + types/models/form.d.ts | 11 + types/models/insurance.d.ts | 20 + types/models/order.d.ts | 27 ++ types/models/parcel.d.ts | 13 + types/models/payload.d.ts | 9 + types/models/pickup.d.ts | 30 ++ types/models/pickup_rate.d.ts | 13 + types/models/postage_label.d.ts | 17 + types/models/rate.d.ts | 23 ++ types/models/refund.d.ts | 13 + types/models/report.d.ts | 15 + types/models/scan_form.d.ts | 15 + types/models/shipment.d.ts | 43 ++ types/models/tracker.d.ts | 22 ++ types/models/user.d.ts | 22 ++ types/models/webhook.d.ts | 14 + types/services/address_service.d.ts | 59 +++ types/services/api_key_service.d.ts | 53 +++ types/services/base_service.d.ts | 62 +++ types/services/batch_service.d.ts | 72 ++++ types/services/beta_rate_service.d.ts | 17 + .../beta_referral_customer_service.d.ts | 41 ++ types/services/billing_service.d.ts | 47 +++ types/services/carrier_account_service.d.ts | 65 ++++ types/services/carrier_metadata_service.d.ts | 21 + types/services/carrier_type_service.d.ts | 18 + types/services/claim_service.d.ts | 44 +++ types/services/customer_portal_service.d.ts | 17 + types/services/customs_info_service.d.ts | 26 ++ types/services/customs_item_service.d.ts | 26 ++ types/services/embeddable_service.d.ts | 17 + types/services/end_shipper_service.d.ts | 41 ++ types/services/event_service.d.ts | 48 +++ .../services/fedex_registration_service.d.ts | 81 ++++ types/services/insurance_service.d.ts | 48 +++ types/services/luma_service.d.ts | 18 + types/services/order_service.d.ts | 42 ++ types/services/parcel_service.d.ts | 26 ++ types/services/pickup_service.d.ts | 57 +++ types/services/rate_service.d.ts | 18 + types/services/referral_customer_service.d.ts | 66 ++++ types/services/refund_service.d.ts | 41 ++ types/services/report_service.d.ts | 39 ++ types/services/scan_form_service.d.ts | 45 +++ types/services/shipment_service.d.ts | 135 +++++++ types/services/smart_rate_service.d.ts | 24 ++ types/services/tracker_service.d.ts | 54 +++ types/services/user_service.d.ts | 74 ++++ types/services/webhook_service.d.ts | 49 +++ types/utils.d.ts | 39 -- types/utils/internal_util.d.ts | 8 + types/utils/util.d.ts | 53 +++ 242 files changed, 2592 insertions(+), 5927 deletions(-) create mode 100644 src/index.ts delete mode 100644 types/Address/Address.d.ts delete mode 100644 types/Address/AddressCreateParameters.d.ts delete mode 100644 types/Address/AddressListParameters.d.ts delete mode 100644 types/Address/Verification.d.ts delete mode 100644 types/Address/VerificationDetails.d.ts delete mode 100644 types/Address/Verifications.d.ts delete mode 100644 types/Address/index.d.ts delete mode 100644 types/ApiKey/ApiKey.d.ts delete mode 100644 types/ApiKey/index.d.ts delete mode 100644 types/Batch/Batch.d.ts delete mode 100644 types/Batch/BatchCreateParameters.d.ts delete mode 100644 types/Batch/BatchListParameters.d.ts delete mode 100644 types/Batch/BatchShipment.d.ts delete mode 100644 types/Batch/BatchState.d.ts delete mode 100644 types/Batch/BatchStatus.d.ts delete mode 100644 types/Batch/BatchStatuses.d.ts delete mode 100644 types/Batch/index.d.ts delete mode 100644 types/Billing/Billing.d.ts delete mode 100644 types/Billing/index.d.ts delete mode 100644 types/Brand/Brand.d.ts delete mode 100644 types/Brand/index.d.ts delete mode 100644 types/Carrier/CarrierAccount/CarrierAccount.d.ts delete mode 100644 types/Carrier/CarrierAccount/CarrierAccountCreateParameters.d.ts delete mode 100644 types/Carrier/CarrierAccount/CarrierAccountField.d.ts delete mode 100644 types/Carrier/CarrierAccount/CarrierAccountFields.d.ts delete mode 100644 types/Carrier/CarrierAccount/index.d.ts delete mode 100644 types/Carrier/CarrierMetadata/CarrierMetadata.d.ts delete mode 100644 types/Carrier/CarrierMetadata/index.d.ts delete mode 100644 types/Carrier/CarrierType/CarrierType.d.ts delete mode 100644 types/Carrier/CarrierType/CarrierTypeCredentials.d.ts delete mode 100644 types/Carrier/CarrierType/CarrierTypeFields.d.ts delete mode 100644 types/Carrier/CarrierType/index.d.ts delete mode 100644 types/Carrier/index.d.ts delete mode 100644 types/Claim/Claim.d.ts delete mode 100644 types/Claim/ClaimCreateParameters.d.ts delete mode 100644 types/Claim/ClaimHistory.d.ts delete mode 100644 types/Claim/ClaimPaymentMethod.d.ts delete mode 100644 types/Claim/ClaimType.d.ts delete mode 100644 types/Claim/index.d.ts delete mode 100644 types/CustomerPortal/CustomerPortalAccountLink.d.ts delete mode 100644 types/CustomerPortal/CustomerPortalAccountLinkCreateParameters.d.ts delete mode 100644 types/CustomerPortal/index.d.ts delete mode 100644 types/Customs/CustomsInfo/CustomsInfo.d.ts delete mode 100644 types/Customs/CustomsInfo/CustomsInfoCreateParameters.d.ts delete mode 100644 types/Customs/CustomsInfo/index.d.ts delete mode 100644 types/Customs/CustomsItem/CustomsItem.d.ts delete mode 100644 types/Customs/CustomsItem/CustomsItemCreateParameters.d.ts delete mode 100644 types/Customs/CustomsItem/index.d.ts delete mode 100644 types/Customs/index.d.ts delete mode 100644 types/EasyPost.d.ts delete mode 100644 types/Embeddable/EmbeddablesSession.d.ts delete mode 100644 types/Embeddable/EmbeddablesSessionCreateParameters.d.ts delete mode 100644 types/Embeddable/index.d.ts delete mode 100644 types/EndShipper/EndShipper.d.ts delete mode 100644 types/EndShipper/EndShipperCreateParameters.d.ts delete mode 100644 types/EndShipper/EndShipperListParameters.d.ts delete mode 100644 types/EndShipper/index.d.ts delete mode 100644 types/Event/Event.d.ts delete mode 100644 types/Event/EventListParameters.d.ts delete mode 100644 types/Event/Payload/Payload.d.ts delete mode 100644 types/Event/Payload/PayloadListParameters.d.ts delete mode 100644 types/Event/Payload/index.d.ts delete mode 100644 types/Event/index.d.ts delete mode 100644 types/FedExRegistration/FedExRegistration.d.ts delete mode 100644 types/FedExRegistration/index.d.ts delete mode 100644 types/Fee/Fee.d.ts delete mode 100644 types/Fee/FeeType.d.ts delete mode 100644 types/Fee/index.d.ts delete mode 100644 types/Insurance/Insurance.d.ts delete mode 100644 types/Insurance/InsuranceCreateParameters.d.ts delete mode 100644 types/Insurance/InsuranceStatus.d.ts delete mode 100644 types/Insurance/index.d.ts delete mode 100644 types/Luma/Luma.d.ts delete mode 100644 types/Luma/index.d.ts delete mode 100644 types/Order/Order.d.ts delete mode 100644 types/Order/OrderCreateParameters.d.ts delete mode 100644 types/Order/index.d.ts delete mode 100644 types/Parcel/Parcel.d.ts delete mode 100644 types/Parcel/ParcelCreateParameters.d.ts delete mode 100644 types/Parcel/index.d.ts delete mode 100644 types/PaymentMethod/PaymentMethod.d.ts delete mode 100644 types/PaymentMethod/index.d.ts delete mode 100644 types/Pickup/Pickup.d.ts delete mode 100644 types/Pickup/PickupCreateParameters.d.ts delete mode 100644 types/Pickup/PickupListParameters.d.ts delete mode 100644 types/Pickup/PickupRate.d.ts delete mode 100644 types/Pickup/index.d.ts delete mode 100644 types/Rate/Rate.d.ts delete mode 100644 types/Rate/index.d.ts delete mode 100644 types/Referral/Referral.d.ts delete mode 100644 types/Referral/ReferralCreateParameters.d.ts delete mode 100644 types/Referral/ReferralListParameters.d.ts delete mode 100644 types/Referral/index.d.ts delete mode 100644 types/Refund/Refund.d.ts delete mode 100644 types/Refund/RefundCreateParameters.d.ts delete mode 100644 types/Refund/RefundListParameters.d.ts delete mode 100644 types/Refund/index.d.ts delete mode 100644 types/Report/Report.d.ts delete mode 100644 types/Report/ReportCreateParameters.d.ts delete mode 100644 types/Report/ReportListParameters.d.ts delete mode 100644 types/Report/ReportObjectType.d.ts delete mode 100644 types/Report/index.d.ts delete mode 100644 types/ScanForm/ScanForm.d.ts delete mode 100644 types/ScanForm/ScanFormCreateParameters.d.ts delete mode 100644 types/ScanForm/ScanFormListParameters.d.ts delete mode 100644 types/ScanForm/index.d.ts delete mode 100644 types/Shipment/Form.d.ts delete mode 100644 types/Shipment/Message.d.ts delete mode 100644 types/Shipment/Options/LabelFormat.d.ts delete mode 100644 types/Shipment/Options/Options.d.ts delete mode 100644 types/Shipment/Options/PrintCustomCode.d.ts delete mode 100644 types/Shipment/Options/index.d.ts delete mode 100644 types/Shipment/PostageLabel.d.ts delete mode 100644 types/Shipment/Shipment.d.ts delete mode 100644 types/Shipment/ShipmentCreateParameters.d.ts delete mode 100644 types/Shipment/ShipmentListParameters.d.ts delete mode 100644 types/Shipment/TaxIdentifier.d.ts delete mode 100644 types/Shipment/index.d.ts delete mode 100644 types/SmartRate/SmartRate.d.ts delete mode 100644 types/SmartRate/index.d.ts delete mode 100644 types/Tracker/CarrierDetail.d.ts delete mode 100644 types/Tracker/Tracker.d.ts delete mode 100644 types/Tracker/TrackerCreateParameters.d.ts delete mode 100644 types/Tracker/TrackerListParameters.d.ts delete mode 100644 types/Tracker/TrackerStatus.d.ts delete mode 100644 types/Tracker/TrackerStatusDetail.d.ts delete mode 100644 types/Tracker/TrackingDetail.d.ts delete mode 100644 types/Tracker/TrackingLocation.d.ts delete mode 100644 types/Tracker/index.d.ts delete mode 100644 types/User/User.d.ts delete mode 100644 types/User/UserCreateParameters.d.ts delete mode 100644 types/User/index.d.ts delete mode 100644 types/Utility/Utils.d.ts delete mode 100644 types/Utility/index.d.ts delete mode 100644 types/Webhook/Webhook.d.ts delete mode 100644 types/Webhook/WebhookCreateParameters.d.ts delete mode 100644 types/Webhook/WebhookListParameters.d.ts delete mode 100644 types/Webhook/index.d.ts delete mode 100644 types/base.d.ts create mode 100644 types/constants.d.ts create mode 100644 types/easypost.d.ts delete mode 100644 types/errors/AddressVerificationFieldError.d.ts delete mode 100644 types/errors/Error.d.ts delete mode 100644 types/errors/ErrorCode.d.ts delete mode 100644 types/errors/FieldError.d.ts create mode 100644 types/errors/api/api_error.d.ts create mode 100644 types/errors/api/bad_request_error.d.ts create mode 100644 types/errors/api/external_api_error.d.ts create mode 100644 types/errors/api/forbidden_error.d.ts create mode 100644 types/errors/api/gateway_timeout_error.d.ts create mode 100644 types/errors/api/http_error.d.ts create mode 100644 types/errors/api/internal_server_error.d.ts create mode 100644 types/errors/api/invalid_request_error.d.ts create mode 100644 types/errors/api/method_not_allowed_error.d.ts create mode 100644 types/errors/api/not_found_error.d.ts create mode 100644 types/errors/api/payment_error.d.ts create mode 100644 types/errors/api/rate_limit_error.d.ts create mode 100644 types/errors/api/redirect_error.d.ts create mode 100644 types/errors/api/service_unavailable_error.d.ts create mode 100644 types/errors/api/timeout_error.d.ts create mode 100644 types/errors/api/unauthorized_error.d.ts create mode 100644 types/errors/api/unknown_api_error.d.ts create mode 100644 types/errors/easypost_error.d.ts create mode 100644 types/errors/error_handler.d.ts create mode 100644 types/errors/general/end_of_pagination_error.d.ts create mode 100644 types/errors/general/filtering_error.d.ts create mode 100644 types/errors/general/invalid_object_error.d.ts create mode 100644 types/errors/general/invalid_parameter_error.d.ts create mode 100644 types/errors/general/missing_parameter_error.d.ts create mode 100644 types/errors/general/signature_verification_error.d.ts delete mode 100644 types/errors/index.d.ts create mode 100644 types/models/address.d.ts create mode 100644 types/models/api_key.d.ts create mode 100644 types/models/batch.d.ts create mode 100644 types/models/brand.d.ts create mode 100644 types/models/carrier_account.d.ts create mode 100644 types/models/carrier_type.d.ts create mode 100644 types/models/claim.d.ts create mode 100644 types/models/customs_info.d.ts create mode 100644 types/models/customs_item.d.ts create mode 100644 types/models/easypost_object.d.ts create mode 100644 types/models/end_shipper.d.ts create mode 100644 types/models/event.d.ts create mode 100644 types/models/form.d.ts create mode 100644 types/models/insurance.d.ts create mode 100644 types/models/order.d.ts create mode 100644 types/models/parcel.d.ts create mode 100644 types/models/payload.d.ts create mode 100644 types/models/pickup.d.ts create mode 100644 types/models/pickup_rate.d.ts create mode 100644 types/models/postage_label.d.ts create mode 100644 types/models/rate.d.ts create mode 100644 types/models/refund.d.ts create mode 100644 types/models/report.d.ts create mode 100644 types/models/scan_form.d.ts create mode 100644 types/models/shipment.d.ts create mode 100644 types/models/tracker.d.ts create mode 100644 types/models/user.d.ts create mode 100644 types/models/webhook.d.ts create mode 100644 types/services/address_service.d.ts create mode 100644 types/services/api_key_service.d.ts create mode 100644 types/services/base_service.d.ts create mode 100644 types/services/batch_service.d.ts create mode 100644 types/services/beta_rate_service.d.ts create mode 100644 types/services/beta_referral_customer_service.d.ts create mode 100644 types/services/billing_service.d.ts create mode 100644 types/services/carrier_account_service.d.ts create mode 100644 types/services/carrier_metadata_service.d.ts create mode 100644 types/services/carrier_type_service.d.ts create mode 100644 types/services/claim_service.d.ts create mode 100644 types/services/customer_portal_service.d.ts create mode 100644 types/services/customs_info_service.d.ts create mode 100644 types/services/customs_item_service.d.ts create mode 100644 types/services/embeddable_service.d.ts create mode 100644 types/services/end_shipper_service.d.ts create mode 100644 types/services/event_service.d.ts create mode 100644 types/services/fedex_registration_service.d.ts create mode 100644 types/services/insurance_service.d.ts create mode 100644 types/services/luma_service.d.ts create mode 100644 types/services/order_service.d.ts create mode 100644 types/services/parcel_service.d.ts create mode 100644 types/services/pickup_service.d.ts create mode 100644 types/services/rate_service.d.ts create mode 100644 types/services/referral_customer_service.d.ts create mode 100644 types/services/refund_service.d.ts create mode 100644 types/services/report_service.d.ts create mode 100644 types/services/scan_form_service.d.ts create mode 100644 types/services/shipment_service.d.ts create mode 100644 types/services/smart_rate_service.d.ts create mode 100644 types/services/tracker_service.d.ts create mode 100644 types/services/user_service.d.ts create mode 100644 types/services/webhook_service.d.ts delete mode 100644 types/utils.d.ts create mode 100644 types/utils/internal_util.d.ts create mode 100644 types/utils/util.d.ts diff --git a/.eslintignore b/.eslintignore index 73270f08b..d2b87fc6a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,5 @@ dist /docs examples node_modules +types types/demo diff --git a/.prettierignore b/.prettierignore index 07356dd88..34b7584b3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -11,5 +11,6 @@ examples official/fixtures/ package-lock.json style_guides/ +types/ vendor/ venv/ diff --git a/package.json b/package.json index af1fcb82f..7ec7d4446 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "test": "cross-env NODE_ENV=test vitest run", "test:node-compatibility": "cross-env NODE_ENV=test node ./test/node_compatibility", "typescript": "npm run typescript:declarations && npm run typescript:source && npm run typescript:compat", - "typescript:declarations": "npx tsc -p tsconfig.json", + "typescript:declarations": "rm -rf ./types && npx tsc -p tsconfig.json", "typescript:source": "npx tsc -p tsconfig.build.json", "typescript:compat": "npx tsc -p tsconfig.type-tests.json", "watch": "vite build --watch" diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 000000000..5e70bb213 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,3 @@ +import EasyPostClient from './easypost'; + +export default EasyPostClient; diff --git a/test/services/claim.test.js b/test/services/claim.test.js index b3f04fb8b..3cf7a7c4d 100644 --- a/test/services/claim.test.js +++ b/test/services/claim.test.js @@ -7,7 +7,7 @@ import Claim from '../../src/models/claim'; import Fixture from '../helpers/fixture'; import * as setupPolly from '../helpers/setup_polly'; -/** @typedef {import("../../types/EasyPost").default} Client */ +/** @typedef {import("../../types/easypost").default} Client */ const CLAIM_AMOUNT = 100; diff --git a/tsconfig.json b/tsconfig.json index 1f0f4c7ed..0b5302a49 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,15 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "noEmit": true + "allowJs": true, + "checkJs": false, + "noImplicitAny": false, + "declaration": true, + "emitDeclarationOnly": true, + "rootDir": "./src", + "outDir": "./types", + "noEmit": false }, - "include": ["types"] + "include": ["src/**/*.js", "src/**/*.ts"], + "exclude": ["dist/**", "docs/**", "coverage/**", "node_modules/**"] } diff --git a/types/Address/Address.d.ts b/types/Address/Address.d.ts deleted file mode 100644 index 07c7e183f..000000000 --- a/types/Address/Address.d.ts +++ /dev/null @@ -1,194 +0,0 @@ -import { IObjectWithId } from '../base'; -import { DeepPartial } from '../utils'; -import { IAddressCreateParameters } from './AddressCreateParameters'; -import { IAddressListParameters } from './AddressListParameters'; -import { IVerifications } from './Verifications'; - -/** - * Address objects are used to represent people, places, and organizations in a number of contexts. - * For example, a Shipment requires a to_address and from_address to accurately calculate rates and generate postage. - * - * Additionally, EasyPost offers several verification tools that can be used to detect deliverability issues, correct minor errors in spelling/formatting, and determine if an Address is residential or not (which has a significant effect on Shipment rating for many carriers). - * - * @see https://docs.easypost.com/docs/addresses#address-object - */ -export declare interface IAddress extends IObjectWithId<'Address'> { - /** - * First line of the address - */ - street1?: string | null; - - /** - * Second line of the address - */ - street2?: string | null; - - /** - * City the address is located in - */ - city?: string | null; - - /** - * State or province the address is located in - */ - state?: string | null; - - /** - * ZIP or postal code the address is located in - */ - zip: string; - - /** - * ISO 3166 country code for the country the address is located in - */ - country: string; - - /** - * Whether or not this address would be considered residential - */ - residential?: boolean | null; - - /** - * The specific designation for the address (only relevant if the address is a carrier facility) - */ - carrier_facility?: string | null; - - /** - * Name of the person. Both name and company can be included - */ - name?: string | null; - - /** - * Name of the organization. Both name and company can be included - */ - company?: string | null; - - /** - * Phone number to reach the person or organization - */ - phone?: string | null; - - /** - * Email to reach the person or organization - */ - email?: string | null; - - /** - * Federal tax identifier of the person or organization - */ - federal_tax_id?: string | null; - - /** - * State tax identifier of the person or organization - */ - state_tax_id?: string | null; - - /** - * The result of any verifications requested - */ - verifications: IVerifications; -} - -declare class Address implements IAddress { - public constructor(input: DeepPartial); - - id: string; - mode: 'test' | 'production'; - object: 'Address'; - street1?: string | null; - street2?: string | null; - city?: string | null; - state?: string | null; - zip: string; - country: string; - residential?: boolean | null; - carrier_facility?: string | null; - name?: string | null; - company?: string | null; - phone?: string | null; - email?: string | null; - federal_tax_id?: string | null; - state_tax_id?: string | null; - verifications: IVerifications; - - /** - * Create an {@link Address address}. - * @see https://docs.easypost.com/docs/addresses#create-an-address - * @param {Object} params - Parameters for the address to be created. - * @returns {Address} - The created address. - */ - static create(params: Object): Promise
; - - /** - * Retrieve a list of all Addresses. - * - * The Address List is a paginated list of all {@link Address} objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The has_more attribute indicates whether additional pages can be requested. - * The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where the next page begins. - * - * @see https://docs.easypost.com/docs/addresses#retrieve-all-addresses - * - * @param {Object} params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Address addresses} and pagination information. - */ - static all(params?: IAddressListParameters): Promise<{ addresses: Address[]; has_more: boolean }>; - - /** - * Create and verify a new {@link Address} in one API call. - * - * Verify an {@link Address} - * - Verifying an {@link Address} before you ship is a great way to reduce issues with delivery. - * Creating a verified Address is as simple as including an enumerated list of the verifications you'd like EasyPost to perform in the `verify` or `verify_strict` url parameters. - * If any of the verification checks included in the `verify_strict` list fail an error will be returned from the API. - * The example below demonstrates the most common verification: "delivery", which checks that the address is deliverable and sets its residential delivery indicator. - * - * - The most effective time to perform address verification is when your customer, or the person entering the delivery address, is present. - * When designing a shopping cart it is recommended to ask the shopper for their address and verify it on the spot. - * If verification fails, ask them to double-check their input; if they confirm that their data is correct, assume they know their address more correctly than the verification process. - * - * @see https://docs.easypost.com/docs/addresses#verify-an-address - * - * @param {Object} params The parameters to create an {@link Address} with. - * @returns {Promise
} The created and verified {@link Address}. - */ - static createAndVerify(params: Object): Promise
; - - /** - * Verify an {@link Address}. - * - * @see https://docs.easypost.com/docs/addresses#verify-an-address - * - * @param addressId Unique, begins with "adr_" - * @returns {Promise
} The verified {@link Address}. - */ - static verifyAddress(addressId: string): Promise
; - - /** - * An Address can be retrieved by its id. - * - * @see https://docs.easypost.com/docs/addresses#retrieve-an-address - * - * @param addressId Unique, begins with "adr_" - * @returns {Promise
} The verified {@link Address} address. - */ - static retrieve(addressId: string): Promise
; - - /** - * Retrieve the next page of {@link Address addresses}. - * - * This automatically reuses the parameters from the previous call or the original {@link Address.all} call. - * - * @see https://docs.easypost.com/docs/addresses#retrieve-all-addresses - * - * @param {Object} addresses - The previous page of addresses (the response from the last {@link Address.getNextPage} or {@link Address.all} call). - * @param {number} [pageSize] - The number of addresses to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Address addresses} and pagination information. - */ - static getNextPage( - addresses: Object, - pageSize?: number, - ): Promise<{ addresses: Address[]; has_more: boolean }>; -} - -export type { Address }; diff --git a/types/Address/AddressCreateParameters.d.ts b/types/Address/AddressCreateParameters.d.ts deleted file mode 100644 index 6b79f0e97..000000000 --- a/types/Address/AddressCreateParameters.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ParametersToOmitOnCreate } from '../utils'; -import { IAddress } from './Address'; - -/** - * @see https://docs.easypost.com/docs/addresses#verify-an-address - */ -export declare interface IAddressCreateParameters extends Omit< - IAddress, - ParametersToOmitOnCreate | 'verifications' -> { - /** - * The verifications to perform when creating. - * verify_strict takes precedence. - * true will perform both delivery and zip code. - */ - verify?: boolean | null; - - /** - * The verifications to perform when creating. - * The failure of any of these verifications causes the whole request to fail. - * true will perform both delivery and zip code. - */ - verify_strict?: boolean | null; - - /** - * The verifications to perform when creating. - * Define either UPS or FedEx as the carrier to verify against. - */ - verify_carrier?: string | null; -} diff --git a/types/Address/AddressListParameters.d.ts b/types/Address/AddressListParameters.d.ts deleted file mode 100644 index 08cbc90ff..000000000 --- a/types/Address/AddressListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/addresses#retrieve-all-addresses - */ -export declare interface IAddressListParameters extends IAllMethodParameters {} diff --git a/types/Address/Verification.d.ts b/types/Address/Verification.d.ts deleted file mode 100644 index 2b9966345..000000000 --- a/types/Address/Verification.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { IAddressVerificationFieldError } from '../errors'; -import { IVerificationDetails } from './VerificationDetails'; - -/** - * @see https://docs.easypost.com/docs/addresses#verification-object - */ -export declare interface IVerification { - /** - * The success of the verification - */ - success: boolean; - - /** - * All errors that caused the verification to fail - */ - errors: IAddressVerificationFieldError[]; - - /** - * Extra data related to the verification - */ - details: IVerificationDetails; -} diff --git a/types/Address/VerificationDetails.d.ts b/types/Address/VerificationDetails.d.ts deleted file mode 100644 index 5e55ad6e1..000000000 --- a/types/Address/VerificationDetails.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @see https://docs.easypost.com/docs/addresses#verificationdetails-object - */ -export declare interface IVerificationDetails { - /** - * The latitude of an Address. - */ - latitude: number; - - /** - * The longitude of an Address. - */ - longitude: number; - - /** - * The time zone the address is located in, IE: America/Los_Angeles - */ - time_zone: string; -} diff --git a/types/Address/Verifications.d.ts b/types/Address/Verifications.d.ts deleted file mode 100644 index 0ddbfed2a..000000000 --- a/types/Address/Verifications.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { IVerification } from './Verification'; - -/** - * @see https://docs.easypost.com/docs/addresses#verification-object - */ -export declare interface IVerifications { - /** - * Only applicable to US addresses - checks and sets the ZIP+4 - */ - zip4: IVerification; - /** - * Checks that the address is deliverable and makes minor corrections to spelling/format. US addresses will also have their "residential" status checked and set. - */ - delivery: IVerification; -} diff --git a/types/Address/index.d.ts b/types/Address/index.d.ts deleted file mode 100644 index 645d630e4..000000000 --- a/types/Address/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './Address'; -export * from './AddressCreateParameters'; -export * from './Verification'; -export * from './VerificationDetails'; -export * from './Verifications'; diff --git a/types/ApiKey/ApiKey.d.ts b/types/ApiKey/ApiKey.d.ts deleted file mode 100644 index 67aeea2c0..000000000 --- a/types/ApiKey/ApiKey.d.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { IObjectWithId } from '../base'; - -export declare interface IApiKey extends IObjectWithId<'ApiKey'> { - /** - * The actual key value to use for authentication - */ - key: string; - - /** - * When the API key was created - */ - created_at: string; - - /** - * Whether the API key is active or not - */ - active: boolean; -} - -declare class ApiKey implements IApiKey { - id: string; - mode: 'test' | 'production'; - object: 'ApiKey'; - key: string; - created_at: string; - active: boolean; - - /** - * Retrieve API Keys for a specified User. - * Both production and test keys will be returned for a User and all of its children. - * If the request is authenticated as a Child, only the API Keys for that Child will be returned. - * - * @see https://docs.easypost.com/docs/api-keys#retrieve-an-api-key - * - * @param {string} id - The ID of the user to retrieve keys for. - * @returns {Promise} - List of associated API Keys. - */ - static retrieveApiKeysForUser(id: string): Promise; - - /** - * Retrieve all API keys associated with the current authenticated user. - * - * @see https://docs.easypost.com/docs/api-keys#retrieve-an-api-key - * - * @param {Object} [params] - Optional parameters for the request. - * @returns {Promise} - An object containing the API keys associated with the current authenticated user and its child users. - */ - static all(params?: Object): Promise; - - /** - * Create an API key for a child or referral customer user. - * - * @see https://docs.easypost.com/docs/api-keys#create-an-api-key - * - * @param {string} mode - The mode for the API key (either "production" or "test"). - * @returns {Promise} - The created API key. - */ - static create(mode: string): Promise; - - /** - * Delete an API key for a child or referral customer user. - * - * @see https://docs.easypost.com/docs/api-keys#delete-an-api-key - * - * @param {string} id - The ID of the API key to delete. - */ - static delete(id: string): void; - - /** - * Enable a child or referral customer API key. - * - * @see https://docs.easypost.com/docs/api-keys#enable-an-api-key - * - * @param {string} id - The ID of the API key to enable. - * @returns {Promise} - The enabled API key. - */ - static enable(id: string): Promise; - - /** - * Disable a child or referral customer API key. - * - * @see https://docs.easypost.com/docs/api-keys#disable-an-api-key - * - * @param {string} id - The ID of the API key to disable. - * @returns {Promise} - The disabled API key. - */ - static disable(id: string): Promise; -} - -export type { ApiKey }; diff --git a/types/ApiKey/index.d.ts b/types/ApiKey/index.d.ts deleted file mode 100644 index 3af301f48..000000000 --- a/types/ApiKey/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ApiKey'; diff --git a/types/Batch/Batch.d.ts b/types/Batch/Batch.d.ts deleted file mode 100644 index ec4e72963..000000000 --- a/types/Batch/Batch.d.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; -import { IPickup } from '../Pickup'; -import { IScanForm } from '../ScanForm'; -import { LabelFormat } from '../Shipment'; -import { IBatchCreateParameters } from './BatchCreateParameters'; -import { IBatchListParameters } from './BatchListParameters'; -import { IBatchShipment } from './BatchShipment'; -import { TBatchState } from './BatchState'; -import { TBatchStatuses } from './BatchStatuses'; - -/** - * The Batch object allows you to perform operations on multiple Shipments at once. - * This includes scheduling a Pickup, creating a ScanForm and consolidating labels. - * Operations performed on Batches are asynchronous and take advantage of our webhook infrastructure. - * - * @see https://docs.easypost.com/docs/batches#batch-object - */ -export declare interface IBatch extends IObjectWithId<'Batch'>, IDatedObject { - /** - * An optional field that may be used in place of ID in some API endpoints - */ - reference?: string | null; - - /** - * The overall state. Possible values are "creating", "creation_failed", "created", "purchasing", "purchase_failed", "purchased", "label_generating", and "label_generated" - */ - state: TBatchState; - - /** - * The number of shipments added - */ - num_shipments: number; - - /** - * An array of batch shipments - */ - shipments: IBatchShipment[]; - - /** - * A map of BatchShipment statuses to the count of BatchShipments with that status. Valid statuses are "postage_purchased", "postage_purchase_failed", "queued_for_purchase", and "creation_failed" - */ - status: TBatchStatuses; - - /** - * The label image url - */ - label_url?: string | null; - - /** - * The created ScanForm - */ - scan_form: IScanForm; - - /** - * The created Pickup - */ - pickup: IPickup; -} - -declare class Batch implements IBatch { - public constructor(input: IBatchCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'Batch'; - reference?: string | null; - state: TBatchState; - num_shipments: number; - shipments: IBatchShipment[]; - status: TBatchStatuses; - label_url?: string | null; - scan_form: IScanForm; - pickup: IPickup; - created_at: string; - updated_at: string; - - /** - * A Batch can be created with or without Shipments. - * When created with Shipments the initial state will be creating. - * Once the state changes to created a webhook Event will be sent. - * When created with no Shipments the initial state will be created and webhook will be sent. - * - * @see https://docs.easypost.com/docs/batches#create-a-batch - * - * @param {Object} params The parameters to create an {@link Batch} with. - * @returns {Promise} The {@link Batch}. - */ - static create(params: Object): Promise; - - /** - * A Batch can be retrieved by its id. - * - * @see https://docs.easypost.com/docs/batches#retrieve-batch - * - * @param batchId Unique, begins with "batch_" - * - * @returns {Promise} The {@link Batch}. - */ - static retrieve(batchId: string): Promise; - - /** - * Shipments can be added to a Batch throughout its life cycle. - * Just remember that the state change of a Batch is asynchronous and will fire a webhook Event when the state change is completed. - * - * @see https://docs.easypost.com/docs/batches#add-shipments-to-a-batch - * - * @param id Unique, begins with "batch_" - * @param shipments An array of shipments - * - * @returns {Promise} The {@link Batch}. - */ - static addShipments(id: string, shipments: IBatchCreateParameters['shipments']): Promise; - - /** - * There could be times when a Shipment needs to be removed from the Batch during its life cycle. - * Removing a Shipment does not remove it from the consolidated label or ScanForm. - * - * @see https://docs.easypost.com/docs/batches#remove-shipments-from-a-batch - * - * @param id Unique, begins with "batch_" - * @param shipments An array of shipments - * - * @returns {Promise} The {@link Batch}. - */ - static removeShipments( - id: string, - shipments: IBatchCreateParameters['shipments'], - ): Promise; - - /** - * One of the advantages of processing Shipments in batches is the ability to consolidate the PostageLabel into one file. - * This can only be done once for each batch and all Shipments must have a status of postage_purchased. - * - * Available label formats are 'pdf', 'zpl' or 'epl2' format. - * Like converting a PostageLabel format, if this process will change the format of the labels they must have been created as PNGs. - * - * @see https://docs.easypost.com/docs/batches#batch-labels - * - * @param id Unique, begins with "batch_" - * @param labelFormat The format of label - * - * @returns {Promise} The {@link Batch}. - */ - static generateLabel(id: string, labelFormat: LabelFormat): Promise; - - /** - * See [Scan Form](https://docs.easypost.com/docs/scan-form) rules and [Object Definition](https://docs.easypost.com/docs/scan-form-object). - * - * @see https://docs.easypost.com/docs/batches#manifesting-scan-form - * - * @param id Unique, begins with "batch_" - * - * @returns {Promise} The {@link Batch}. - */ - static createScanForm(id: string): Promise; - - /** - * Once you have added all of your Shipments to a Batch, issue a buy request to enqueue a background job to purchase the shipments and generate all necessary labels. - * Purchasing may take anywhere from a few seconds to an hour, depending on the size of the batch, the carrier, and Internet weather. - * - * @see https://docs.easypost.com/docs/batches#buy-a-batch - * - * @param id Unique, begins with "batch_" - * @returns {Promise} The {@link Batch}. - */ - static buy(id: string): Promise; - - /** - * The Batch List is a paginated list of all Batch objects associated with the given API Key. - * See the Pagination section of our docs for more details on retrieving all records when - * multiple pages are available. - * - * @see https://docs.easypost.com/docs/batches#retrieve-all-batches - * - * @param {Object} params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Batch batches} and pagination information. - */ - static all(params?: IBatchListParameters): Promise<{ batches: Batch[]; has_more: boolean }>; -} - -export type { Batch }; diff --git a/types/Batch/BatchCreateParameters.d.ts b/types/Batch/BatchCreateParameters.d.ts deleted file mode 100644 index 92849b98e..000000000 --- a/types/Batch/BatchCreateParameters.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Shipment } from '../Shipment'; - -export declare interface IBatchCreateParameters { - shipments?: Array; -} diff --git a/types/Batch/BatchListParameters.d.ts b/types/Batch/BatchListParameters.d.ts deleted file mode 100644 index a6e0fc7a4..000000000 --- a/types/Batch/BatchListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/batches#retrieve-all-batches - */ -export declare interface IBatchListParameters extends IAllMethodParameters {} diff --git a/types/Batch/BatchShipment.d.ts b/types/Batch/BatchShipment.d.ts deleted file mode 100644 index 9368ef1ec..000000000 --- a/types/Batch/BatchShipment.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { TBatchStatus } from './BatchStatus'; - -/** - * @see https://docs.easypost.com/docs/batches#batchshipment-object - */ -export declare interface IBatchShipment { - /** - * The id of the Shipment. Unique, begins with "shp_" - */ - id: string; - - /** - * An optional field that may be used in place of ID in some API endpoints - */ - reference?: string | null; - - /** - * The current status. Possible values are "postage_purchased", "postage_purchase_failed", "queued_for_purchase", "creation_failed", and "created" - */ - batch_status: TBatchStatus; - - /** - * A human readable message for any errors that occurred during the Batch's life cycle - */ - batch_message: string; -} diff --git a/types/Batch/BatchState.d.ts b/types/Batch/BatchState.d.ts deleted file mode 100644 index 7de25d436..000000000 --- a/types/Batch/BatchState.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export declare type TBatchState = - | 'creating' - | 'creation_failed' - | 'created' - | 'purchasing' - | 'purchase_failed' - | 'purchased' - | 'label_generating' - | 'label_generated'; diff --git a/types/Batch/BatchStatus.d.ts b/types/Batch/BatchStatus.d.ts deleted file mode 100644 index ecd5eb553..000000000 --- a/types/Batch/BatchStatus.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare type TBatchStatus = - | 'postage_purchased' - | 'postage_purchase_failed' - | 'queued_for_purchase' - | 'creation_failed' - | 'created'; diff --git a/types/Batch/BatchStatuses.d.ts b/types/Batch/BatchStatuses.d.ts deleted file mode 100644 index 24e6470ca..000000000 --- a/types/Batch/BatchStatuses.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { TBatchStatus } from './BatchStatus'; - -export declare type TBatchStatuses = { [key in TBatchStatus]: number }; diff --git a/types/Batch/index.d.ts b/types/Batch/index.d.ts deleted file mode 100644 index 00cf085aa..000000000 --- a/types/Batch/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './Batch'; -export * from './BatchState'; -export * from './BatchStatus'; -export * from './BatchStatuses'; -export * from './BatchShipment'; -export * from './BatchCreateParameters'; diff --git a/types/Billing/Billing.d.ts b/types/Billing/Billing.d.ts deleted file mode 100644 index 02c214912..000000000 --- a/types/Billing/Billing.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * The Billing class allow you to fund wallet by using primary or secondary payment method, - * delete a existing payment method, and retrieve all payment methods associated to the user. - * - * @see https://docs.easypost.com/docs/users/billing - */ -declare class Billing { - /** - * Fund your EasyPost wallet by charging your primary or secondary payment method on file. - * - * @see https://docs.easypost.com/docs/users/billing#add-funds-to-your-wallet-one-time-charge - * @requires production API Key. - * - * @param amount Amount in cents to be deposited into the user's wallet. Amount must be greater than or equal to the user's current balance. - * @param priority The payment method from your account, either primary or secondary. - */ - static fundWallet(amount: string, priority?: string): void; - - /** - * Delete a payment method from your account. - * @see https://docs.easypost.com/docs/users/billing#delete-a-payment-method - * @requires production API Key. - * - * @param priority The payment method from your account, either primary or secondary. - */ - static deletePaymentMethod(priority: string): void; - - /** - * Retrieve all payment methods. - * - * @see https://docs.easypost.com/docs/users/billing#retrieve-payment-methods - * @requires production API Key. - */ - static retrievePaymentMethods(): object; -} - -export type { Billing }; diff --git a/types/Billing/index.d.ts b/types/Billing/index.d.ts deleted file mode 100644 index 6da3db555..000000000 --- a/types/Billing/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Billing'; diff --git a/types/Brand/Brand.d.ts b/types/Brand/Brand.d.ts deleted file mode 100644 index 201879887..000000000 --- a/types/Brand/Brand.d.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { IObjectWithId } from '../base'; - -/** - * The Brand class represents the public-accessible information about a user's brand, including logos, colors and themes. - * - * @see https://docs.easypost.com/docs/users/brand - */ -export declare interface IBrand extends IObjectWithId<'Brand'> { - /** - * The background color of the brand, as a hex code. - */ - background_color: string; - - /** - * The primary color of the brand, as a hex code. - */ - color: string; - - /** - * The logo of the brand, as a base64-encoded PNG, GIF, JPEG or SVG. - */ - logo: string; - - /** - * The URL of the brand's logo. - */ - logo_href: string; - - /** - * The banner ad of the brand, as a base64-encoded PNG, GIF, JPEG or SVG. - */ - ad: string; - - /** - * The URL of the brand's banner ad. - */ - ad_href: string; - - /** - * The ID of the brand's associated User. - */ - user_id: string; - - /** - * The name of the current theme. - */ - theme: 'theme1' | 'theme2'; -} - -declare class Brand implements IBrand { - id: string; - mode: 'test' | 'production'; - object: 'Brand'; - reference?: string | null; - ad: string; - ad_href: string; - background_color: string; - color: string; - logo: string; - logo_href: string; - theme: 'theme1' | 'theme2'; - user_id: string; - - /** - * Update the brand of the current authenticated user. - * - * @see https://docs.easypost.com/docs/users/brand#update-a-brand - * - * @param params The parameters to update the {@link Brand} with - * @returns {Promise} The updated Brand. - */ - static updateBrand(params: object): Promise; -} - -export type { Brand }; diff --git a/types/Brand/index.d.ts b/types/Brand/index.d.ts deleted file mode 100644 index 731d929af..000000000 --- a/types/Brand/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Brand'; diff --git a/types/Carrier/CarrierAccount/CarrierAccount.d.ts b/types/Carrier/CarrierAccount/CarrierAccount.d.ts deleted file mode 100644 index 18dc7fe01..000000000 --- a/types/Carrier/CarrierAccount/CarrierAccount.d.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../../base'; -import { DeepPartial } from '../../utils'; -import { ICarrierAccountCreateParameters } from './CarrierAccountCreateParameters'; -import { ICarrierAccountFields } from './CarrierAccountFields'; - -/** - * A CarrierAccount encapsulates your credentials with the carrier. - * The CarrierAccount object provides CRUD operations for all CarrierAccounts. - * - * Each EasyPost account is automatically provided a USPS account managed by EasyPost. - * - * Other operations, such as Shipment creation, can reference CarrierAccounts to reduce the scope of data returned. - * For instance, you may have multiple warehouses that need to use distinct FedEx SmartPost credentials to request the correct rates. - * Rate objects will include a `carrier_account_id` field which can be used to determine the account used for rating. - * - * @see https://docs.easypost.com/docs/carrier-accounts#carrieraccount-object - */ -export declare interface ICarrierAccount extends IObjectWithId<'CarrierAccount'>, IDatedObject { - /** - * The name of the carrier type. - */ - type: string; - - /** - * Contains "credentials" and/or "test_credentials", or may be empty - */ - fields: ICarrierAccountFields; - - /** - * If clone is true, only the reference and description are possible to update - */ - clone?: boolean | null; - - /** - * An optional, user-readable field to help distinguish accounts - */ - description?: string | null; - - /** - * An optional field that may be used in place of carrier_account_id in other API endpoints - */ - reference?: string | null; - - /** - * The name used when displaying a readable value for the type of the account - */ - readable: string; - - /** - * Unlike the "credentials" object contained in "fields", this nullable object contains just raw credential pairs for client library consumption - */ - credentials?: object | null; - - /** - * Unlike the "test_credentials" object contained in "fields", this nullable object contains just raw test_credential pairs for client library consumption - */ - test_credentials?: object | null; - - /** - * Billing type of the carrier account - */ - billing_type: string | null; -} - -declare class CarrierAccount implements ICarrierAccount { - public constructor(input: DeepPartial); - - id: string; - mode: 'test' | 'production'; - object: 'CarrierAccount'; - type: string; - fields: ICarrierAccountFields; - clone?: boolean | null; - description?: string | null; - reference?: string | null; - readable: string; - credentials?: object | null; - test_credentials?: object | null; - billing_type: string | null; - created_at: string; - updated_at: string; - - /** - * CarrierAccount objects may be managed through the EasyPost API using the Production mode API key only. - * Multiple accounts can be added for a single carrier. - * - * The CarrierType of the preferred CarrierAccount should be consulted before attempting to create a new CarrierAccount, as it will inform you of the field names expected by a certain carrier. - * - * @see https://docs.easypost.com/docs/carrier-accounts#create-a-carrieraccount - * @requires production API Key. - * - * @param {Object} params The parameters to create an {@link CarrierAccount} with - * @returns {Promise} The created and verified {@link CarrierAccount}. - */ - static create(params: Object): Promise; - - /** - * @see https://docs.easypost.com/docs/carrier-accounts#update-a-carrieraccount - * - * @param carrierAccountId Unique, begins with "ca_" - * @param {Object} params The parameters to create an {@link CarrierAccount} with - * @returns {Promise} The created and verified {@link CarrierAccount}. - */ - static update(carrierAccountId: string, params: Object): Promise; - - /** - * Retrieve an unpaginated list of all CarrierAccounts available to the authenticated account. - * Only Production API keys may be used to retrieve this list, as there is no test mode equivalent. - * - * @see https://docs.easypost.com/docs/carrier-accounts#retrieve-all-carrieraccounts - * @requires production API Key. - * - * @returns {Object} - An object containing a list of {@link CarrierAccount carrier accounts}. - */ - static all(): Promise; - - /** - * Retrieve a CarrierAccount by either its id or reference. - * However it is recommended to use EasyPost's provided identifiers because we do not enforce a unique reference. - * - * @param carrierAccountId Unique, begins with "ca_" - * - * @see https://docs.easypost.com/docs/carrier-accounts#retrieve-a-carrieraccount - * @requires production API Key. - * - * @returns {Promise} The {@link CarrierAccount} object. - */ - static retrieve(carrierAccountId: string): Promise; - - /** - * CarrierAccount objects may be removed from your account when they become out of date or no longer useful. - * - * @see https://docs.easypost.com/docs/carrier-accounts#delete-a-carrieraccount - * @requires production API Key. - * - * @param carrierAccountId Unique, begins with "ca_" - */ - static delete(carrierAccountId: string): void; -} - -export type { CarrierAccount }; diff --git a/types/Carrier/CarrierAccount/CarrierAccountCreateParameters.d.ts b/types/Carrier/CarrierAccount/CarrierAccountCreateParameters.d.ts deleted file mode 100644 index a313ce045..000000000 --- a/types/Carrier/CarrierAccount/CarrierAccountCreateParameters.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ParametersToOmitOnCreate } from '../../utils'; -import { ICarrierAccount } from './CarrierAccount'; - -export declare interface ICarrierAccountCreateParameters extends Omit< - ICarrierAccount, - ParametersToOmitOnCreate -> {} diff --git a/types/Carrier/CarrierAccount/CarrierAccountField.d.ts b/types/Carrier/CarrierAccount/CarrierAccountField.d.ts deleted file mode 100644 index d6c103a3d..000000000 --- a/types/Carrier/CarrierAccount/CarrierAccountField.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @see https://docs.easypost.com/docs/carrier-accounts#fields-object - */ -export declare interface ICarrierAccountField { - /** - * Each key in the sub-objects of a CarrierAccount's fields is the name of a settable field - */ - key: string; - - /** - * The visibility value is used to control form field types, and is discussed in the CarrierType section - */ - visibility: string; - - /** - * The label value is used in form rendering to display a more precise field name - */ - label: string; - - /** - * Checkbox fields use "0" and "1" as False and True, all other field types present plaintext, partly-masked, or masked credential data for reference - */ - value: string; -} diff --git a/types/Carrier/CarrierAccount/CarrierAccountFields.d.ts b/types/Carrier/CarrierAccount/CarrierAccountFields.d.ts deleted file mode 100644 index 13a74a63a..000000000 --- a/types/Carrier/CarrierAccount/CarrierAccountFields.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ICarrierAccountField } from './CarrierAccountField'; - -/** - * @see https://docs.easypost.com/docs/carrier-accounts#fields-object - */ -export declare interface ICarrierAccountFields { - /** - * Credentials used in the production environment. - */ - credentials: ICarrierAccountField; - - /** - * Credentials used in the test environment. - */ - test_credentials: ICarrierAccountField; - - /** - * For USPS this designates that no credentials are required. - */ - auto_link: boolean; - - /** - * When present, a separate authentication process will be required through the UI to link this account type. - */ - custom_workflow: boolean; -} diff --git a/types/Carrier/CarrierAccount/index.d.ts b/types/Carrier/CarrierAccount/index.d.ts deleted file mode 100644 index 054b8b901..000000000 --- a/types/Carrier/CarrierAccount/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './CarrierAccount'; -export * from './CarrierAccountFields'; -export * from './CarrierAccountField'; -export * from './CarrierAccountCreateParameters'; diff --git a/types/Carrier/CarrierMetadata/CarrierMetadata.d.ts b/types/Carrier/CarrierMetadata/CarrierMetadata.d.ts deleted file mode 100644 index c92e3b416..000000000 --- a/types/Carrier/CarrierMetadata/CarrierMetadata.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * The Carrier Metadata endpoint returns information about all the carriers available on the EasyPost platform. - * This information may include service levels, predefined packages, shipment options, supported features, and - * more that are available per carrier. This metadata can be useful during onboarding and integration or when - * determining the ideal carrier mix for your setup. - * - * @see https://docs.easypost.com/docs/carrier-metadata#carriermetadata-object - */ -export declare interface ICarrierMetadata { - /** - * The single-word name of a carrier such as "royalmail" - */ - carrier: string; - - /** - * The human-readable name of the carrier - */ - human_readable?: string | null; - - /** - * A list of service level objects for this carrier - */ - service_levels?: Array | null; - - /** - * A list of predefined package objects for this carrier - */ - predefined_packages?: Array | null; - - /** - * A list of supported feature objects for this carrier - */ - supported_features?: Array | null; - - /** - * A list of shipment option objects for this carrier - */ - shipment_options?: Array | null; -} - -declare class CarrierMetadata implements ICarrierMetadata { - carrier: string; - human_readable?: string | null; - service_levels?: Array | null; - predefined_packages?: Array | null; - supported_features?: Array | null; - shipment_options?: Array | null; - - /** - * Retrieve all Carrier Metadata for all carriers on the EasyPost platform. Optionally, - * filter the response by specifying a list of carriers or metadata types. - * - * @param {Array} carriers A comma-delimited list of single-word carriers you'd like to filter the response by - * @param {Array} types A comma-delimited list of the metadata types you'd like to filter the response by - * - * @see https://docs.easypost.com/docs/carrier-metadata#retrieve-carrier-metadata - * - * @returns {Promise} The {@link CarrierMetadata} object. - */ - static retrieve(carriers: Array, types: Array): Promise; -} - -export type { CarrierMetadata }; diff --git a/types/Carrier/CarrierMetadata/index.d.ts b/types/Carrier/CarrierMetadata/index.d.ts deleted file mode 100644 index 109e687de..000000000 --- a/types/Carrier/CarrierMetadata/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './CarrierMetadata'; diff --git a/types/Carrier/CarrierType/CarrierType.d.ts b/types/Carrier/CarrierType/CarrierType.d.ts deleted file mode 100644 index d00c32e2b..000000000 --- a/types/Carrier/CarrierType/CarrierType.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { IBaseObject } from '../../base'; -import { ICarrierTypeFields } from './CarrierTypeFields'; - -/** - * The CarrierType object provides an export declare interface for determining the valid fields of a CarrierAccount. - * The list of CarrierType objects only changes when a new carrier is added to EasyPost. - * - * The CarrierType objects consist of their top level attributes as well as a fields object that contains credentials and sometimes test_credentials sub-objects, - * which themselves are collections of attributes for CarrierAccount creation as well as metadata about presentation and the naming of said attributes. - * - * There are a couple special case CarrierAccounts, with structures differing somewhat from the norm. - * For instance, instead of credentials for UspsAccount, it has only auto_link: true, which indicates that it is an account that can be added or removed without any carrier-specific fields. - * - * The other custom option in the fields list is custom_workflow: true, which indicates that the EasyPost website export declare interface includes special processing for signups for the associated CarrierType. - * Carriers with a custom workflow will also present their normal credential rules, but it is considered unsafe to directly add a CarrierAccount of this type with these attributes filled out via another source than the EasyPost custom workflow. - * - * @see https://docs.easypost.com/docs/carrier-types#carriertype-object - */ -export declare interface ICarrierType extends IBaseObject<'CarrierType'> { - /** - * Specifies the CarrierAccount type. - */ - type: string; - - /** - * Contains at least one of the following keys: "auto_link", "credentials", "test_credentials", and "custom_workflow" - */ - fields: ICarrierTypeFields; -} - -declare class CarrierType implements ICarrierType { - type: string; - fields: ICarrierTypeFields; - object: 'CarrierType'; - - /** - * The CarrierType list is an unpaginated list of all carrier types available to the account of the given API key. - * - * @see https://docs.easypost.com/docs/carrier-types#retrieve-available-carrier-types - * @requires production API Key. - * - * @returns {Object} - An object containing a list of {@link CarrierType carrier types}. - */ - static all(): Promise; -} - -export type { CarrierType }; diff --git a/types/Carrier/CarrierType/CarrierTypeCredentials.d.ts b/types/Carrier/CarrierType/CarrierTypeCredentials.d.ts deleted file mode 100644 index 671c0470a..000000000 --- a/types/Carrier/CarrierType/CarrierTypeCredentials.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @see https://docs.easypost.com/docs/carrier-types#credentials-object - */ -export declare interface ICarrierTypeCredentials { - /** - * The key for each attribute sub-object within credentials is the name of the attribute for submission on CarrierAccounts - */ - name: string; - - /** - * There are five possible values, which encode the security need and storage type for each attribute: "visible", "checkbox", "fake", "password", and "masked" - */ - visibility: 'visible' | 'checkbox' | 'fake' | 'password' | 'masked'; - - /** - * Most attributes have generic names, so for clarity a "label" value is provided for clearer representation when rendering forms - */ - label: string; -} diff --git a/types/Carrier/CarrierType/CarrierTypeFields.d.ts b/types/Carrier/CarrierType/CarrierTypeFields.d.ts deleted file mode 100644 index 663f32034..000000000 --- a/types/Carrier/CarrierType/CarrierTypeFields.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { ICarrierTypeCredentials } from './CarrierTypeCredentials'; - -/** - * @see https://docs.easypost.com/docs/carrier-types#fields-object - */ -export declare interface ICarrierTypeFields { - /** - * If this key is present with the value of true, no other attributes are needed for CarrierAccount creation - */ - auto_link: boolean; - - /** - * If this key is present with the value of true, CarrierAccount creation of this type requires extra work not handled by the CarrierAccount standard API - */ - custom_workflow: boolean; - - /** - * If this object is present, required attribute names and their metadata are presented inside - */ - credentials: ICarrierTypeCredentials; - - /** - * If this object is present, it contains attribute names and metadata just as the credentials object. - * It is not required for CarrierAccount creation if you do not plan on using the carrier account for test mode - */ - test_credentials: ICarrierTypeCredentials; -} diff --git a/types/Carrier/CarrierType/index.d.ts b/types/Carrier/CarrierType/index.d.ts deleted file mode 100644 index 58e4783b4..000000000 --- a/types/Carrier/CarrierType/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './CarrierType'; -export * from './CarrierTypeFields'; -export * from './CarrierTypeCredentials'; diff --git a/types/Carrier/index.d.ts b/types/Carrier/index.d.ts deleted file mode 100644 index 8a86777f2..000000000 --- a/types/Carrier/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './CarrierAccount'; -export * from './CarrierMetadata'; -export * from './CarrierType'; diff --git a/types/Claim/Claim.d.ts b/types/Claim/Claim.d.ts deleted file mode 100644 index 7c00d5237..000000000 --- a/types/Claim/Claim.d.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; -import { IAllMethodParameters } from '../utils'; -import { IClaimCreateParameters } from './ClaimCreateParameters'; -import { TClaimHistory } from './ClaimHistory'; -import { TClaimPaymentMethod } from './ClaimPaymentMethod'; -import { TClaimType } from './ClaimType'; - -/** - * Class representing an EasyPost claim object. - * - */ -export declare interface IClaim extends IObjectWithId<'Claim'>, IDatedObject { - /** The amount that has been approved for reimbursement */ - approved_amount: string | null; - - /** A list of links to attachments associated with the claim */ - attachments: string[]; - - /** The address to which the reimbursement check should be sent */ - check_delivery_address: string | null; - - /** The email to contact if more information is needed on this claim */ - contact_email: string; - - /** The description of the claim */ - description: string; - - /** A list of status updates for this claim */ - history: TClaimHistory[]; - - /** The amount of insurance that was purchased for the rate associated with the claim */ - insurance_amount: string; - - /** The id associated with the insurance purchased for this claim */ - insurance_id: string; - - /** The way the claim will be payed out */ - payment_method: TClaimPaymentMethod; - - /** The name of the person who was to receive the shipment */ - recipient_name: null; - - /** An optional value that may be used in place of ID when doing Retrieve calls for this claim. */ - reference: string | null; - - /** The amount the claim is for */ - requested_amount: string; - - /** The salvage value of the damaged goods */ - salvage_value: null; - - /** The shipment id that is associated with this claim */ - shipment_id: string; - - /** The current status of the claim */ - status: string; - - /** Details about the current status of the claim */ - status_detail: string; - - /** When the status was last updated */ - status_timestamp: string; - - /** The tracking_code associated with the rate this claim was made for */ - tracking_code: string; - - /** The reason the package was in an unacceptable state and that this claim was made */ - type: TClaimType; -} - -declare class Claim implements IClaim { - public constructor(input: IClaimCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'Claim'; - approved_amount: string | null; - attachments: string[]; - check_delivery_address: string | null; - contact_email: string; - description: string; - history: TClaimHistory[]; - insurance_amount: string; - insurance_id: string; - payment_method: TClaimPaymentMethod; - recipient_name: null; - requested_amount: string; - salvage_value: null; - shipment_id: string; - reference: string | null; - status: string; - status_detail: string; - status_timestamp: string; - tracking_code: string; - type: TClaimType; - created_at: string; - updated_at: string; - - /** - * Create a claim - * - * @see https://docs.easypost.com/docs/insurance/claims#create-a-claim - * - * @param {Object} params The parameters to create an {@link Claim} with. - * @returns {Promise} The created and verified {@link Claim}. - */ - static create(params: Object): Promise; - - /** - * The Claim List is a paginated list of all Claim objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The has_more attribute indicates whether or not additional pages can be requested. - * The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where the next page begins. - * - * @see https://docs.easypost.com/docs/insurance/claims#retrieve-all-claims - * - * @returns {Object} - An object containing a list of {@link Claim claim} and pagination information. - */ - static all(params?: IAllMethodParameters): Promise<{ claims: Claim[]; has_more: boolean }>; - - /** - * Retrieve an Claim by id. - * - * @see https://docs.easypost.com/docs/insurance/claims#retrieve-a-claim - * - * @param claimId Unique, starts with "clm_" - * @returns {Promise} The retrieved {@link Claim}. - */ - static retrieve(claimId: string): Promise; - - /** - * Retrieve the next page of {@link Claim claims}. - * - * This automatically reuses the parameters from the previous call or the original {@link Claim.all} call. - * - * @see https://docs.easypost.com/docs/insurance/claims#retrieve-all-claims - * - * @param {Object} claims - The previous page of claims (the response from the last {@link Claim.getNextPage} or {@link Claim.all} call). - * @param {number} [pageSize] - The number of claims to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Claim claims} and pagination information. - */ - static getNextPage( - claims: Object, - pageSize?: number, - ): Promise<{ claims: Claim[]; has_more: boolean }>; - - /** - * Cancel an Claim by id. - * - * @see https://docs.easypost.com/docs/insurance/claims#cancel-a-claim - * - * @param claimId Unique, starts with "clm_" - * @returns {Promise} The refunded {@link Claim}. - */ - static cancel(claimId: string): Promise; -} - -export type { Claim }; diff --git a/types/Claim/ClaimCreateParameters.d.ts b/types/Claim/ClaimCreateParameters.d.ts deleted file mode 100644 index 6cb7f1e8f..000000000 --- a/types/Claim/ClaimCreateParameters.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { TClaimPaymentMethod } from './ClaimPaymentMethod'; -import { TClaimType } from './ClaimType'; - -export declare interface IClaimCreateParameters { - /** The tracking code of the shipment to file a claim for. */ - tracking_code: string; - - /** The type of claim to file. */ - type: TClaimType; - - /** The amount being claimed for reimbursement. */ - amount: string; - - /** - * Email-based files to attach to the claim for evidence. Each file must be a - * base64-encoded string. - */ - email_evidence_attachments?: string[]; - - /** - * Invoices to attach to the claim for evidence. Each file must be a - * base64-encoded string. - */ - invoice_attachments?: string[]; - - /** - * Additional supporting documents to attach to the claim. Required if the - * type is damage or theft. Each file must be a base64-encoded string. - */ - supporting_documentation_attachments?: string[]; - - /** Detailed description of the claim. */ - description: string; - - /** The name of the recipient of the reimbursement. */ - recipient_name: string; - - /** The email address of the contact for the claim. */ - contact_email: string; - - /** The payment method for the claim reimbursement. */ - payment_method: TClaimPaymentMethod; -} diff --git a/types/Claim/ClaimHistory.d.ts b/types/Claim/ClaimHistory.d.ts deleted file mode 100644 index aea875180..000000000 --- a/types/Claim/ClaimHistory.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export declare type TClaimHistory = { - /** The status of the claim at the time of this history entry. */ - status: string; - - /** The reason for the status of the claim at the time of this history entry. */ - status_detail: string; - - /** The date and time of the history entry. */ - timestamp: string; -}; diff --git a/types/Claim/ClaimPaymentMethod.d.ts b/types/Claim/ClaimPaymentMethod.d.ts deleted file mode 100644 index c4b90a45b..000000000 --- a/types/Claim/ClaimPaymentMethod.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare type TClaimPaymentMethod = 'mailed_check' | 'easypost_wallet'; diff --git a/types/Claim/ClaimType.d.ts b/types/Claim/ClaimType.d.ts deleted file mode 100644 index 0161c9a95..000000000 --- a/types/Claim/ClaimType.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare type TClaimType = 'damage' | 'loss' | 'theft'; diff --git a/types/Claim/index.d.ts b/types/Claim/index.d.ts deleted file mode 100644 index b0a544356..000000000 --- a/types/Claim/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './Claim'; -export * from './ClaimCreateParameters'; -export * from './ClaimHistory'; -export * from './ClaimType'; diff --git a/types/CustomerPortal/CustomerPortalAccountLink.d.ts b/types/CustomerPortal/CustomerPortalAccountLink.d.ts deleted file mode 100644 index 991007826..000000000 --- a/types/CustomerPortal/CustomerPortalAccountLink.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { ICustomerPortalAccountLinkCreateParameters } from './CustomerPortalAccountLinkCreateParameters'; - -/** - * Class representing an EasyPost CustomerPortalAccountLink object. - * - */ -export declare interface ICustomerPortalAccountLink { - /** Always returns "CustomerPortalAccountLink". */ - object: string; - - /** One-time-use session URL for initiating the Customer Portal. */ - link: string; - - /** One-time-use session URL for initiating the Customer Portal. */ - created_at: string; - - /** ISO 8601 timestamp when the link will expire (5 minutes from creation). */ - expires_at: string; -} - -declare class CustomerPortalAccountLink implements ICustomerPortalAccountLink { - public constructor(input: ICustomerPortalAccountLinkCreateParameters); - - object: 'CustomerPortalAccountLink'; - link: string; - created_at: string; - expires_at: string; - - /** - * Create a Portal Session. - * - * @see https://docs.easypost.com/docs/customer-portals#creating-a-portal-session - * - * @param {Object} params The parameters to create a {@link CustomerPortalAccountLink} with. - * @returns {Promise} The {@link CustomerPortalAccountLink}. - */ - static createAccountLink(params: Object): Promise; -} - -export type { CustomerPortalAccountLink }; diff --git a/types/CustomerPortal/CustomerPortalAccountLinkCreateParameters.d.ts b/types/CustomerPortal/CustomerPortalAccountLinkCreateParameters.d.ts deleted file mode 100644 index 44af038d3..000000000 --- a/types/CustomerPortal/CustomerPortalAccountLinkCreateParameters.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -export declare interface ICustomerPortalAccountLinkCreateParameters { - /** Type of Customer Portal session. */ - session_type: 'account_onboarding' | 'account_management'; - - /** The User ID of the sub account for which the portal session is being created. */ - user_id: string; - - /** The URL to which the sub account will be redirected if the session URL is expired, reused, or otherwise invalid. This should trigger a new session request. */ - refresh_url: string; - - /** - * The URL to which the sub account will be redirected after exiting the Customer Portal session. - * This does not confirm completion of the flow; webhook or API polling is recommended for confirmation. - */ - return_url: string; - - /** - * Used to configure the Customer Portal session. - */ - metadata?: object; -} diff --git a/types/CustomerPortal/index.d.ts b/types/CustomerPortal/index.d.ts deleted file mode 100644 index 42c938ef8..000000000 --- a/types/CustomerPortal/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './CustomerPortalAccountLink'; -export * from './CustomerPortalAccountLinkCreateParameters'; diff --git a/types/Customs/CustomsInfo/CustomsInfo.d.ts b/types/Customs/CustomsInfo/CustomsInfo.d.ts deleted file mode 100644 index 0c724e564..000000000 --- a/types/Customs/CustomsInfo/CustomsInfo.d.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../../base'; -import { DeepPartial } from '../../utils'; -import { ICustomsItem } from '../CustomsItem/CustomsItem'; -import { ICustomsInfoCreateParameters } from './CustomsInfoCreateParameters'; - -/** - * CustomsInfo objects contain CustomsItem objects and all necessary information for the generation of customs forms required for international shipping. - * - * Please see the Shipments documentation for examples of including a CustomsInfo object in a shipment. - * - * @see https://docs.easypost.com/docs/customs-infos#customsinfo-object - */ -export declare interface ICustomsInfo extends IObjectWithId<'CustomsInfo'>, IDatedObject { - /** - * "EEL" or "PFC" - * value less than $2500: "NOEEI 30.37(a)" - * value greater than $2500: see [Customs Guide](https://docs.easypost.com/guides/customs-guide) - */ - eel_pfc?: string | null; - - /** - * "documents", "gift", "merchandise", "returned_goods", "sample", or "other" - */ - contents_type?: string | null; - - /** - * (max 255 characters) Human readable description of content. - * Required for certain carriers and always required if contents_type is "other" - */ - contents_explanation?: string | null; - - /** - * Electronically certify the information provided - */ - customs_certify?: boolean | null; - - /** - * Required if customs_certify is true - */ - customs_signer?: string | null; - - /** - * "abandon" or "return", defaults to "return" - */ - non_delivery_option?: 'abandon' | 'return' | null; - - /** - * "none", "other", "quarantine", or "sanitary_phytosanitary_inspection" - */ - restriction_type?: 'none' | 'other' | 'quarantine' | 'sanitary_phytosanitary_inspection' | null; - - /** - * Required if restriction_type is not "none" - */ - restriction_comments?: string | null; - - /** - * Describes the products being shipped - */ - customs_items: ICustomsItem[]; - - /** - * A customs declaration message, available for eligible carriers - */ - declaration?: string | null; -} - -declare class CustomsInfo implements ICustomsInfo { - public constructor(input: DeepPartial); - - id: string; - mode: 'test' | 'production'; - object: 'CustomsInfo'; - eel_pfc?: string | null; - contents_type?: string | null; - contents_explanation?: string | null; - customs_certify?: boolean | null; - customs_signer?: string | null; - non_delivery_option?: 'abandon' | 'return' | null; - restriction_type?: 'none' | 'other' | 'quarantine' | 'sanitary_phytosanitary_inspection' | null; - restriction_comments?: string | null; - customs_items: ICustomsItem[]; - declaration?: string | null; - created_at: string; - updated_at: string; - - /** - * A CustomsInfo object contains all administrative information for processing customs, as well as a list of CustomsItems. When creating a CustomsInfo, you may store the ID from the response for use later in shipment creation. - * - * @see https://docs.easypost.com/docs/customs-infos#create-a-customsinfo - * - * @param {Object} params The parameters to create an {@link CustomsInfo} with. - * @returns {Promise} The {@link CustomsInfo}. - */ - static create(params: Object): Promise; - - /** - * A CustomsInfo can be retrieved by its id. - * - * @param CustomsInfoId Unique, begins with "cstinfo_" - * - * @see https://docs.easypost.com/docs/customs-infos#retrieve-a-customsinfo - * - * @returns {Promise} The {@link CustomsInfo}. - */ - static retrieve(CustomsInfoId: string): Promise; -} - -export type { CustomsInfo }; diff --git a/types/Customs/CustomsInfo/CustomsInfoCreateParameters.d.ts b/types/Customs/CustomsInfo/CustomsInfoCreateParameters.d.ts deleted file mode 100644 index ce85ff6de..000000000 --- a/types/Customs/CustomsInfo/CustomsInfoCreateParameters.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ParametersToOmitOnCreate } from '../../utils'; -import { ICustomsInfo } from './CustomsInfo'; - -export declare interface ICustomsInfoCreateParameters extends Omit< - ICustomsInfo, - ParametersToOmitOnCreate -> {} diff --git a/types/Customs/CustomsInfo/index.d.ts b/types/Customs/CustomsInfo/index.d.ts deleted file mode 100644 index 2f558baf3..000000000 --- a/types/Customs/CustomsInfo/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './CustomsInfo'; diff --git a/types/Customs/CustomsItem/CustomsItem.d.ts b/types/Customs/CustomsItem/CustomsItem.d.ts deleted file mode 100644 index 3aa912134..000000000 --- a/types/Customs/CustomsItem/CustomsItem.d.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../../base'; -import { DeepPartial } from '../../utils'; -import { ICustomsItemCreateParameters } from './CustomsItemCreateParameters'; - -/** - * A CustomsItem object describes goods for international shipment and should be created then included in a CustomsInfo object. - * - * @see https://docs.easypost.com/docs/customs-items-object - */ -export declare interface ICustomsItem extends IObjectWithId<'CustomsItem'>, IDatedObject { - /** - * Required, description of item being shipped - */ - description: string; - - /** - * Required, greater than zero - * float - */ - quantity: number; - - /** - * Required, greater than zero, total value (unit value * quantity) - * float (USD) - */ - value: number; - - /** - * Required, greater than zero, total weight (unit weight * quantity) - * float (oz) - */ - weight: number; - - /** - * Harmonized Tariff Schedule, e.g. "6109.10.0012" for Men's T-shirts - * - * @see https://hts.usitc.gov/ - */ - hs_tariff_number?: string | null; - - /** - * SKU/UPC or other product identifier - */ - code?: string | null; - - /** - * Required, 2 char country code - */ - origin_country: string; - - /** - * 3 char currency code, default USD - */ - currency?: string | null; -} - -declare class CustomsItem implements ICustomsItem { - public constructor(input: DeepPartial); - - id: string; - mode: 'test' | 'production'; - object: 'CustomsItem'; - description: string; - quantity: number; - value: number; - weight: number; - hs_tariff_number?: string | null; - code?: string | null; - origin_country: string; - currency?: string | null; - created_at: string; - updated_at: string; - - /** - * A CustomsItem contains information relating to each product within the package. When creating a customs item, you may store the ID from the response for use later in CustomsInfo creation. - * - * @see https://docs.easypost.com/docs/customs-items#create-a-customsitem - * - * @param {Object} params The parameters to create an {@link CustomsItem} with. - * @returns {Promise} The {@link CustomsItem}. - */ - static create(params: Object): Promise; - - /** - * A CustomsItem can be retrieved by its id. - * - * @param CustomsItemId Unique, begins with "cstitem_" - * - * @see https://docs.easypost.com/docs/customs-items#retrieve-a-customsitem - * - * @returns {Promise} The {@link CustomsItem}. - */ - static retrieve(CustomsItemId: string): Promise; -} - -export type { CustomsItem }; diff --git a/types/Customs/CustomsItem/CustomsItemCreateParameters.d.ts b/types/Customs/CustomsItem/CustomsItemCreateParameters.d.ts deleted file mode 100644 index 17f92ab83..000000000 --- a/types/Customs/CustomsItem/CustomsItemCreateParameters.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ParametersToOmitOnCreate } from '../../utils'; -import { ICustomsItem } from './CustomsItem'; - -export declare interface ICustomsItemCreateParameters extends Omit< - ICustomsItem, - ParametersToOmitOnCreate -> {} diff --git a/types/Customs/CustomsItem/index.d.ts b/types/Customs/CustomsItem/index.d.ts deleted file mode 100644 index 38bfcd6b0..000000000 --- a/types/Customs/CustomsItem/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './CustomsItem'; diff --git a/types/Customs/index.d.ts b/types/Customs/index.d.ts deleted file mode 100644 index f1640b6d8..000000000 --- a/types/Customs/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './CustomsInfo'; -export * from './CustomsItem'; diff --git a/types/EasyPost.d.ts b/types/EasyPost.d.ts deleted file mode 100644 index 3c4315840..000000000 --- a/types/EasyPost.d.ts +++ /dev/null @@ -1,162 +0,0 @@ -import { Address } from './Address'; -import { ApiKey } from './ApiKey'; -import { Batch } from './Batch'; -import { Billing } from './Billing'; -import { Brand } from './Brand'; -import { CarrierAccount, CarrierMetadata, CarrierType } from './Carrier'; -import { Claim } from './Claim'; -import { CustomerPortalAccountLink } from './CustomerPortal'; -import { CustomsInfo, CustomsItem } from './Customs'; -import { EmbeddablesSession } from './Embeddable'; -import { EndShipper } from './EndShipper'; -import { Event } from './Event'; -import { FedExRegistration } from './FedExRegistration'; -import { Fee } from './Fee'; -import { Insurance } from './Insurance'; -import { Luma } from './Luma'; -import { Order } from './Order'; -import { Parcel } from './Parcel'; -import { PaymentMethod } from './PaymentMethod'; -import { Pickup } from './Pickup'; -import { Rate } from './Rate'; -import { Referral } from './Referral'; -import { Refund } from './Refund'; -import { Report } from './Report'; -import { ScanForm } from './ScanForm'; -import { Shipment } from './Shipment'; -import { SmartRate } from './SmartRate'; -import { Tracker } from './Tracker'; -import { User } from './User'; -import { Utils } from './Utility'; -import { Webhook } from './Webhook'; - -export interface IEasyPostRequest { - method: 'get' | 'post' | 'put' | 'patch' | 'delete'; - path: string; - requestBody: any; - headers: Record; - requestTimestamp: number; - requestUUID: string; -} -export interface IEasyPostResponse extends IEasyPostRequest { - httpStatus: number; - responseBody: any; - responseTimestamp: number; -} - -export interface IEasyPostOptions { - /** - * Time in milliseconds that should fail requests. - */ - timeout?: number; - - /** - * Change the base URL that the API library uses. Useful if you proxy requests from a frontend through a server. - * @example https://api.easypost.com/v2/ - */ - baseUrl?: string; - - /** - * Disable using the API key. Useful if you proxy requests from a frontend through a server. - */ - useProxy?: boolean; - - /** - * Function that wraps the HTTP transport function. - * Backward-compatibility alias retained from the pre-fetch transport implementation. - */ - httpMiddleware?: (httpClient: any) => any; - - /** - * Function that wraps the HTTP transport function. - */ - httpClient?: (input: string, init?: Record) => Promise; - - /** - * Function that takes a compatibility request object and returns it. - * Supports legacy middleware patterns with `auth`, `query`, and `send` methods. - */ - requestMiddleware?: (request: any) => any; -} - -export default class EasyPost { - public Address: typeof Address; - public ApiKey: typeof ApiKey; - public Batch: typeof Batch; - public Billing: typeof Billing; - public Brand: typeof Brand; - public CarrierAccount: typeof CarrierAccount; - public CarrierMetadata: typeof CarrierMetadata; - public CarrierType: typeof CarrierType; - public Claim: typeof Claim; - public CustomerPortal: typeof CustomerPortalAccountLink; - public CustomsInfo: typeof CustomsInfo; - public CustomsItem: typeof CustomsItem; - public Embeddable: typeof EmbeddablesSession; - public EndShipper: typeof EndShipper; - public Event: typeof Event; - public FedExRegistration: typeof FedExRegistration; - public Fee: typeof Fee; // TODO: Fix IFee - public Insurance: typeof Insurance; - public Luma: typeof Luma; - public Order: typeof Order; - public Parcel: typeof Parcel; - public PaymentMethod: typeof PaymentMethod; - public Pickup: typeof Pickup; - public Rate: typeof Rate; - public ReferralCustomer: typeof Referral; - public Refund: typeof Refund; - public Report: typeof Report; - public ScanForm: typeof ScanForm; - public Shipment: typeof Shipment; - public SmartRate: typeof SmartRate; - public Tracker: typeof Tracker; - public User: typeof User; - public Utils: typeof Utils; - public Webhook: typeof Webhook; - - public constructor(apiKey: string, options?: IEasyPostOptions); - - /** - * Adds a request hook to the EasyPost client. Useful for logging or debugging. - */ - public addRequestHook(fn: (config: IEasyPostRequest) => void): void; - - /** - * Removes a request hook from the EasyPost client. - */ - public removeRequestHook(fn: (config: IEasyPostRequest) => void): void; - - /** - * Clears all request hooks from the EasyPost client. - */ - public clearRequestHooks(): void; - - /** - * Adds a response hook to the EasyPost client. Useful for logging or debugging. - */ - public addResponseHook(fn: (config: IEasyPostResponse) => void): void; - - /** - * Removes a response hook from the EasyPost client. - */ - public removeResponseHook(fn: (config: IEasyPostResponse) => void): void; - - /** - * Clears all response hooks from the EasyPost client. - */ - public clearResponseHooks(): void; - - /** - * Make an API call to the EasyPost API. - * - * This public, generic interface is useful for making arbitrary API calls to the EasyPost API that - * are not yet supported by the client library's services. When possible, the service for your use case - * should be used instead as it provides a more convenient and higher-level interface depending on the endpoint. - */ - public makeApiCall( - method: 'get' | 'post' | 'put' | 'patch' | 'delete', - endpoint: string, - params?: Record, - ): Promise>; -} diff --git a/types/Embeddable/EmbeddablesSession.d.ts b/types/Embeddable/EmbeddablesSession.d.ts deleted file mode 100644 index abfdfbff5..000000000 --- a/types/Embeddable/EmbeddablesSession.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { IEmbeddablesSessionCreateParameters } from './EmbeddablesSessionCreateParameters'; - -/** - * Class representing an EasyPost EmbeddablesSession object. - * - */ -export declare interface IEmbeddablesSession { - /** Always returns "EmbeddablesSession". */ - object: string; - - /** Short-lived, one-time-use token that authorizes an Embeddables Components session. Must be provided to the client-side Embeddables script to initialize the component. */ - session_id: string; - - /** ISO 8601 timestamp indicating when the session was created. */ - created_at: string; - - /** ISO 8601 timestamp indicating when the session expires. */ - expires_at: string; -} - -declare class EmbeddablesSession implements IEmbeddablesSession { - public constructor(input: IEmbeddablesSessionCreateParameters); - - object: 'EmbeddablesSession'; - session_id: string; - created_at: string; - expires_at: string; - - /** - * Create a Portal Session. - * - * @see https://docs.easypost.com/docs/embeddables#create-an-embeddable-session - * - * @param {Object} params The parameters to create a {@link EmbeddablesSession} with. - * @returns {Promise} The {@link EmbeddablesSession}. - */ - static createSession(params: Object): Promise; -} - -export type { EmbeddablesSession }; diff --git a/types/Embeddable/EmbeddablesSessionCreateParameters.d.ts b/types/Embeddable/EmbeddablesSessionCreateParameters.d.ts deleted file mode 100644 index a8f4c8126..000000000 --- a/types/Embeddable/EmbeddablesSessionCreateParameters.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export declare interface IEmbeddablesSessionCreateParameters { - /** The integrator’s domain in bare-host format (e.g., example.com), excluding protocol and subdomains. */ - origin_host: string; - - /** The User ID of the sub account for which the embeddable session is being created. */ - user_id: string; -} diff --git a/types/Embeddable/index.d.ts b/types/Embeddable/index.d.ts deleted file mode 100644 index db2293987..000000000 --- a/types/Embeddable/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './EmbeddablesSession'; -export * from './EmbeddablesSessionCreateParameters'; diff --git a/types/EndShipper/EndShipper.d.ts b/types/EndShipper/EndShipper.d.ts deleted file mode 100644 index 290c1af1b..000000000 --- a/types/EndShipper/EndShipper.d.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { IObjectWithId } from '../base'; -import { DeepPartial } from '../utils'; -import { IEndShipperCreateParameters } from './EndShipperCreateParameters'; -import { IEndShipperListParameters } from './EndShipperListParameters'; - -/** - * The EndShipper API is for platforms purchasing postage on behalf of their users, the EndShipper. - * Platforms must assert the EndShipper details, as the EndShipper is ultimately responsible for what is in the box. - * Multiple labels purchased for the same EndShipper must use the same EndShipper identity (API object). - * EndShipper objects must be created prior to buying a Shipment. Once EndShipper objects have been created, - * you must keep track of their public id in order to use them during a label buy. - * - * @see https://docs.easypost.com/docs/endshippers - */ -export declare interface IEndshipper extends IObjectWithId<'EndShipper'> { - /** - * Name of responsible person (conditionally required) - */ - name?: string | null; - - /** - * Name of responsible company (conditionally required) - */ - company?: string | null; - - /** - * First line of the address - */ - street1?: string | null; - - /** - * Second line of the address - */ - street2?: string | null; - - /** - * City the address is located in - */ - city?: string | null; - - /** - * State or province the address is located in - */ - state?: string | null; - - /** - * ZIP or postal code the address is located in - */ - zip: string; - - /** - * ISO 3166 country code for the country the address is located in - */ - country?: string; - - /** - * Phone number to reach the person or organization - */ - phone?: string | null; - - /** - * Email to reach the person or organization - */ - email?: string | null; -} - -declare class EndShipper implements IEndshipper { - public constructor(input: DeepPartial); - id: string; - mode: 'test' | 'production'; - object: 'EndShipper'; - street1?: string | null; - street2?: string | null; - city?: string | null; - state?: string | null; - zip: string; - country: string; - name?: string | null; - company?: string | null; - phone?: string | null; - email?: string | null; - - /** - * The EndShipper object is meant to represent the person or business entity responsible for the - * shipment and not necessarily the shipping location. - * EndShipper objects are fully-qualified Address objects and require every field to be filled with two exceptions: - * name and company fields. At least one of these fields must be filled (when both are present, name will take precedence). - * street2 field. This fieldcan be empty if the address does not include multiple lines. - * - * @see https://docs.easypost.com/docs/endshippers#create-an-endshipper - * - * @param {Object} params The parameters to create an {@link EndShipper} with. - * @returns {Promise} The created and verified {@link EndShipper}. - */ - static create(params: Object): Promise; - - /** - * An EndShipper object may be updated using the EndShipper API. - * All required fields for creating an EndShipper are required in an update request. Partial updates are not supported. - * - * @see https://docs.easypost.com/docs/endshippers#update-an-endshipper - * - * @param id Unique, start with "es_". - * @param params The parameters to update an {@link EndShipper} with. - * @returns {Promise} The updated {@link EndShipper}. - */ - static update(id: string, params: Object): Promise; - - /** - * Similar to retrieving a list of EndShippers, you can retrieve an individual EndShipper. - * - * @see https://docs.easypost.com/docs/endshippers#retrieve-an-endshipper - * - * @param id Unique, start with "es_". - * @returns {Promise} The retrieved {@link EndShipper}. - */ - static retrieve(id: string): Promise; - - /** - * List the EndShippers that have been created. - * - * @see https://docs.easypost.com/docs/endshippers#retrieve-all-endshippers - * - * @param params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link EndShipper endshippers} and pagination information. - */ - static all( - params: IEndShipperListParameters, - ): Promise<{ endshippers: EndShipper[]; has_more: boolean }>; -} - -export type { EndShipper }; diff --git a/types/EndShipper/EndShipperCreateParameters.d.ts b/types/EndShipper/EndShipperCreateParameters.d.ts deleted file mode 100644 index 7f156be4d..000000000 --- a/types/EndShipper/EndShipperCreateParameters.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ParametersToOmitOnCreate } from '../utils'; -import { IEndshipper } from './EndShipper'; - -export declare interface IEndShipperCreateParameters extends Omit< - IEndshipper, - ParametersToOmitOnCreate -> {} diff --git a/types/EndShipper/EndShipperListParameters.d.ts b/types/EndShipper/EndShipperListParameters.d.ts deleted file mode 100644 index c31f2e038..000000000 --- a/types/EndShipper/EndShipperListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/endshippers - */ -export declare interface IEndShipperListParameters extends IAllMethodParameters {} diff --git a/types/EndShipper/index.d.ts b/types/EndShipper/index.d.ts deleted file mode 100644 index 8cccc97ed..000000000 --- a/types/EndShipper/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './EndShipper'; -export * from './EndShipperCreateParameters'; diff --git a/types/Event/Event.d.ts b/types/Event/Event.d.ts deleted file mode 100644 index bd274122e..000000000 --- a/types/Event/Event.d.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; -import { IEventListParameters } from './EventListParameters'; - -/** - * Webhook Events are triggered by changes in objects you've created via the API. - * Every time an Event related to one of your objects is created, EasyPost guarantees at least one POST request will be sent to each of the webhook URLs set up for your account. - * For this reason, we strongly encourage your webhook handler to be idempotent. - * See the webhooks guide for more information. - * - * @see https://docs.easypost.com/docs/events - */ -export declare interface IEvent extends IObjectWithId<'Event'>, IDatedObject { - /** - * Result type and event name, see the "Possible Event Types" section for more information - */ - description: string; - - /** - * Previous values of relevant result attributes - */ - previous_attributes: any; - - /** - * The object associated with the Event. See the "object" attribute on the result to determine its specific type. - * This field will not be returned when retrieving events directly from the API - */ - result: any; - - /** - * The current status of the event. Possible values are "completed", "failed", "in_queue", "retrying", or "pending" (deprecated) - * - * @deprecated - */ - status: 'completed' | 'failed' | 'in_queue' | 'retrying' | 'pending'; - - /** - * Webhook URLs that have not yet been successfully notified as of the time this webhook event was sent. - * The URL receiving the Event will still be listed in pending_urls, as will any other URLs that receive the Event at the same time - */ - pending_urls: string[]; - - /** - * Webhook URLs that have already been successfully notified as of the time this webhook was sent - */ - completed_urls: string[]; -} - -declare class Event implements IEvent { - id: string; - mode: 'test' | 'production'; - object: 'Event'; - description: string; - previous_attributes: any; - result: any; - status: 'completed' | 'failed' | 'in_queue' | 'retrying' | 'pending'; - pending_urls: string[]; - completed_urls: string[]; - created_at: string; - updated_at: string; - - /** - * Events can be retrieved by their ID. - * - * @param eventId the ID of the event object. - * @returns {Promise} The retrieved {@link Event}. - */ - static retrieve(eventId: string): Promise; - - /** - * Retrieve all event objects. - * - * @param {Object} params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Event events} and pagination information. - */ - static all(params: IEventListParameters): Promise<{ events: Event[]; has_more: boolean }>; - - /** - * Retrieve the next page of {@link Event events}. - * - * This automatically reuses the parameters from the previous call or the original {@link Event.all} call. - * - * @see https://docs.easypost.com/docs/events#retrieve-all-events - * - * @param {Object} events - The previous page of events (the response from the last {@link Event.getNextPage} or {@link Event.all} call). - * @param {number} [pageSize] - The number of events to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Event events} and pagination information. - */ - static getNextPage( - events: Object, - pageSize?: number, - ): Promise<{ events: Event[]; has_more: boolean }>; -} - -export type { Event }; diff --git a/types/Event/EventListParameters.d.ts b/types/Event/EventListParameters.d.ts deleted file mode 100644 index 30a2e6419..000000000 --- a/types/Event/EventListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/events#retrieve-all-events - */ -export declare interface IEventListParameters extends IAllMethodParameters {} diff --git a/types/Event/Payload/Payload.d.ts b/types/Event/Payload/Payload.d.ts deleted file mode 100644 index 49130e93b..000000000 --- a/types/Event/Payload/Payload.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../../base'; -import { IPayloadListParameters } from './PayloadListParameters'; - -/** - * A Payload represents an attempt by EasyPost to send an Event to a Webhook. - * An Event can have multiple Payloads. For instance, if there is a failure to deliver a Webhook, - * an Event would have multiple payloads, one for each attempt to deliver the Event to the Webhook. - * Payload can be useful for debugging webhook delivery and when initially setting up EasyPost webhooks. - */ -export declare interface IPayload extends IObjectWithId<'Payload'>, IDatedObject { - /** - * The body of the Payload response - */ - response_body: string | null; -} - -declare class Payload implements IPayload { - id: string; - mode: 'test' | 'production'; - object: 'Payload'; - response_body: string; - created_at: string; - updated_at: string; - - /** - * Payload can be retrieved by their ID. - * - * @see https://docs.easypost.com/docs/events/payloads#retrieve-a-payload - * - * @param eventId the ID of the event object. - * @param payloadId the ID of the payload. - * @returns {Promise} The retrieved {@link Payload payload}. - */ - static retrieve(eventId: string, payloadId: string): Promise; - - /** - * Retrieve all payload objects. - * - * @see https://docs.easypost.com/docs/events/payloads#retrieve-all-payloads - * - * @param params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Payload payloads} and pagination information. - */ - static all(params: IPayloadListParameters): Promise<{ payloads: Payload[] }>; -} - -export type { Payload }; diff --git a/types/Event/Payload/PayloadListParameters.d.ts b/types/Event/Payload/PayloadListParameters.d.ts deleted file mode 100644 index 22f2f7170..000000000 --- a/types/Event/Payload/PayloadListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../../utils'; - -/** - * @see https://docs.easypost.com/docs/events/payloads#retrieve-all-payloads - */ -export declare interface IPayloadListParameters extends IAllMethodParameters {} diff --git a/types/Event/Payload/index.d.ts b/types/Event/Payload/index.d.ts deleted file mode 100644 index b1fd98702..000000000 --- a/types/Event/Payload/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Payload'; diff --git a/types/Event/index.d.ts b/types/Event/index.d.ts deleted file mode 100644 index e59a11981..000000000 --- a/types/Event/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Event'; diff --git a/types/FedExRegistration/FedExRegistration.d.ts b/types/FedExRegistration/FedExRegistration.d.ts deleted file mode 100644 index 98a121ba9..000000000 --- a/types/FedExRegistration/FedExRegistration.d.ts +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Interface for FedEx Account Validation Response returned during initial validation steps. - */ -export declare interface IFedExAccountValidationResponse { - /** - * Email address for PIN delivery (if applicable) - */ - email_address?: string | null; - - /** - * Available PIN delivery options (SMS, CALL, EMAIL, INVOICE) - */ - options?: Array | null; - - /** - * Phone number for PIN delivery (if applicable) - */ - phone_number?: string | null; - - /** - * Carrier account ID (returned upon successful validation) - */ - id?: string | null; - - /** - * Object type (returned upon successful validation) - */ - object?: string | null; - - /** - * Carrier account type (returned upon successful validation) - */ - type?: string | null; - - /** - * Carrier account credentials (returned upon successful validation) - */ - credentials?: Record | null; -} - -/** - * Interface for FedEx Request PIN Response. - */ -export declare interface IFedExRequestPinResponse { - /** - * Confirmation message that PIN was sent - */ - message?: string | null; -} - -/** - * The FedEx Registration service provides methods for registering FedEx carrier accounts with multi-factor authentication. - * - * @see https://support.easypost.com/hc/en-us/articles/35262738410253-FedEx-Multi-Factor-Authentication - */ -declare class FedExRegistration { - /** - * Register the billing address for a FedEx account. - * - * @param fedexAccountNumber The FedEx account number. - * @param params Parameters including address_validation and optional easypost_details. - * @returns {Promise} Response object with next steps (PIN or invoice validation). - */ - static registerAddress( - fedexAccountNumber: string, - params: { - address_validation: { - name?: string; - street1: string; - city: string; - state: string; - postal_code: string; - country_code: string; - }; - easypost_details?: { - action?: string; - type?: string; - carrier_account_id?: string; - }; - }, - ): Promise; - - /** - * Request a PIN for FedEx account verification. - * - * @param fedexAccountNumber The FedEx account number. - * @param pinMethodOption The PIN delivery method: "SMS", "CALL", or "EMAIL". - * @param params Parameters including easypost_details. - * @returns {Promise} Response object confirming PIN was sent. - */ - static requestPin( - fedexAccountNumber: string, - pinMethodOption: string, - params: { - easypost_details?: { - action?: string; - type?: string; - carrier_account_id?: string; - }; - }, - ): Promise; - - /** - * Validate the PIN entered by the user for FedEx account verification. - * - * @param fedexAccountNumber The FedEx account number. - * @param params Parameters including pin_validation and optional easypost_details. - * @returns {Promise} Response object with carrier account credentials. - */ - static validatePin( - fedexAccountNumber: string, - params: { - pin_validation: { - pin_code: string; - name?: string; - }; - easypost_details?: { - action?: string; - type?: string; - carrier_account_id?: string; - }; - }, - ): Promise; - - /** - * Submit invoice information to complete FedEx account registration. - * - * @param fedexAccountNumber The FedEx account number. - * @param params Parameters including invoice_validation and optional easypost_details. - * @returns {Promise} Response object with carrier account credentials. - */ - static submitInvoice( - fedexAccountNumber: string, - params: { - invoice_validation: { - name?: string; - invoice_number: string; - invoice_date: string; - invoice_amount: string; - invoice_currency: string; - }; - easypost_details?: { - action?: string; - type?: string; - carrier_account_id?: string; - }; - }, - ): Promise; -} - -export type { FedExRegistration }; diff --git a/types/FedExRegistration/index.d.ts b/types/FedExRegistration/index.d.ts deleted file mode 100644 index 3279c547f..000000000 --- a/types/FedExRegistration/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './FedExRegistration'; diff --git a/types/Fee/Fee.d.ts b/types/Fee/Fee.d.ts deleted file mode 100644 index 7dee8fd93..000000000 --- a/types/Fee/Fee.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { IBaseObject } from '../base'; -import { TFeeType } from './FeeType'; - -/** - * Fee objects are used to represent the breakdown of charges made when purchasing an item on EasyPost. - * Shipments and Trackers both have associations to Fee objects. - * - * Each Shipment object will have a Fee of type "LabelFee" to represent the label fee charged by EasyPost for the service. - * Shipments with postage collected by EasyPost (as opposed to shipments with postage collected directly by the carrier) will have a "PostageFee" according to the postage amount. - * Insurance on a Shipment will add an "InsuranceFee" with the insurance premium (not the covered value) for the amount. - * Tracker objects will have a "TrackerFee" with the price, even when a Tracker is free. - * - * @see https://docs.easypost.com/docs/fees#fee-object - */ -export declare interface IFee extends IBaseObject<'Fee'> { - /** - * The name of the category of fee. Possible types are "LabelFee", "PostageFee", "InsuranceFee", and "TrackerFee" - */ - type: TFeeType; - - /** - * USD value with sub-cent precision - */ - amount: string; - - /** - * Whether EasyPost has successfully charged your account for the fee - */ - charged: boolean; - - /** - * Whether the Fee has been refunded successfully - */ - refunded: boolean; -} - -declare class Fee implements IFee { - object: 'Fee'; - type: TFeeType; - amount: string; - charged: boolean; - refunded: boolean; -} - -export type { Fee }; diff --git a/types/Fee/FeeType.d.ts b/types/Fee/FeeType.d.ts deleted file mode 100644 index 04fe55530..000000000 --- a/types/Fee/FeeType.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare type TFeeType = 'InsuranceFee' | 'LabelFee' | 'PostageFee' | 'TrackerFee'; diff --git a/types/Fee/index.d.ts b/types/Fee/index.d.ts deleted file mode 100644 index bcaf739f4..000000000 --- a/types/Fee/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Fee'; -export * from './FeeType'; diff --git a/types/Insurance/Insurance.d.ts b/types/Insurance/Insurance.d.ts deleted file mode 100644 index 4b55ced06..000000000 --- a/types/Insurance/Insurance.d.ts +++ /dev/null @@ -1,176 +0,0 @@ -import { IAddress } from '../Address'; -import { IDatedObject, IObjectWithId } from '../base'; -import { IFee } from '../Fee'; -import { ITracker } from '../Tracker'; -import { IAllMethodParameters } from '../utils'; -import { IInsuranceCreateParameters } from './InsuranceCreateParameters'; -import { TInsuranceStatus } from './InsuranceStatus'; - -/** - * An Insurance object represents insurance for packages purchased both via the EasyPost API as well as shipments purchased through third parties and later registered with EasyPost. - * An Insurance is created automatically whenever you buy a Shipment through EasyPost and pass insurance options during the Buy call or in a later call to Insure a Shipment. - * - * Insurance purchased through the Shipment Buy or Insure endpoints is immediately insured - there is no possibility of rejection based on tracking information, as the package was just created. - * On the other hand, Insurance purchased on shipments purchased outside of EasyPost requires creation with a tracking code so that EasyPost may confirm the package existence and current shipping status at the time of purchase. - * - * Standalone insurance is created in a pending state to help distinguish it from insurance purchased for an EasyPost Shipment. - * Both kinds of Insurance use the Tracking system to receive periodic updates, and will report those updates to any appropriate Webhooks on file. - * Standalone insurance will cancel itself if the tracking information for the given tracking code shows evidence of having been shipped anytime before the insurance was purchased. - * - * Unlike Shipments within EasyPost, Insurance objects register To and From Address objects according to the destination and ship-from locations of the package. - * This means that a Shipment with "is_return: true" actually ships to the listed From Address. - * Insurance does not have a concept of "is_return", so all insurance records refer to their true package destination as "to_address", regardless of whether or not the shipment is a return. - * - * @see https://docs.easypost.com/docs/insurance#insurance-object - */ -export declare interface IInsurance extends IObjectWithId<'Insurance'>, IDatedObject { - /** - * The unique reference for this Insurance, if any - */ - reference?: string | null; - - /** - * USD value of insured goods with sub-cent precision - */ - amount: string; - - /** - * The insurance provider used by EasyPost - */ - provider: string; - - /** - * An identifying number for some insurance providers used by EasyPost - */ - provider_id: string; - - /** - * The ID of the Shipment in EasyPost, if postage was purchased via EasyPost - */ - shipment_id: string; - - /** - * The tracking code of either the shipment within EasyPost, or provided by you during creation - */ - tracking_code: string; - - /** - * The current status of the insurance, possible values are "new", "pending", "purchased", "failed", or "cancelled" - */ - status: TInsuranceStatus; - - /** - * The associated Tracker object - */ - tracker: ITracker; - - /** - * The associated Address object for destination - */ - to_address: IAddress; - - /** - * The associated Address object for origin - */ - from_address: IAddress; - - /** - * The associated InsuranceFee object if any - */ - fee: IFee; - - /** - * The list of errors encountered during attempted purchase of the insurance - */ - messages: string[]; -} - -declare class Insurance implements IInsurance { - public constructor(input: IInsuranceCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'Insurance'; - reference?: string | null; - amount: string; - provider: string; - provider_id: string; - shipment_id: string; - tracking_code: string; - status: TInsuranceStatus; - tracker: ITracker; - to_address: IAddress; - from_address: IAddress; - fee: IFee; - messages: string[]; - created_at: string; - updated_at: string; - - /** - * An Insurance created via this endpoint must belong to a shipment purchased outside of EasyPost. - * Insurance for Shipments created within EasyPost must be created via the Shipment Buy or Insure endpoints. - * When creating Insurance for a non-EasyPost shipment, you must provide `to_address`, `from_address`, `tracking_code`, and `amount` information. - * Optionally, you can provide the carrier parameter, which will help EasyPost identify the carrier the package was shipped with. - * If no carrier is provided, EasyPost will attempt to determine the carrier based on the tracking_code provided. - * Providing a carrier parameter is recommended, since some tracking_codes are ambiguous and may match with more than one carrier. - * In addition, not having to auto-match the carrier will significantly speed up the response time. - * - * @see https://docs.easypost.com/docs/insurance#create-an-insurance - * - * @param {Object} params The parameters to create an {@link Insurance} with. - * @returns {Promise} The created and verified {@link Insurance}. - */ - static create(params: Object): Promise; - - /** - * The Insurance List is a paginated list of all Insurance objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The has_more attribute indicates whether or not additional pages can be requested. - * The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where the next page begins. - * - * @see https://docs.easypost.com/docs/insurance#retrieve-all-insurances - * - * @returns {Object} - An object containing a list of {@link Insurance insurance} and pagination information. - */ - static all( - params?: IAllMethodParameters, - ): Promise<{ insurances: Insurance[]; has_more: boolean }>; - - /** - * Retrieve an Insurance by id. - * - * @see https://docs.easypost.com/docs/insurance#retrieve-an-insurance - * - * @param insuranceId Unique, starts with "ins_" - * @returns {Promise} The retrieved {@link Insurance}. - */ - static retrieve(insuranceId: string): Promise; - - /** - * Retrieve the next page of {@link Insurance insurances}. - * - * This automatically reuses the parameters from the previous call or the original {@link Insurance.all} call. - * - * @see https://docs.easypost.com/docs/insurance#retrieve-all-insurances - * - * @param {Object} insurances - The previous page of insurances (the response from the last {@link Insurance.getNextPage} or {@link Insurance.all} call). - * @param {number} [pageSize] - The number of insurances to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Insurance insurances} and pagination information. - */ - static getNextPage( - insurances: Object, - pageSize?: number, - ): Promise<{ insurances: Insurance[]; has_more: boolean }>; - - /** - * Refund an Insurance by id. - * - * @see https://docs.easypost.com/docs/insurance#refund-an-insurance - * - * @param insuranceId Unique, starts with "ins_" - * @returns {Promise} The refunded {@link Insurance}. - */ - static refund(insuranceId: string): Promise; -} - -export type { Insurance }; diff --git a/types/Insurance/InsuranceCreateParameters.d.ts b/types/Insurance/InsuranceCreateParameters.d.ts deleted file mode 100644 index e467ef25c..000000000 --- a/types/Insurance/InsuranceCreateParameters.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { IAddress } from '../Address'; - -export declare interface IInsuranceCreateParameters { - reference?: string | null; - to_address: IAddress | string; - from_address: IAddress | string; - - /** - * The carrier associated with the tracking_code you provided. - * The carrier will get auto-detected if none is provided - */ - carrier?: string | null; - - /** - * The tracking code associated with the non-EasyPost-purchased package you'd like to insure. - */ - tracking_code: string; - - /** - * The USD value of contents you would like to insure. - * Currently the maximum is $5000 - * - * @example 100.00 - */ - amount: string; -} diff --git a/types/Insurance/InsuranceStatus.d.ts b/types/Insurance/InsuranceStatus.d.ts deleted file mode 100644 index 80ad8f4ef..000000000 --- a/types/Insurance/InsuranceStatus.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare type TInsuranceStatus = 'new' | 'pending' | 'purchased' | 'failed' | 'cancelled'; diff --git a/types/Insurance/index.d.ts b/types/Insurance/index.d.ts deleted file mode 100644 index 198f8684d..000000000 --- a/types/Insurance/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './Insurance'; -export * from './InsuranceStatus'; -export * from './InsuranceCreateParameters'; diff --git a/types/Luma/Luma.d.ts b/types/Luma/Luma.d.ts deleted file mode 100644 index d870df72e..000000000 --- a/types/Luma/Luma.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Interface representing an EasyPost Luma promise object. - * - * @see https://docs.easypost.com/docs/luma - */ -export declare interface ILumaPromise { - /** Always returns "LumaInfo". */ - object: string; - - /** The delivery date and time commitment. */ - delivery_datetime: string | null; - - /** The delivery date commitment. */ - delivery_date: string | null; - - /** The pickup date and time commitment. */ - pickup_datetime: string | null; - - /** The pickup date commitment. */ - pickup_date: string | null; - - /** The carrier account used for the promise. */ - carrier_account_id: string | null; - - /** The service level used for the promise. */ - service: string | null; - - /** The carrier used for the promise. */ - carrier: string | null; -} - -/** - * The Luma class interacts with the Luma API to provide service recommendations. - * - * @see https://docs.easypost.com/docs/luma - */ -declare class Luma { - /** - * Get service recommendations from Luma that meet the criteria of your ruleset. - * - * @see https://docs.easypost.com/docs/luma - * - * @param params - The parameters to get a Luma promise with (shipment parameters). - * @returns {Promise} - An object containing the Luma promise. - */ - static getPromise(params: object): Promise; -} - -export type { Luma }; diff --git a/types/Luma/index.d.ts b/types/Luma/index.d.ts deleted file mode 100644 index 24ea27a16..000000000 --- a/types/Luma/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Luma'; diff --git a/types/Order/Order.d.ts b/types/Order/Order.d.ts deleted file mode 100644 index 529c3611d..000000000 --- a/types/Order/Order.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { IAddress } from '../Address'; -import { IDatedObject, IObjectWithId } from '../base'; -import { IRate } from '../Rate'; -import { IMessage, IShipment } from '../Shipment'; -import { IOrderCreateParameters } from './OrderCreateParameters'; - -/** - * The Order object represents a collection of packages and can be used for Multi-Piece Shipments. - * Like a single Shipment each Order consists of a "to" and "from" Address to be used for each Shipment within the Order. - * These Addresses will be copied to each Shipment so there is no need to specify them multiple times. - * Each Shipment must then specify its Parcel, Options, and CustomsInfo. - * - * An Order created with valid Address Objects and Parcel data nested within the Order's Shipment object will automatically retrieve available shipping Rate options. - * - * @see https://docs.easypost.com/docs/orders#order-object - */ -export declare interface IOrder extends IObjectWithId<'Order'>, IDatedObject { - /** - * An optional field that may be used in place of id in other API endpoints - */ - reference?: string | null; - - /** - * The destination address - */ - to_address: IAddress; - - /** - * The origin address - */ - from_address: IAddress; - - /** - * The shipper's address, defaults to from_address - */ - return_address?: IAddress | null; - - /** - * The buyer's address, defaults to to_address - */ - buyer_address?: IAddress | null; - - /** - * All associated Shipment objects. Maximum of 100. - */ - shipments: IShipment[]; - - /** - * All associated Rate objects - */ - rates: IRate[]; - - /** - * Any carrier errors encountered during rating - */ - messages: IMessage[]; - - /** - * Set true to create as a return - */ - is_return?: boolean | null; -} - -declare class Order implements IOrder { - public constructor(input: IOrderCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'Order'; - reference?: string | null; - to_address: IAddress; - from_address: IAddress; - return_address?: IAddress | null; - buyer_address?: IAddress | null; - shipments: IShipment[]; - rates: IRate[]; - messages: IMessage[]; - is_return?: boolean | null; - created_at: string; - updated_at: string; - - /** - * An Order is almost exclusively a container for other objects, and thus an Order may reuse many of these objects. - * Alternatively, all the objects contained within an Order may be created at the same time. - * - * You can limit the CarrierAccounts to use for rating by passing the carrier_accounts parameter. - * - * @see https://docs.easypost.com/docs/orders#create-an-order - * - * @param {Object} params The parameters to create an {@link Order} with. - * @returns {Promise} The created and verified {@link Order}. - */ - static create(params: Object): Promise; - - /** - * An Order can be retrieved by either its id or reference. - * However it is recommended to use EasyPost's provided identifiers because uniqueness on reference is not enforced. - * - * @see https://docs.easypost.com/docs/orders#retrieve-an-order - * - * @param orderId Unique, begins with "order_" - * @returns {Promise} The retrieved {@link Order}. - */ - static retrieve(orderId: string): Promise; - - /** - * To purchase an Order you only need to specify the carrier and service to purchase. - * This operation populates the `tracking_code` and `postage_label` attributes of each Shipment. - * - * @see https://docs.easypost.com/docs/orders#buy-an-order - * - * @param orderId Unique, begins with "order_" - * @param carrier Carrier (UPS, FedEx, USPS) - * @param service Service of the carrier - * - * @returns {Promise} The {@link Order} object. - */ - static buy(orderId: string, carrier: string, service: string): Promise; - - /** - * Returns the rates of an Order. - * - * @param orderId Unique, begins with "order_" - * @returns {Promise} The list of {@link IRate[]}. - */ - static getRates(orderId: string): Promise; - - /** - * - * @param carriers a list of carriers to filter rates for. - * @param services a list of services to filter rates for. - * @returns {Rate} The lowest {@link Rate}. - */ - lowestRate(carriers?: string[], services?: string[]): IRate; -} - -export type { Order }; diff --git a/types/Order/OrderCreateParameters.d.ts b/types/Order/OrderCreateParameters.d.ts deleted file mode 100644 index 05fce62b9..000000000 --- a/types/Order/OrderCreateParameters.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { IAddress } from '../Address'; -import { Shipment } from '../Shipment'; - -export declare interface IOrderCreateParameters { - reference?: string | null; - to_address: IAddress | string; - from_address: IAddress | string; - shipments: Shipment[]; - - /** - * optional array of ids that begin with "ca_" - */ - carrier_accounts?: string[] | null; -} diff --git a/types/Order/index.d.ts b/types/Order/index.d.ts deleted file mode 100644 index aead5d7cb..000000000 --- a/types/Order/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Order'; -export * from './OrderCreateParameters'; diff --git a/types/Parcel/Parcel.d.ts b/types/Parcel/Parcel.d.ts deleted file mode 100644 index cd1dd5af0..000000000 --- a/types/Parcel/Parcel.d.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; -import { DeepPartial } from '../utils'; -import { IParcelCreateParameters } from './ParcelCreateParameters'; - -/** - * Parcel objects represent the physical container being shipped. - * Dimensions can be supplied either as length, width, and height dimensions, or a predefined_package string. - * Only weight is required, but since many carriers charge different rates for packages with large dimensions, we strongly recommend including all dimensions if available. - * - * Weights are in OUNCES (OZ) and go to one decimal point. - * Dimensions are in INCHES (IN) and go to one decimal point. - * - * @see https://docs.easypost.com/docs/parcels#parcel-object - */ -export declare interface IParcel extends IObjectWithId<'Parcel'>, IDatedObject { - /** - * Required if width and/or height are present - * float (inches) - */ - length?: number | null; - - /** - * Required if width and/or height are present - * float (inches) - */ - width?: number | null; - - /** - * Required if width and/or height are present - * float (inches) - */ - height?: number | null; - - /** - * Always required - * float (oz) - */ - weight: number; - - /** - * Optional, one of our predefined_packages - */ - predefined_package?: string | null; -} - -declare class Parcel implements IParcel { - public constructor(input: DeepPartial); - - id: string; - mode: 'test' | 'production'; - object: 'Parcel'; - length?: number | null; - width?: number | null; - height?: number | null; - predefined_package?: string | null; - weight: number; - created_at: string; - updated_at: string; - - /** - * Include the `weight`, and either a `predefined_package` or `length`, `width` and `height` if applicable. - * - * @see https://docs.easypost.com/docs/parcels#create-a-parcel - * - * @param {Object} params The parameters to create an {@link Parcel} with. - * @returns {Promise} The created and verified {@link Parcel}. - */ - static create(params: Object): Promise; - - /** - * Get a Parcel by its id. - * In general you should not need to use this in your automated solution. - * A Parcel's id can be inlined into the creation call to other objects. - * This allows you to only create one Parcel for each package you will be using. - * - * @see https://docs.easypost.com/docs/parcels#retrieve-a-parcel - * - * @param parcelId Unique, begins with "prcl_" - * @returns {Promise} The retrieved {@link Parcel}. - */ - static retrieve(parcelId: string): Promise; -} - -export type { Parcel }; diff --git a/types/Parcel/ParcelCreateParameters.d.ts b/types/Parcel/ParcelCreateParameters.d.ts deleted file mode 100644 index 22e3ae711..000000000 --- a/types/Parcel/ParcelCreateParameters.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ParametersToOmitOnCreate } from '../utils'; -import { IParcel } from './Parcel'; - -export declare interface IParcelCreateParameters extends Omit { - /** - * Required if width and/or height are present - * float (inches) - */ - length?: number | null; - - /** - * Required if width and/or height are present - * float (inches) - */ - width?: number | null; - - /** - * Required if width and/or height are present - * float (inches) - */ - height?: number | null; - - /** - * Always required - * float (oz) - */ - weight: number; -} diff --git a/types/Parcel/index.d.ts b/types/Parcel/index.d.ts deleted file mode 100644 index f4ffd66ec..000000000 --- a/types/Parcel/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Parcel'; diff --git a/types/PaymentMethod/PaymentMethod.d.ts b/types/PaymentMethod/PaymentMethod.d.ts deleted file mode 100644 index 82c76d12b..000000000 --- a/types/PaymentMethod/PaymentMethod.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { IObjectWithId } from '../base'; - -/** - * The Payment method object can be either credit card or bank account. - */ -export declare interface IPaymentMethod extends IObjectWithId<'PaymentMethod'> { - /** - * Country of the bank account - */ - country: string; - - /** - * Name of the bank - */ - bank_name: string; - - /** - * Brand of the credit card - */ - brand: string; - - /** - * Whether the payment method(credit card or bank account) is disabled or not - */ - disabled_at: string; - - /** - * Expiration month of the credit card - */ - exp_month: number; - - /** - * Expiration year of the credit card - */ - exp_year: number; - - /** - * Last four of the credit card - */ - last4: string; - - /** - * Name of the credit card - */ - name: string; - - /** - * Whether the bank account is verified or not - */ - verified: boolean; -} - -declare class PaymentMethod implements IPaymentMethod { - id: string; - mode: 'test' | 'production'; - object: 'PaymentMethod'; - country: string; - bank_name: string; - brand: string; - disabled_at: string; - exp_month: number; - exp_year: number; - last4: string; - name: string; - verified: boolean; -} - -export type { PaymentMethod }; diff --git a/types/PaymentMethod/index.d.ts b/types/PaymentMethod/index.d.ts deleted file mode 100644 index ce53190ca..000000000 --- a/types/PaymentMethod/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './PaymentMethod'; diff --git a/types/Pickup/Pickup.d.ts b/types/Pickup/Pickup.d.ts deleted file mode 100644 index 401424042..000000000 --- a/types/Pickup/Pickup.d.ts +++ /dev/null @@ -1,201 +0,0 @@ -import { IAddress } from '../Address'; -import { IDatedObject, IObjectWithId } from '../base'; -import { ICarrierAccount } from '../Carrier'; -import { IRate } from '../Rate'; -import { IMessage, IShipment } from '../Shipment'; -import { IPickupCreateParameters } from './PickupCreateParameters'; -import { IPickupListParameters } from './PickupListParameters'; -import { IPickupRate } from './PickupRate'; - -/** - * The Pickup object allows you to schedule a pickup from your carrier from your customer's residence or place of business. - * Supported carriers include: - * - Canada Post - * - Canpar - * - DHL Express - * - FedEx - * - Lasership - * - Loomis Express - * - LSO - * - Ontrac - * - UPS - * - USPS - * - Veho - * - * After a Pickup is successfully created, it will automatically fetch PickupRates for each CarrierAccount specified that supports scheduled pickups. - * Then a PickupRate must be selected and purchased before the pickup can be successfully scheduled. - * - * @see https://docs.easypost.com/docs/pickups#pickup-object - */ -export declare interface IPickup extends IObjectWithId<'Pickup'>, IDatedObject { - /** - * An optional field that may be used in place of ID in some API endpoints - */ - reference?: string | null; - - /** - * One of: "unknown", "scheduled", or "canceled" - */ - status: 'unknown' | 'scheduled' | 'canceled'; - - /** - * The earliest time at which the package is available to pick up - */ - min_datetime: string; - - /** - * The latest time at which the package is available to pick up. - * Must be later than the min_datetime - */ - max_datetime: string; - - /** - * Is the pickup address the account's address? - */ - is_account_address?: boolean | null; - - /** - * Additional text to help the driver successfully obtain the package - */ - instructions?: string | null; - - /** - * A list of messages containing carrier errors encountered during pickup rate generation - */ - messages: IMessage[]; - - /** - * The confirmation number for a booked pickup from the carrier - */ - confirmation: string; - - /** - * The associated Shipment - */ - shipment: IShipment; - - /** - * The associated Address - */ - address: IAddress; - - /** - * The list of carriers (if empty, all carriers were used) used to generate pickup rates - */ - carrier_accounts?: ICarrierAccount[] | null; - - /** - * The list of different pickup rates across valid carrier accounts for the shipment - */ - pickup_rates: IPickupRate[]; -} - -declare class Pickup implements IPickup { - public constructor(input: IPickupCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'Pickup'; - reference?: string | null; - status: 'unknown' | 'scheduled' | 'canceled'; - min_datetime: string; - max_datetime: string; - is_account_address?: boolean | null; - instructions?: string | null; - messages: IMessage[]; - confirmation: string; - shipment: IShipment; - address: IAddress; - carrier_accounts?: ICarrierAccount[] | null; - pickup_rates: IPickupRate[]; - created_at: string; - updated_at: string; - - /** - * Creating a Pickup will automatically fetch rates for the given time frame and location. - * - * Pickups work with existing shipments or a batch and either a fully-specified Address object or id. - * The examples below assume that a shipment and address have both already been created. - * - * @see https://docs.easypost.com/docs/pickups#create-a-pickup - * - * @param {Object} params The parameters to create an {@link Pickup} with. - * @returns {Promise} The created and verified {@link Pickup}. - */ - static create(params: Object): Promise; - - /** - * The Pickup List is a paginated list of all Pickup objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The has_more attribute indicates whether additional pages can be requested. - * The recommended way of paginating is to use either the before_id or after_id parameter to specify where the next page begins. - * - * @see https://docs.easypost.com/docs/pickups#retrieve-all-pickups - * - * @param params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Pickup pickups} and pagination information. - */ - static all(params?: IPickupListParameters): Promise<{ pickups: Pickup[]; has_more: boolean }>; - - /** - * A Pickup object can be retrieved by either an id or reference. - * However it is recommended to use EasyPost's provided identifiers because uniqueness on reference is not enforced. - * - * @see https://docs.easypost.com/docs/pickups#retrieve-a-pickup - * - * @param pickupId Unique, starts with "pickup_" - * @returns {Promise} The created and verified {@link Pickup}. - */ - static retrieve(pickupId: string): Promise; - - /** - * To purchase a Pickup a PickupRate must be specified by its carrier and service name, instead of its id. - * The client libraries will handle this automatically if a PickupRate is provided. - * - * @see https://docs.easypost.com/docs/pickups#buy-a-pickup - * - * @param pickupId Unique, begins with "pickup_" - * @param carrier Carrier (UPS, FedEx, USPS) - * @param service Service of the carrier - * @returns {Promise} The created and verified {@link Pickup}. - */ - static buy(pickupId: string, carrier: string, service: string): Promise; - - /** - * You may cancel a Pickup anytime before it has been completed. - * It requires no additional parameters other than the id or reference. - * The status will change to "canceled" on success. - * - * @see https://docs.easypost.com/docs/pickups#cancel-a-pickup - * - * @param pickupId Unique, begins with "pickup_" - * @returns {Promise} The created and verified {@link Pickup}. - */ - static cancel(pickupId: string): Promise; - - /** - * Retrieve the next page of {@link Pickup pickups}. - * - * This automatically reuses the parameters from the previous call or the original {@link Pickup.all} call. - * - * @see https://docs.easypost.com/docs/pickups#retrieve-all-pickups - * - * @param {Object} pickups - The previous page of pickups (the response from the last {@link Pickup.getNextPage} or {@link Pickup.all} call). - * @param {number} [pageSize] - The number of pickups to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Pickup pickups} and pagination information. - */ - static getNextPage( - pickups: Object, - pageSize?: number, - ): Promise<{ pickups: Pickup[]; has_more: boolean }>; - - /** - * - * @param carriers a list of carriers to filter rates for. - * @param services a list of services to filter rates for. - * @returns {Rate} The lowest {@link Rate}. - */ - lowestRate(carriers?: string[], services?: string[]): IRate; -} - -export type { Pickup }; diff --git a/types/Pickup/PickupCreateParameters.d.ts b/types/Pickup/PickupCreateParameters.d.ts deleted file mode 100644 index 109fe09bc..000000000 --- a/types/Pickup/PickupCreateParameters.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { IPickupRate } from './PickupRate'; -import { Address } from '../Address'; -import { Batch } from '../Batch'; -import { CarrierAccount } from '../Carrier'; -import { Shipment } from '../Shipment'; - -interface BasePickupCreateParameters { - address: Address | string; - carrier_accounts?: CarrierAccount[] | null; - confirmation?: string | null; - instructions?: string | null; - is_account_address?: boolean | null; - max_datetime: string; - min_datetime: string; - pickup_rates: IPickupRate; - reference?: string | null; - status: string; -} - -interface ShipmentPickupCreateParameters extends BasePickupCreateParameters { - shipment?: Shipment | string | null; -} - -interface BatchPickupCreateParameters extends BasePickupCreateParameters { - batch?: Batch | string | null; -} - -export type IPickupCreateParameters = ShipmentPickupCreateParameters | BatchPickupCreateParameters; diff --git a/types/Pickup/PickupListParameters.d.ts b/types/Pickup/PickupListParameters.d.ts deleted file mode 100644 index d43400459..000000000 --- a/types/Pickup/PickupListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/pickups#retrieve-all-pickups - */ -export declare interface IPickupListParameters extends IAllMethodParameters {} diff --git a/types/Pickup/PickupRate.d.ts b/types/Pickup/PickupRate.d.ts deleted file mode 100644 index b308dd240..000000000 --- a/types/Pickup/PickupRate.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; - -/** - * @see https://docs.easypost.com/docs/pickups#pickuprate-object - */ -export declare interface IPickupRate extends IObjectWithId<'PickupRate'>, IDatedObject { - /** - * service name - */ - service: string; - - /** - * name of carrier - */ - carrier: string; - - /** - * the actual rate quote for this service - */ - rate: string; - - /** - * currency for the rate - */ - currency: string; - - /** - * the ID of the pickup this is a quote for - */ - pickup_id: string; -} diff --git a/types/Pickup/index.d.ts b/types/Pickup/index.d.ts deleted file mode 100644 index 99968d8e0..000000000 --- a/types/Pickup/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './Pickup'; -export * from './PickupRate'; -export * from './PickupCreateParameters'; diff --git a/types/Rate/Rate.d.ts b/types/Rate/Rate.d.ts deleted file mode 100644 index a0cc8389d..000000000 --- a/types/Rate/Rate.d.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; - -/** - * The Rate class represents a summary of the price and details of a delivery service quote. - * - * @see https://docs.easypost.com/docs/shipments/rates - */ -export declare interface IRate extends IObjectWithId<'Rate'>, IDatedObject { - /** - * The service level of the rate. - */ - service: string; - /** - * The carrier of the rate. - */ - carrier: string; - /** - * The ID of the carrier account associated with this rate. - */ - carrier_account_id: string; - /** - * The ID of the shipment associated with this rate. - */ - shipment_id: string; - /** - * The quote price of the rate. - */ - rate: string; - /** - * The currency of the rate. - */ - currency: string; - /** - * The in-store retail rate given with no account. - */ - retail_rate: string; - /** - * The currency of the retail rate. - */ - retail_currency: string; - /** - * The non-negotiated rate given for having an account with the carrier. - */ - list_rate: string; - /** - * The currency of the list rate. - */ - list_currency: string; - /** - * The number of days in transit for this rate. - */ - delivery_days: number; - /** - * The delivery date for this rate. - */ - delivery_date: string; - /** - * Whether the delivery window is guaranteed. - */ - delivery_date_guaranteed: boolean; - /** - * The earliest delivery date for this rate. - * This is deprecated and should be ignored. - */ - est_delivery_days: number; - /** - * The billing type of the rate. - */ - billing_type: string; -} - -declare class Rate implements IRate { - billing_type: string; - carrier: string; - carrier_account_id: string; - created_at: string; - currency: string; - delivery_date: string; - delivery_date_guaranteed: boolean; - delivery_days: number; - est_delivery_days: number; - id: string; - list_currency: string; - list_rate: string; - mode: 'test' | 'production'; - object: 'Rate'; - rate: string; - retail_currency: string; - retail_rate: string; - service: string; - shipment_id: string; - updated_at: string; -} - -export type { Rate }; diff --git a/types/Rate/index.d.ts b/types/Rate/index.d.ts deleted file mode 100644 index 9ef03ab5e..000000000 --- a/types/Rate/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Rate'; diff --git a/types/Referral/Referral.d.ts b/types/Referral/Referral.d.ts deleted file mode 100644 index c4bba244f..000000000 --- a/types/Referral/Referral.d.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { IApiKey } from '../ApiKey'; -import { IUser } from '../User'; -import { IReferralCreateParameters } from './ReferralCreateParameters'; -import { IReferralListParameters } from './ReferralListParameters'; - -/** - * A Referral represents a sub-user under a Partner or white-label account. - * - * @see https://docs.easypost.com/docs/users/referral-customers - */ -export declare interface IReferral extends IUser { - /** - * API keys for the referral customer (only returned on creation). - * Contains both test and production API keys. - * These keys should be saved securely as they cannot be retrieved again later. - */ - api_keys?: IApiKey[]; -} - -declare class Referral implements IReferral { - public constructor(input: IReferralCreateParameters); - - id: string; - mode: 'test' | 'production'; - // @ts-ignore Suppress warning about "object" override - object: 'Referral'; - reference?: string | null; - parent_id: string; - name: string; - email: string; - phone_number?: string | null; - balance: string; - recharge_amount: string; - secondary_recharge_amount: string; - recharge_threshold: string; - children: IUser[]; - api_keys?: IApiKey[]; - - /** - * Creates a referral customer. - * - * @see https://docs.easypost.com/docs/users/referral-customers#create-a-referralcustomer - * - * @param {Object} params The parameters to create an {@link Referral} with. - * @returns {Promise} The created Referral. - */ - static create(params: Object): Promise; - - /** - * The Referral List is a paginated list of all Referral objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The `has_more` attribute indicates whether additional pages can be requested. - * The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where the next page begins. - * - * @see https://docs.easypost.com/docs/users/referral-customers#retrieve-all-referralcustomers - * - * @param params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Referral referral customers} and pagination information. - */ - static all( - params?: IReferralListParameters, - ): Promise<{ referral_customers: Referral[]; has_more: boolean }>; - - /** - * Update a Referral's email address. - * - * @see https://docs.easypost.com/docs/users/referral-customers#update-a-referralcustomer - * - * @param {string} referralUserId ID of the referral user to update - * @param {string} email New email address for the referral user - * @returns {Promise} Whether the update was successful - */ - static updateEmail(referralUserId: string, email: string): Promise; - - /** - * Add Stripe payment method to referral customer. - * - * @see https://docs.easypost.com/docs/users/referral-customers#add-payment-method-to-referralcustomer - * - * @param {string} stripeCustomerId Stripe customer ID - * @param {string} paymentMethodReference Reference for the Stripe payment method - * @param {string} priority Whether the payment method is primary or secondary - * @returns {object} Object representing the newly-added payment method - */ - static addPaymentMethod( - stripeCustomerId: string, - paymentMethodReference: string, - priority?: string, - ): object; - - /** - * Refund by amount for a recent payment. - * @see https://docs.easypost.com/docs/users/referral-customers#refund-a-referralcustomer - * - * @param {number} refundAmount Amount to refund - * @returns {object} Object representing the newly-added payment method - */ - static refundByAmount(refundAmount: number): object; - - /** - * Refund a payment by a payment log ID. - * @see https://docs.easypost.com/docs/users/referral-customers#refund-a-referralcustomer - * - * @param {string} paymentLogId ID of the payment log to refund - * @returns {object} Object representing the newly-added payment method - */ - static refundByPaymentLog(paymentLogId: string): object; - - /** - * Retrieve the next page of {@link Referral referrals}. - * - * This automatically reuses the parameters from the previous call or the original {@link Referral.all} call. - * - * @see https://docs.easypost.com/docs/users/referral-customers#retrieve-all-referralcustomers - * - * @param {Object} referralCustomers - The previous page of referrals (the response from the last {@link Referral.getNextPage} or {@link Referral.all} call). - * @param {number} [pageSize] - The number of referrals to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Referral referrals} and pagination information. - */ - static getNextPage( - referralCustomers: Object, - pageSize?: number, - ): Promise<{ referral_customers: Referral[]; has_more: boolean }>; -} - -export type { Referral }; diff --git a/types/Referral/ReferralCreateParameters.d.ts b/types/Referral/ReferralCreateParameters.d.ts deleted file mode 100644 index a9a8d5b33..000000000 --- a/types/Referral/ReferralCreateParameters.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ParametersToOmitOnCreate } from '../utils'; -import { IReferral } from './Referral'; - -export declare interface IReferralCreateParameters extends Omit< - IReferral, - ParametersToOmitOnCreate -> {} diff --git a/types/Referral/ReferralListParameters.d.ts b/types/Referral/ReferralListParameters.d.ts deleted file mode 100644 index 5ebd59f20..000000000 --- a/types/Referral/ReferralListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/users/referral-customers#retrieve-all-referralcustomers - */ -export declare interface IReferralListParameters extends IAllMethodParameters {} diff --git a/types/Referral/index.d.ts b/types/Referral/index.d.ts deleted file mode 100644 index 4f93470e0..000000000 --- a/types/Referral/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Referral'; -export * from './ReferralCreateParameters'; diff --git a/types/Refund/Refund.d.ts b/types/Refund/Refund.d.ts deleted file mode 100644 index c8ff8fdc0..000000000 --- a/types/Refund/Refund.d.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; -import { IRefundCreateParameters } from './RefundCreateParameters'; -import { IRefundListParameters } from './RefundListParameters'; - -/** - * The Refund object represents a refunded shipment, and includes details about the related Shipment and tracking code. - * USPS shipping labels can be refunded if requested within 30 days of generation. - * The processing time is at least 15 days, after which the funds will return to your EasyPost balance. - * EasyPost fees will also be refunded. To qualify, a shipment must not have been scanned by the USPS. - * UPS and FedEx shipping labels may be refunded within 90 days of creation. - */ -export declare interface IRefund extends IObjectWithId<'Refund'>, IDatedObject { - /** - * The tracking code of the related Shipment - */ - tracking_code: string; - - /** - * The confirmation number for the refund request to the carrier - */ - confirmation_number: string; - - /** - * The status of the refund request, reported by the carrier. Possible values are "submitted", "refunded", or "rejected" - */ - status: 'submitted' | 'refunded' | 'rejected'; - - /** - * The carrier the refund request was submitted to - */ - carrier: string; - - /** - * The ID of the related Shipment being refunded - */ - shipment_id: string; -} - -declare class Refund implements IRefund { - public constructor(input: IRefundCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'Refund'; - tracking_code: string; - confirmation_number: string; - status: 'submitted' | 'refunded' | 'rejected'; - carrier: string; - shipment_id: string; - created_at: string; - updated_at: string; - - /** - * This endpoint is intended to be used to bulk-process multiple refunds; as a result, this endpoint will return a list of Refund objects. - * To refund a single shipment, use the Refund a Shipment endpoint instead. - * - * @see https://docs.easypost.com/docs/refunds#create-a-refund - * - * @param {Object} params The parameters to create an {@link Refund} with. - * @returns {Promise} The created and verified {@link Refund}. - */ - static create(params: Object): Promise; - - /** - * Retrieve a paginated list of all Refunds associated with the given API Key. - * See the Pagination section of our docs for more details on retrieving all records when multiple pages are available. - * - * @see https://docs.easypost.com/docs/refunds#retrieve-all-refunds - * - * @param params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Refund refunds} and pagination information. - */ - static all(params?: IRefundListParameters): Promise<{ refunds: Refund[]; has_more: boolean }>; - - /** - * Retrieve a Refund by id. - * - * @see https://docs.easypost.com/docs/refunds#retrieve-a-refund - * - * @param refundId Unique, starts with "refund_" - * @returns {Promise} The created and verified {@link Refund}. - */ - static retrieve(refundId: string): Promise; - - /** - * Retrieve the next page of {@link Refund refunds}. - * - * This automatically reuses the parameters from the previous call or the original {@link Refund.all} call. - * - * @see https://docs.easypost.com/docs/refunds#retrieve-all-refunds - * - * @param {Object} refunds - The previous page of refunds (the response from the last {@link Refund.getNextPage} or {@link Refund.all} call). - * @param {number} [pageSize] - The number of refunds to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Refund refunds} and pagination information. - */ - static getNextPage( - refunds: Object, - pageSize?: number, - ): Promise<{ refunds: Refund[]; has_more: boolean }>; -} - -export type { Refund }; diff --git a/types/Refund/RefundCreateParameters.d.ts b/types/Refund/RefundCreateParameters.d.ts deleted file mode 100644 index e4d498e68..000000000 --- a/types/Refund/RefundCreateParameters.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @see https://docs.easypost.com/docs/refunds#create-a-refund - */ -export declare interface IRefundCreateParameters { - /** - * The carrier to request a refund from - */ - carrier: string; - - /** - * A list of tracking codes to request refunds for. Even for a single tracking code, it needs to be submitted as a list. - */ - tracking_codes: string[]; -} diff --git a/types/Refund/RefundListParameters.d.ts b/types/Refund/RefundListParameters.d.ts deleted file mode 100644 index 6210bf30b..000000000 --- a/types/Refund/RefundListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/refunds#retrieve-all-refunds - */ -export declare interface IRefundListParameters extends IAllMethodParameters {} diff --git a/types/Refund/index.d.ts b/types/Refund/index.d.ts deleted file mode 100644 index 109195cc5..000000000 --- a/types/Refund/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Refund'; -export * from './RefundCreateParameters'; diff --git a/types/Report/Report.d.ts b/types/Report/Report.d.ts deleted file mode 100644 index 4495848ef..000000000 --- a/types/Report/Report.d.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; -import { IReportCreateParameters } from './ReportCreateParameters'; -import { IReportListParameters } from './ReportListParameters'; -import { TReportObjectType } from './ReportObjectType'; - -/** - * A Report contains a csv that is a log of all the objects created within a certain time frame. - * - * Reports can be generated using the Reports Endpoint. - * You can create and view Reports created between any time frame defined between the start_date and end_date. - * - * The Report api can be categorized into several types. - * These types determine which EasyPost Object to produce a Report for, and should be passed as the type in our libraries: - * - cash_flow - * - insurance - * - payment_log - * - refund - * - shipment - * - shipment_invoice - * - tracker - * - * @see https://docs.easypost.com/docs/reports#report-object - */ -export declare interface IReport extends IObjectWithId, IDatedObject { - /** - * "new", "available", "failed", or null - */ - status: 'new' | 'available' | 'failed' | null; - - /** - * A date string in YYYY-MM-DD form eg: "2016-02-02" - */ - start_date: string; - - /** - * A date string in YYYY-MM-DD form eg: "2016-02-03" - */ - end_date: string; - - /** - * Set true if you would like to include Refunds /Shipments /Trackers created by child users - */ - include_children?: boolean | null; - - /** - * A url that contains a link to the Report. - * Expires 30 seconds after retrieving this object - */ - url: string; - - /** - * Url expiring time - */ - url_expires_at: string; - - /** - * Set true if you would like to send an email containing the Report - */ - send_email?: boolean | null; -} - -declare class Report implements IReport { - public constructor(input: IReportCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: TReportObjectType; - status: 'new' | 'available' | 'failed' | null; - start_date: 'unknown' | 'scheduled' | 'canceled'; - end_date: string; - include_children?: boolean | null; - url: string; - url_expires_at: string; - send_email?: boolean | null; - created_at: string; - updated_at: string; - - /** - * To create a Report, provide a `start_date` and `end_date` that are less than 31 days apart along with any other - * optional parameter that you would like to specify. A detailed list of Report Object attributes are provided below. - * - * The expiry on url is 30 seconds. The default status on each new Report is "new". It changes to "available" if the - * csv file is created successfully or to "failed" when csv creation is unsuccessful, or to "empty" if the report - * does not include any data for the specified date range. Additionally, null could also be a status. - * - * When a Report's status changes, a webhook will be created. See our Webhooks Guide for help on Event handling. - * - * @see https://docs.easypost.com/docs/reports#create-a-report - * - * @param {Object} params The parameters to create an {@link Report} with. - * @returns {Promise} The created and verified {@link Report}. - */ - static create(params: Object): Promise; - - /** - * The Report List is a paginated list of all Report objects associated with the given API Key. It accepts a variety of - * parameters which can be used to modify the scope. The `has_more` attribute indicates whether or not additional pages can - * be requested. The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where - * the next page begins. - * - * @see https://docs.easypost.com/docs/reports#retrieve-all-reports - * - * @param params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Report reports} and pagination information. - */ - static all(params?: IReportListParameters): Promise<{ reports: Report[]; has_more: boolean }>; - - /** - * Retrieve a Report by id. - * - * @param reportId Unique, starts with the prefix for that particular report, - * eg: "cfrep_", "plrep_", "refrep_", "shprep_", "shpinvrep_", "trkrep_" - * - * @see https://docs.easypost.com/docs/reports#retrieve-a-report - */ - static retrieve(reportId: string): Promise; - - /** - * Retrieve the next page of {@link Report reports}. - * - * This automatically reuses the parameters from the previous call or the original {@link Report.all} call. - * - * @see https://docs.easypost.com/docs/reports#retrieve-all-reports - * - * @param {Object} reports - The previous page of reports (the response from the last {@link Report.getNextPage} or {@link Report.all} call). - * @param {number} [pageSize] - The number of reports to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Report reports} and pagination information. - */ - static getNextPage( - reports: Object, - pageSize?: number, - ): Promise<{ reports: Report[]; has_more: boolean }>; -} - -export type { Report }; diff --git a/types/Report/ReportCreateParameters.d.ts b/types/Report/ReportCreateParameters.d.ts deleted file mode 100644 index 43ec64bad..000000000 --- a/types/Report/ReportCreateParameters.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export declare interface IReportCreateParameters { - start_date: string | null; - end_date?: string | null; - include_children?: boolean | null; - send_email?: boolean | null; - columns?: string[] | null; - additional_columns?: string[] | null; -} diff --git a/types/Report/ReportListParameters.d.ts b/types/Report/ReportListParameters.d.ts deleted file mode 100644 index deaefc273..000000000 --- a/types/Report/ReportListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/refunds#retrieve-all-refunds - */ -export declare interface IReportListParameters extends IAllMethodParameters {} diff --git a/types/Report/ReportObjectType.d.ts b/types/Report/ReportObjectType.d.ts deleted file mode 100644 index c9cc99059..000000000 --- a/types/Report/ReportObjectType.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export declare type TReportObjectType = - | 'CashFlowReport' - | 'PaymentLogReport' - | 'RefundReport' - | 'ShipmentReport' - | 'ShipmentInvoiceReport' - | 'TrackerReport'; diff --git a/types/Report/index.d.ts b/types/Report/index.d.ts deleted file mode 100644 index d0c66d61c..000000000 --- a/types/Report/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Report'; -export * from './ReportObjectType'; diff --git a/types/ScanForm/ScanForm.d.ts b/types/ScanForm/ScanForm.d.ts deleted file mode 100644 index 4b5b9a9ac..000000000 --- a/types/ScanForm/ScanForm.d.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { IAddress } from '../Address'; -import { IDatedObject, IObjectWithId } from '../base'; -import { IScanFormCreateParameters } from './ScanFormCreateParameters'; -import { IScanFormListParameters } from './ScanFormListParameters'; - -/** - * A ScanForm can be created to speed up and simplify the carrier pickup process. - * The ScanForm is one document that can be scanned to mark all included tracking codes as "Accepted for Shipment" by the carrier. - * The following criteria must met before creation: - * - Refunded Shipments cannot be added - * - Each Shipment must have the same origin address - * - Shipments must all be dated (using the label_date option) on or after the date the form is generated - * - Shipments cannot be added to more than one ScanForm - * - Existing ScanForms may not be updated with additional Shipments. If a ScanForm already exists, and new Shipments need to be added, a new ScanForm must be created. - * - Shipments should be provided in the form of an array - * - * @see https://docs.easypost.com/docs/scan-form-object - */ -export declare interface IScanForm extends IObjectWithId<'ScanForm'>, IDatedObject { - /** - * Current status. - * Possible values are "creating", "created" and "failed" - */ - status: 'creating' | 'created' | 'failed'; - - /** - * Human-readable message explaining any failures - */ - message: string; - - /** - * Address that the Shipments will be shipped from - */ - address: IAddress; - - /** - * Tracking codes included on the ScanForm - */ - tracking_codes: string[]; - - /** - * Url of the document - */ - form_url: string; - - /** - * File format of the document - */ - form_file_type: string; - - /** - * The id of the associated Batch. Unique, starts with "batch_" - */ - batch_id: string; -} - -declare class ScanForm implements IScanForm { - public constructor(input: IScanFormCreateParameters); - - address: IAddress; - batch_id: string; - created_at: string; - form_file_type: string; - form_url: string; - id: string; - message: string; - mode: 'test' | 'production'; - object: 'ScanForm'; - status: 'creating' | 'created' | 'failed'; - tracking_codes: string[]; - updated_at: string; - - /** - * A ScanForm can be created to speed up and simplify the carrier pickup process. - * The Scan Form is one document that can be scanned to mark all included tracking codes as "Accepted for Shipment" by the carrier. - * - * @see https://docs.easypost.com/docs/scan-form - * - * @returns {Promise} The created ScanForm - * - * @param {Object} params The parameters to create an {@link ScanForm} with. - * @returns {Promise} The created and verified {@link ScanForm}. - */ - static create(params: Object): Promise; - - /** - * The ScanForm List is a paginated list of all ScanForm objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The `has_more` attribute indicates whether additional pages can be requested. - * The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where the next page begins. - * - * @see https://docs.easypost.com/docs/scan-form#retrieve-all-scanforms - * - * @param {object} params The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link ScanForm scanforms} and pagination information. - */ - static all( - params?: IScanFormListParameters, - ): Promise<{ scan_forms: ScanForm[]; has_more: boolean }>; - - /** - * A ScanForm can be retrieved by either its id or reference. - * However, it is recommended to use EasyPost's provided identifiers because uniqueness on reference is not enforced. - * - * @see https://docs.easypost.com/docs/scan-form#retrieve-a-scanform - * - * @param {string} scanFormId Unique, begins with "sf_". - */ - static retrieve(scanFormId: string): Promise; - - /** - * Retrieve the next page of {@link ScanForm scan forms}. - * - * This automatically reuses the parameters from the previous call or the original {@link ScanForm.all} call. - * - * @see https://docs.easypost.com/docs/scan-form#retrieve-all-scanforms - * - * @param {Object} scanforms - The previous page of scan forms (the response from the last {@link ScanForm.getNextPage} or {@link ScanForm.all} call). - * @param {number} [pageSize] - The number of scan forms to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link ScanForm scan forms} and pagination information. - */ - static getNextPage( - scanforms: Object, - pageSize?: number, - ): Promise<{ scan_forms: ScanForm[]; has_more: boolean }>; -} - -export type { ScanForm }; diff --git a/types/ScanForm/ScanFormCreateParameters.d.ts b/types/ScanForm/ScanFormCreateParameters.d.ts deleted file mode 100644 index e5cc97a1e..000000000 --- a/types/ScanForm/ScanFormCreateParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { DeepPartial } from '../utils'; -import { IShipmentCreateParameters } from '../Shipment'; - -export declare interface IScanFormCreateParameters { - shipments: Array>; -} diff --git a/types/ScanForm/ScanFormListParameters.d.ts b/types/ScanForm/ScanFormListParameters.d.ts deleted file mode 100644 index f2b5f77ad..000000000 --- a/types/ScanForm/ScanFormListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/scan-form#retrieve-all-scanforms - */ -export declare interface IScanFormListParameters extends IAllMethodParameters {} diff --git a/types/ScanForm/index.d.ts b/types/ScanForm/index.d.ts deleted file mode 100644 index 3851190d8..000000000 --- a/types/ScanForm/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ScanForm'; diff --git a/types/Shipment/Form.d.ts b/types/Shipment/Form.d.ts deleted file mode 100644 index a6c7e14ca..000000000 --- a/types/Shipment/Form.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; - -/** - * @see https://docs.easypost.com/docs/shipments/forms#form-object - */ -export declare interface IForm extends IObjectWithId<'Form'>, IDatedObject { - /** - * The type of form that we returned, can be one of "cn22", "cod_return_label", "commercial_invoice", "high_value_report", "label_qr_code", "nafta_certificate_of_origin", "order_summary", "return_packing_slip", "rma_qr_code" - */ - form_type: - | 'cn22' - | 'cod_return_label' - | 'commercial_invoice' - | 'high_value_report' - | 'label_qr_code' - | 'nafta_certificate_of_origin' - | 'order_summary' - | 'return_packing_slip' - | 'rma_qr_code'; - - /** - * The address we return the form back at - */ - form_url: string; - - /** - * If we have submitted the form to the carrier on behalf of the customer - */ - submitted_electronically: boolean; -} diff --git a/types/Shipment/Message.d.ts b/types/Shipment/Message.d.ts deleted file mode 100644 index 042733380..000000000 --- a/types/Shipment/Message.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * When rating a Shipment or Pickup, some carriers may fail to generate rates. - * These failures are returned as part of the Shipment or Pickup as part of their messages attribute, and follow a common object structure. - * - * It is important to note that the message value for any member of this list comes directly from the carrier, not from EasyPost. - * This means that if you see an authentication or other non-shipping error here, it is not an issue between you and EasyPost, it is an issue between you and the carrier, or an issue with the given data. - * - * @see https://docs.easypost.com/docs/shipments/messages#message-object - */ -export declare interface IMessage { - /** - * the name of the carrier generating the error, e.g. "UPS" - */ - carrier: string; - - /** - * the category of error that occurred. Most frequently "rate_error" - */ - type: string; - - /** - * the string from the carrier explaining the problem - */ - message: string; - - /** - * the account id of the carrier. Useful if you have multiple accounts with the same carrier - */ - carrier_account_id: string; -} diff --git a/types/Shipment/Options/LabelFormat.d.ts b/types/Shipment/Options/LabelFormat.d.ts deleted file mode 100644 index cc3a84031..000000000 --- a/types/Shipment/Options/LabelFormat.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare type LabelFormat = 'PNG' | 'PDF' | 'ZPL' | 'EPL2'; diff --git a/types/Shipment/Options/Options.d.ts b/types/Shipment/Options/Options.d.ts deleted file mode 100644 index 3d2668626..000000000 --- a/types/Shipment/Options/Options.d.ts +++ /dev/null @@ -1,365 +0,0 @@ -import { LabelFormat } from './LabelFormat'; -import { TPrintCustomCode } from './PrintCustomCode'; - -/** - * Shipments can have a variety of additional options which you can specify when creating a shipment. - * The Options object can be populated with the keys below. - * - * @see https://docs.easypost.com/docs/shipments/options#options-object - */ -export declare interface IOptions { - /** - * Setting this option to true, will add an additional handling charge. - * An Additional Handling charge may be applied to the following: - * - Any article that is encased in an outside shipping container made of metal or wood. - * - Any item, such as a barrel, drum, pail or tire, that is not fully encased in a corrugated cardboard shipping container. - * - Any package with the longest side exceeding 60 inches or its second longest side exceeding 30 inches. - * - Any package with an actual weight greater than 70 pounds. - */ - additional_handling?: boolean | null; - - /** - * Setting this option to "0", will allow the minimum amount of address information to pass the validation check. - * Only for USPS postage. - */ - address_validation_level?: string | null; - - /** - * Set this option to true if your shipment contains alcohol. - * - UPS - only supported for US Domestic shipments - * - FedEx - only supported for US Domestic shipments - * - Canada Post - Requires adult signature 19 years or older. If you want adult signature 18 years or older, instead use delivery_confirmation: ADULT_SIGNATURE - */ - alcohol?: boolean | null; - - /** - * Setting this option to true will indicate to the carrier to prefer delivery by drone, if the carrier supports drone delivery. - */ - by_drone?: boolean | null; - - /** - * Setting this to true will add a charge to reduce carbon emissions. - */ - carbon_neutral?: boolean | null; - - /** - * Adding an amount will have the carrier collect the specified amount from the recipient. - */ - cod_amount?: string | null; - - /** - * Method for payment. "CASH", "CHECK", "MONEY_ORDER" - */ - cod_method?: 'CASH' | 'CHECK' | 'MONEY_ORDER' | null; - - /** - * The ID of the Address to which the COD payment should be returned. - * Defaults to the origin address. - * Only available on FedEx shipments. - */ - cod_address_id?: string | null; - - /** - * A description of the content of the shipment. - */ - content_description?: string | null; - - /** - * Which currency this shipment will show for rates if carrier allows. - */ - currency?: string | null; - - /** - * If you want to request a signature, you can pass "ADULT_SIGNATURE" or "SIGNATURE". - * You may also request "NO_SIGNATURE" to leave the package at the door. - * - All - some options may be limited for international shipments - * - FedEx - "INDIRECT_SIGNATURE" is also an option - * - USPS - additional options - * - "ADULT_SIGNATURE_RESTRICTED" - * - "SIGNATURE_RESTRICTED" - * - Canada Post - "DO_NOT_SAFE_DROP" - Tells the carrier to not hide the package ("safe drop"). - * - GSO - "STANDARD_SIGNATURE". - * - DHL Express - option mapping - * - "SIGNATURE" - DHL Express Direct Signature - * - "NO_SIGNATURE" - DHL Express Signature Release - */ - delivery_confirmation?: - | 'ADULT_SIGNATURE' - | 'SIGNATURE' - | 'NO_SIGNATURE' - | 'INDIRECT_SIGNATURE' - | 'ADULT_SIGNATURE_RESTRICTED' - | 'SIGNATURE_RESTRICTED' - | null; - - /** - * Method the customer will use to transfer the package to the carrier. - * "REGULAR_PICKUP", "SCHEDULED_PICKUP", "RETAIL_LOCATION", "STATION" or "DROP_BOX". - * Supported carriers and their corresponding carrier dropoff codes: - * - FedEx - * - "REGULAR_PICKUP" - "REGULAR_PICKUP" (default) - * - "SCHEDULED_PICKUP" - "REQUEST_COURIER" - * - "RETAIL_LOCATION" - "BUSINESS_SERVICE_CENTER" - * - "STATION" - "STATION" - * - "DROP_BOX" - "DROP_BOX" - */ - dropoff_type?: - | 'REGULAR_PICKUP' - | 'SCHEDULED_PICKUP' - | 'RETAIL_LOCATION' - | 'STATION' - | 'DROP_BOX' - | 'REQUEST_COURIER' - | 'BUSINESS_SERVICE_CENTER' - | null; - - /** - * Package contents contain dry ice. - * - UPS - Need dry_ice_weight to be set - * - UPS MailInnovations - Need dry_ice_weight to be set - * - FedEx - Need dry_ice_weight to be set - */ - dry_ice?: boolean | null; - - /** - * If the dry ice is for medical use, set this option to true. - * - UPS - Need dry_ice_weight to be set - * - UPS MailInnovations - Need dry_ice_weight to be set - */ - dry_ice_medical?: boolean | null; - - /** - * Weight of the dry ice in ounces. - * - UPS - Need dry_ice to be set - * - UPS MailInnovations - Need dry_ice to be set - * - FedEx - Need dry_ice to be set - */ - dry_ice_weight?: string | null; - - /** - * Setting duty_payment type to bill the correct account for purchasing postage. - * This option is only available with FedEx and UPS. - * - type - (string) Supported values are "THIRD_PARTY", and "RECEIVER". - * - account - (string) Setting account number. - * - country - (string) Setting country code that the account is based in. - * - postal_code - (string) Setting postal code that the account is based in. - */ - duty_payment: object | null; - - /** - * Possible values "ADDRESS_SERVICE_REQUESTED", "FORWARDING_SERVICE_REQUESTED", "CHANGE_SERVICE_REQUESTED", "RETURN_SERVICE_REQUESTED", "LEAVE_IF_NO_RESPONSE" - */ - endorsement?: - | 'ADDRESS_SERVICE_REQUESTED' - | 'FORWARDING_SERVICE_REQUESTED' - | 'CHANGE_SERVICE_REQUESTED' - | 'RETURN_SERVICE_REQUESTED' - | 'LEAVE_IF_NO_RESPONSE' - | null; - - /** - * Specify the responsible EndShipper for the shipment by passing in an EndShipper ID. - */ - end_shipper_id: string | null; - - /** - * Additional cost to be added to the invoice of this shipment. - * Only applies to UPS currently. - */ - freight_charge?: number | null; - - /** - * This is to designate special instructions for the carrier like "Do not drop!". - */ - handling_instructions?: string | null; - - /** - * Dangerous goods indicator. - * Possible values are "PRIMARY_CONTAINED", "PRIMARY_PACKED", "PRIMARY", "SECONDARY_CONTAINED", "SECONDARY_PACKED", "SECONDARY", "ORMD", "LIMITED_QUANTITY", "LITHIUM". - * Applies to USPS, FedEx and DHL eCommerce. - */ - hazmat?: - | 'PRIMARY_CONTAINED' - | 'PRIMARY_PACKED' - | 'PRIMARY' - | 'SECONDARY_CONTAINED' - | 'SECONDARY_PACKED' - | 'SECONDARY' - | 'ORMD' - | 'LIMITED_QUANTITY' - | 'LITHIUM' - | null; - - /** - * Package will wait at carrier facility for pickup. - */ - hold_for_pickup?: boolean | null; - - /** - * Incoterm negotiated for shipment. - * Supported values are "EXW", "FCA", "CPT", "CIP", "DAT", "DAP", "DDP", "FAS", "FOB", "CFR", and "CIF". - * Setting this value to anything other than "DDP" will pass the cost and responsibility of duties on to the recipient of the package(s), as specified by Incoterms rules - */ - incoterm?: - 'EXW' | 'FCA' | 'CPT' | 'CIP' | 'DAT' | 'DAP' | 'DDP' | 'FAS' | 'FOB' | 'CFR' | 'CIF' | null; - - /** - * This will print an invoice number on the postage label. - */ - invoice_number?: string | null; - - /** - * Set the date that will appear on the postage label. - * Accepts ISO 8601 formatted string including time zone offset. - * EasyPost stores all dates as UTC time. - */ - label_date?: string | null; - - /** - * Supported label formats include "PNG", "PDF", "ZPL", and "EPL2". - * "PNG" is the only format that allows for conversion. - * - * @see https://docs.easypost.com/docs/shipments#converting-the-label-format-of-a-shipment - */ - label_format?: LabelFormat | null; - - /** - * Whether or not the parcel can be processed by the carriers equipment. - */ - machinable?: boolean | null; - - /** - * Setting payment type to bill the correct account for purchasing postage. - */ - payment: { - /** - * Supported values are "SENDER", "THIRD_PARTY", "RECEIVER", "COLLECT". Defaults to SENDER. - */ - type?: 'SENDER' | 'THIRD_PARTY' | 'RECEIVER' | 'COLLECT' | null; - - /** - * Setting account number. - * Required for RECEIVER and THIRD_PARTY. - */ - account?: string | null; - - /** - * Setting country code that the account is based in. - * Required for THIRD_PARTY. - */ - country?: string | null; - - /** - * Setting postal code that the account is based in. - * Required for RECEIVER and THIRD_PARTY. - */ - postal_code?: string | null; - }; - - /** - * The earliest a package should be picked up. Supported carriers vary. - */ - pickup_min_datetime: string | null; - - /** - * The latest a package should be picked up. Supported carriers vary. - */ - pickup_max_datetime: string | null; - - /** - * You can optionally print custom messages on labels. - * The locations of these fields show up on different spots on the carrier's labels. - */ - print_custom_1?: string | null; - - /** - * An additional message on the label. Same restrictions as print_custom_1 - */ - print_custom_2?: string | null; - - /** - * An additional message on the label. Same restrictions as print_custom_1 - */ - print_custom_3?: string | null; - - /** - * Create a barcode for this custom reference if supported by carrier. - */ - print_custom_1_barcode?: boolean | null; - - /** - * Create a barcode for this custom reference if supported by carrier. - */ - print_custom_2_barcode?: boolean | null; - - /** - * Create a barcode for this custom reference if supported by carrier. - */ - print_custom_3_barcode?: boolean | null; - - /** - * Specify the type of print_custom_1. - */ - print_custom_1_code?: TPrintCustomCode | null; - - /** - * Specify the type of print_custom_2. - */ - print_custom_2_code?: TPrintCustomCode | null; - - /** - * Specify the type of print_custom_3. - */ - print_custom_3_code?: TPrintCustomCode | null; - - /** - * Set this value to true for delivery on Saturday. - * When setting the saturday_delivery option, you will only get rates for services that are eligible for saturday delivery. - * If no services are available for saturday delivery, then you will not be returned any rates. - * You may need to create 2 shipments, one with the saturday_delivery option set on one without to get all your eligible rates. - */ - saturday_delivery?: boolean | null; - - /** - * This option allows you to request restrictive rates from USPS. - * Can set to 'USPS.MEDIAMAIL' or 'USPS.LIBRARYMAIL'. - */ - special_rates_eligibility?: 'USPS.MEDIAMAIL' | 'USPS.LIBRARYMAIL' | null; - - /** - * You can use this to override the hub ID you have on your account. - */ - smartpost_hub?: string | null; - - /** - * The manifest ID is used to group SmartPost packages onto a manifest for each trailer. - */ - smartpost_manifest?: string | null; - - /** - * A reference ID for aggregating DHL eCommerce billing data. - */ - billing_ref?: string | null; - - /** - * Certified Mail provides the sender with a mailing receipt and, upon request, electronic verification that an article was delivered or that a delivery attempt was made. - */ - certified_mail?: boolean | null; - - /** - * Registered Mail is the most secure service that the USPS offers. - * It incorporates a system of receipts to monitor the movement of the mail from the point of acceptance to delivery - */ - registered_mail?: boolean | null; - - /** - * The value of the package contents - */ - registered_mail_amount?: number | null; - - /** - * An electronic return receipt may be purchased at the time of mailing and provides a shipper with evidence of delivery (to whom the mail was delivered and date of delivery), and information about the recipient's actual delivery address. - * Only applies to the USPS. - */ - return_receipt?: boolean | null; -} diff --git a/types/Shipment/Options/PrintCustomCode.d.ts b/types/Shipment/Options/PrintCustomCode.d.ts deleted file mode 100644 index 4933056eb..000000000 --- a/types/Shipment/Options/PrintCustomCode.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * - FedEx - * - (null) - If print_custom_1_code is not provided it defaults to Customer Reference - * - PO - Purchase Order Number - * - DP - Department Number - * - RMA - Return Merchandise Authorization - * - UPS - * - AJ - Accounts Receivable Customer Account - * - AT - Appropriation Number - * - BM - Bill of Lading Number - * - 9V - Collect on Delivery (COD) Number - * - ON - Dealer Order Number - * - DP - Department Number - * - 3Q - Food and Drug Administration (FDA) Product Code - * - IK - Invoice Number - * - MK - Manifest Key Number - * - MJ - Model Number - * - PM - Part Number - * - PC - Production Code - * - PO - Purchase Order Number - * - RQ - Purchase Request Number - * - RZ - Return Authorization Number - * - SA - Salesperson Number - * - SE - Serial Number - * - ST - Store Number - * - TN - Transaction Reference Number - * - EI - Employer's ID Number - * - TJ - Federal Taxpayer ID No. - */ -export declare type TPrintCustomCode = - | 'PO' - | 'DP' - | 'RMA' - | 'AJ' - | 'AT' - | 'BM' - | '9V' - | 'ON' - | '3Q' - | 'IK' - | 'MK' - | 'MJ' - | 'PM' - | 'PC' - | 'RQ' - | 'RZ' - | 'SA' - | 'SE' - | 'ST' - | 'TN' - | 'EI' - | 'TJ'; diff --git a/types/Shipment/Options/index.d.ts b/types/Shipment/Options/index.d.ts deleted file mode 100644 index 349426b0d..000000000 --- a/types/Shipment/Options/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './LabelFormat'; -export * from './Options'; -export * from './PrintCustomCode'; diff --git a/types/Shipment/PostageLabel.d.ts b/types/Shipment/PostageLabel.d.ts deleted file mode 100644 index 9f8717b97..000000000 --- a/types/Shipment/PostageLabel.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; - -/** - * PostageLabel Object - */ -export declare interface IPostageLabel extends IObjectWithId<'PostageLabel'>, IDatedObject { - date_advance: number; - integrated_form: string; - label_date: string; - label_resolution: number; - label_size: string; - label_type: string; - label_url: string; - label_file_type: string; - label_pdf_url: string; - label_epl2_url: string; - label_zpl_url: string; -} diff --git a/types/Shipment/Shipment.d.ts b/types/Shipment/Shipment.d.ts deleted file mode 100644 index 0485fa593..000000000 --- a/types/Shipment/Shipment.d.ts +++ /dev/null @@ -1,368 +0,0 @@ -import { IAddress } from '../Address'; -import { IDatedObject, IObjectWithId } from '../base'; -import { TBatchStatus } from '../Batch'; -import { ICustomsInfo } from '../Customs'; -import { IFee } from '../Fee'; -import { IInsurance } from '../Insurance'; -import { IParcel } from '../Parcel'; -import { IRate } from '../Rate'; -import { IScanForm } from '../ScanForm'; -import { ITracker } from '../Tracker'; -import { IForm } from './Form'; -import { IMessage } from './Message'; -import { IOptions, LabelFormat } from './Options'; -import { IPostageLabel } from './PostageLabel'; -import { IShipmentCreateParameters } from './ShipmentCreateParameters'; -import { IShipmentListParameters } from './ShipmentListParameters'; -import { ITaxIdentifier } from './TaxIdentifier'; - -/** - * The workhorse of the EasyPost API, a Shipment is made up of a "to" and "from" Address, the Parcel being shipped, and any customs forms required for international deliveries. - * Once created a Shipment object is used to retrieve shipping Rates and purchase a label. - * - * A Shipment created with a valid to_address, from_address, and parcel will automatically populate its rates attribute. - * - * @see https://docs.easypost.com/docs/shipments#shipment-object - */ -export declare interface IShipment extends IObjectWithId<'Shipment'>, IDatedObject { - /** - * An optional field that may be used in place of id in other API endpoints - */ - reference?: string | null; - - /** - * The destination address - */ - to_address: IAddress; - - /** - * The origin address - */ - from_address: IAddress; - - /** - * The shipper's address, defaults to from_address - */ - return_address?: IAddress | null; - - /** - * The buyer's address, defaults to to_address - */ - buyer_address?: IAddress | null; - - /** - * The dimensions and weight of the package - */ - parcel: IParcel; - - /** - * Information for the processing of customs - */ - customs_info?: ICustomsInfo | null; - - /** - * Tax identifiers for the shipment - */ - tax_identifiers?: ITaxIdentifier[]; - - /** - * Document created to manifest and scan multiple shipments - */ - scan_form: IScanForm; - - /** - * All associated Form objects - */ - forms: IForm[]; - - /** - * The associated Insurance object - */ - insurance: IInsurance; - - /** - * All associated Rate objects - */ - rates: IRate[]; - - /** - * The specific rate purchased for the shipment, or null if unpurchased or purchased through another mechanism - */ - selected_rate: IRate; - - /** - * The associated PostageLabel object - */ - postage_label: IPostageLabel; - - /** - * Any carrier errors encountered during rating, discussed in more depth below - */ - messages: IMessage[]; - - /** - * All the options passed to the shipment, discussed in more depth below - */ - options?: IOptions | null; - - /** - * Set true to create as a return, discussed in more depth below - */ - is_return?: boolean | null; - - /** - * If purchased, the tracking code will appear here as well as within the Tracker object - */ - tracking_code: string; - - /** - * The USPS zone of the shipment, if purchased with USPS - */ - usps_zone: string; - - /** - * The current tracking status of the shipment - */ - status: string; - - /** - * The associated Tracker object - */ - tracker: ITracker; - - /** - * The associated Fee objects charged to the billing user account - */ - fees: IFee[]; - - /** - * The current status of the shipment refund process. Possible values are "submitted", "refunded", "rejected". - */ - refund_status: 'submitted' | 'refunded' | 'rejected'; - - /** - * The ID of the batch that contains this shipment, if any - */ - batch_id: string; - - /** - * The current status of the associated BatchShipment - */ - batch_status: TBatchStatus; - - /** - * The current message of the associated BatchShipment - */ - batch_message: string; -} - -declare class Shipment implements IShipment { - public constructor(input: IShipmentCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'Shipment'; - reference?: string | null; - to_address: IAddress; - from_address: IAddress; - return_address?: IAddress | null; - buyer_address?: IAddress | null; - parcel: IParcel; - customs_info?: ICustomsInfo | null; - scan_form: IScanForm; - forms: IForm[]; - insurance: IInsurance; - rates: IRate[]; - selected_rate: IRate; - postage_label: IPostageLabel; - messages: IMessage[]; - options?: IOptions | null; - is_return?: boolean | null; - tracking_code: string; - usps_zone: string; - status: string; - tracker: ITracker; - fees: IFee[]; - refund_status: 'submitted' | 'refunded' | 'rejected'; - batch_id: string; - batch_status: TBatchStatus; - batch_message: string; - created_at: string; - updated_at: string; - - /** - * A Shipment is almost exclusively a container for other objects, and thus a Shipment may reuse many of these objects. - * Additionally, all the objects contained within a Shipment may be created at the same time. - * - * The origin/destination Address and Parcel are required for rating. - * CustomsInfo is required to rate an international Shipment, this includes when the destination is a US Territory. - * The associated Tracker, Fees, and Rates are generated by EasyPost and cannot be modified by the user. - * - * You can limit the CarrierAccounts to use for rating by passing the carrier_accounts parameter. - * - * @see https://docs.easypost.com/docs/shipments#create-a-shipment - * - * @param {Object} params The parameters to create an {@link Shipment} with. - * @returns {Promise} The created {@link Shipment}. - */ - static create(params: Object): Promise; - - /** - * The Shipment List is a paginated list of all Shipment objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The `has_more` attribute indicates whether additional pages can be requested. - * The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where the next page begins. - * - * @see https://docs.easypost.com/docs/shipments#retrieve-all-shipments - * - * @param params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Shipment shipments} and pagination information. - */ - static all( - params?: IShipmentListParameters, - ): Promise<{ shipments: Shipment[]; has_more: boolean }>; - - /** - * A Shipment can be retrieved by either its id or reference. - * However, it is recommended to use EasyPost's provided identifiers because uniqueness on reference is not enforced. - * - * @see https://docs.easypost.com/docs/shipments#retrieve-a-shipment - * - * @param {string} id Unique, begins with "shp_". - * @returns {Promise} The created {@link Shipment}. - */ - static retrieve(id: string): Promise; - - /** - * To purchase a Shipment you only need to specify the Rate to purchase. - * This operation populates the `tracking_code` and `postage_label` attributes. - * The default image format of the associated PostageLabel is PNG. - * To change this default see the label_format option. - * - * Additionally, insurance may be added during the purchase. - * To specify an amount to insure, pass the insurance attribute as a string. - * The currency of all insurance is USD. - * - * @see https://docs.easypost.com/docs/shipments#buy-a-shipment - * - * @param id shipment id (begins with "shp_"). - * @param rate rate id (begins with "rate_") or rate object. - * @param insuranceAmount amount to insure the shipment for. - * @param endShipperId The ID of the end shipper to purchase the shipment with. - * @returns {Promise} The created {@link Shipment}. - */ - static buy( - id: string, - rate: string | IRate, - insuranceAmount?: number, - endShipperId?: string, - ): Promise; - - /** - * Refunding a Shipment is available for many carriers supported by EasyPost. - * Once the refund has been submitted, refund_status attribute of the Shipment will be populated with one of the possible values: "submitted", "refunded", "rejected". - * The most common initial status is "submitted". - * Many carriers require that the refund be processed before the `refund_status` will move to "refunded". - * The length of this process depends on the carrier, but no greater than 30 days. - * - * Refunds created very shortly after a label is generated may be improperly flagged as invalid, but you may retry a refund with the "rejected" status by submitting the same request again. - * Carriers that are bill-on-scan tend to have refunds attempts return as "not_applicable", which will not change with multiple retries. - * - * @see https://docs.easypost.com/docs/shipments/shipping-refund#refund-a-shipment - * - * @param id shipment id (begins with "shp_"). - * @returns {Promise} The created {@link Shipment}. - */ - static refund(id: string): Promise; - - /** - * - * @param carriers a list of carriers to filter rates for. - * @param services a list of services to filter rates for. - * @returns {Rate} The lowest {@link Rate}. - */ - lowestRate(carriers?: string[], services?: string[]): IRate; - - /** - * A Shipment's PostageLabel can be converted from PNG to other formats. - * If the PostageLabel was originally generated in a format other than PNG it cannot be converted. - * - * @see https://docs.easypost.com/docs/shipments#converting-the-label-format-of-a-shipment - * - * @param id shipment id (begins with "shp_"). - * @param format Format of the label ("PNG", "PDF", "ZPL", and "EPL2"). - * @returns {Promise} The created {@link Shipment}. - */ - static convertLabelFormat(id: string, format: LabelFormat): Promise; - - /** - * You can update the Rates of a Shipment at any time. - * This operation respects the `carrier_accounts` attribute. - * - * @see https://docs.easypost.com/docs/shipments/rates#regenerate-rates-for-a-shipment - * - * @param id shipment id (begins with "shp_"). - * @returns {Promise} The created {@link Shipment}. - */ - static regenerateRates(id: string): Promise; - - /** - * Insuring your Shipment is as simple as sending us the value of the contents. - * We charge 1% of the value, with a $1 minimum, and handle all the claims. - * All our claims are paid out within 10 days. - * - * To buy insurance, first purchase the Shipment, then make the insurance call before the package begins being handled by the carrier. - * - * @see https://docs.easypost.com/docs/shipments/shipping-insurance#insure-a-shipment - * - * @param id shipment id (begins with "shp_"). - * @param amount amount to insure the shipment for. - * @returns {Promise} The created {@link Shipment}. - */ - static insure(id: string, amount: number): Promise; - - /** - * Generate a specific type of form for the Shipment, using the provided form options. - * - * @param id shipment id (begins with "shp_"). - * @param formType The type of form to generate. - * @param formOptions Additional options to use when generating the form. - * @returns {Promise} The created {@link Shipment}. - */ - static generateForm(id: string, formType: string, formOptions?: object): Promise; - - /** - * Retrieve the estimated delivery date of each Rate via SmartRate. - * - * @param id shipment id (begins with "shp_"). - * @param plannedShipDate The planned ship date in format YYYY-MM-DD - * @returns {Promise>} The array of estimated delivery dates and rates. - */ - static retrieveEstimatedDeliveryDate(id: string, plannedShipDate: string): Promise>; - - /** - * Retrieve a recommended ship date for a {@link Shipment shipment} via the Precision Shipping API, based on a specific desired delivery date. - * @param id - The ID of the shipment to retrieve the recommended ship date for. - * @param desiredDeliveryDate - The desired delivery date for the shipment. - * @returns {Array} - An array of the recommended ship date and rates. - */ - static recommendShipDate(id: string, desiredDeliveryDate: string): Promise>; - - /** - * Retrieve the next page of {@link Shipment shipments}. - * - * This automatically reuses the parameters from the previous call or the original {@link Shipment.all} call. - * - * @see https://docs.easypost.com/docs/shipments#retrieve-all-shipments - * - * @param {Object} shipments - The previous page of shipments (the response from the last {@link Shipment.getNextPage} or {@link Shipment.all} call). - * @param {number} [pageSize] - The number of shipments to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Shipment shipments} and pagination information. - */ - static getNextPage( - shipments: Object, - pageSize?: number, - ): Promise<{ shipments: Shipment[]; has_more: boolean }>; -} - -export type { Shipment }; diff --git a/types/Shipment/ShipmentCreateParameters.d.ts b/types/Shipment/ShipmentCreateParameters.d.ts deleted file mode 100644 index 3aae0378e..000000000 --- a/types/Shipment/ShipmentCreateParameters.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { IAddressCreateParameters } from '../Address'; -import { ICustomsInfo } from '../Customs/CustomsInfo/CustomsInfo'; -import { IParcelCreateParameters } from '../Parcel/ParcelCreateParameters'; -import { DeepPartial } from '../utils'; -import { IOptions } from './Options'; -import { ITaxIdentifier } from './TaxIdentifier'; - -export declare interface IShipmentCreateParameters { - reference?: string | null; - to_address: DeepPartial | string; - from_address: DeepPartial | string; - parcel: Partial | string; - - /** - * optional array of ids that begin with "ca_" - */ - carrier_accounts?: string[] | null; - - customs_info?: DeepPartial | null; - tax_identifiers?: ITaxIdentifier[] | null; - options?: DeepPartial | null; - line_items?: Array<{ - total_line_value: string; - item_description: string; - }>; -} diff --git a/types/Shipment/ShipmentListParameters.d.ts b/types/Shipment/ShipmentListParameters.d.ts deleted file mode 100644 index 8117a2c1a..000000000 --- a/types/Shipment/ShipmentListParameters.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/shipments#retrieve-all-shipments - */ -export declare interface IShipmentListParameters extends IAllMethodParameters { - /** - * Only include Shipments that have been purchased. - * Default is true - */ - purchased?: boolean | null; - - /** - * Also include Shipments created by Child Users. - * Defaults to false - */ - include_children?: boolean | null; -} diff --git a/types/Shipment/TaxIdentifier.d.ts b/types/Shipment/TaxIdentifier.d.ts deleted file mode 100644 index 277170f15..000000000 --- a/types/Shipment/TaxIdentifier.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Interface representing a TaxIdentifier object, an embedded object within a Shipment. - * - * @see https://docs.easypost.com/docs/shipments/tax-identifiers - */ -export declare interface ITaxIdentifier { - /** The entity type (e.g., "SENDER", "RECEIVER"). */ - entity: string; - - /** The tax identification number. */ - tax_id: string; - - /** The type of tax identifier (e.g., "IOSS", "VAT", "EIN", etc.). */ - tax_id_type: string; - - /** The two-letter ISO country code of the country that issued the tax ID. */ - issuing_country: string; -} diff --git a/types/Shipment/index.d.ts b/types/Shipment/index.d.ts deleted file mode 100644 index 1dd95a59d..000000000 --- a/types/Shipment/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './Form'; -export * from './Message'; -export * from './Options'; -export * from './PostageLabel'; -export { IRate, Rate } from '../Rate'; -export * from './Shipment'; -export * from './ShipmentCreateParameters'; -export * from './ShipmentListParameters'; -export * from './TaxIdentifier'; diff --git a/types/SmartRate/SmartRate.d.ts b/types/SmartRate/SmartRate.d.ts deleted file mode 100644 index 12e1fb5d8..000000000 --- a/types/SmartRate/SmartRate.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * The SmartRate class interacts with the SmartRate API to provide optimized shipping rates and estimates. - * - * @see https://docs.easypost.com/docs/smartrate - */ -declare class SmartRate { - /** - * Retrieve the estimated delivery date of each carrier-service level combination via the Smart Deliver By API, based on a specific ship date and origin-destination postal code pair. - * @param params - The parameters to estimate the delivery date with. - * @returns {Object} - Estimates and related metadata. - */ - static estimateDeliveryDate(params: object): object; - - /** - * Retrieve a recommended ship date for each carrier-service level combination via the Smart Deliver On API, based on a specific delivery date and origin-destination postal code pair. - * @param params - The parameters to recommend the ship date with. - * @returns {Object} - Recommendation and related metadata. - */ - static recommendShipDate(params: object): object; -} - -export type { SmartRate }; diff --git a/types/SmartRate/index.d.ts b/types/SmartRate/index.d.ts deleted file mode 100644 index e8db4933d..000000000 --- a/types/SmartRate/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './SmartRate'; diff --git a/types/Tracker/CarrierDetail.d.ts b/types/Tracker/CarrierDetail.d.ts deleted file mode 100644 index 9d3136878..000000000 --- a/types/Tracker/CarrierDetail.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { IBaseObject } from '../base'; -import { ITrackingLocation } from './TrackingLocation'; - -/** - * @see https://docs.easypost.com/docs/trackers#carrierdetail-object - */ -export declare interface ICarrierDetail extends IBaseObject<'CarrierDetail'> { - /** - * The service level the associated shipment was shipped with (if available) - */ - service: string; - - /** - * The type of container the associated shipment was shipped in (if available) - */ - container_type: string; - - /** - * The estimated delivery date as provided by the carrier, in the local time zone (if available) - */ - est_delivery_date_local: string; - - /** - * The estimated delivery time as provided by the carrier, in the local time zone (if available) - */ - est_delivery_time_local: string; - - /** - * The location from which the package originated, stringified for presentation (if available) - */ - origin_location: string; - - /** - * The location from which the package originated, broken down by city/state/country/zip (if available) - */ - origin_tracking_location: ITrackingLocation; - - /** - * The location to which the package is being sent, stringified for presentation (if available) - */ - destination_location: string; - - /** - * The location to which the package is being sent, broken down by city/state/country/zip (if available) - */ - destination_tracking_location: ITrackingLocation; - - /** - * The date and time the carrier guarantees the package to be delivered by (if available) - */ - guaranteed_delivery_date: string; - - /** - * The alternate identifier for this package as provided by the carrier (if available) - */ - alternate_identifier: string; - - /** - * The date and time of the first attempt by the carrier to deliver the package (if available) - */ - initial_delivery_attempt: string; -} diff --git a/types/Tracker/Tracker.d.ts b/types/Tracker/Tracker.d.ts deleted file mode 100644 index 18e650b8a..000000000 --- a/types/Tracker/Tracker.d.ts +++ /dev/null @@ -1,202 +0,0 @@ -import { IDatedObject, IObjectWithId } from '../base'; -import { IFee } from '../Fee'; -import { ICarrierDetail } from './CarrierDetail'; -import { ITrackerCreateParameters } from './TrackerCreateParameters'; -import { ITrackerListParameters } from './TrackerListParameters'; -import { ITrackerStatus } from './TrackerStatus'; -import { ITrackerStatusDetail } from './TrackerStatusDetail'; -import { ITrackingDetail } from './TrackingDetail'; - -/** - * A Tracker object contains all the tracking information for a package. - * A Tracker is created automatically whenever you buy a Shipment through EasyPost. - * If you don't use EasyPost to purchase your shipping labels, you can still track packages through our API by creating a Tracker object directly. - * Each Tracker is continually updated in the background as the package moves through its life cycle, regardless of whether or not the label was purchased through EasyPost. - * - * After creation, a Tracker object will be updated periodically based on when the carrier provides EasyPost with new tracking information. - * This information can be consumed by using our webhooks infrastructure. - * Every time a Tracker is updated a webhook Event will be sent. - * - * The Tracker object contains both the current information about the package and previous updates. - * All the previous updates are stored in the tracking_details array. - * Each TrackingDetail object contains the status, the message from the carrier, and a TrackingLocation. - * - * The TrackingLocation contains city, state, country, and zip information about the location where the package was scanned. - * The information each carrier provides is different, so some carriers may not make use of all these fields. - * - * Some Tracker objects may also contain a CarrierDetail, which stores some additional information about the Tracker that the carrier has made available to EasyPost. - * The CarrierDetail object contains the service and container_type of the package. - * Additionally, it also stores the `est_delivery_date_local` and `est_delivery_time_local`, which provide information about the local delivery time. - * - * It's worth noting that tracking_codes are not globally unique. - * Each carrier promises uniqueness for a given `tracking_code` for a certain period of time, but the length of time varies greatly based on the specific carrier and service level. - * The carriers do eventually recycle `tracking_codes`, and for this reason enforcing uniqueness on the `tracking_code` field is not recommended. - * EasyPost does, however, prevent the creation of duplicate Trackers based on tracking_code and carrier; duplicate requests by the same User will simply return the original Tracker. - * - * @see https://docs.easypost.com/docs/trackers#tracker-object - */ -export declare interface ITracker extends IObjectWithId<'Tracker'>, IDatedObject { - /** - * The tracking code provided by the carrier - */ - tracking_code: string; - - /** - * The current status of the package, possible values are "unknown", "pre_transit", "in_transit", "out_for_delivery", "delivered", "available_for_pickup", "return_to_sender", "failure", "cancelled" or "error" - */ - status: ITrackerStatus; - - /** - * Additional details about the current status, possible values are "unknown", "status_update", "departed_facility", "arrived_at_facility", "out_for_delivery", "arrived_at_destination" - */ - status_detail: ITrackerStatusDetail; - - /** - * The name of the person who signed for the package (if available) - */ - signed_by: string; - - /** - * The weight of the package as measured by the carrier in ounces (if available) - * float (oz) - */ - weight: number; - - /** - * The estimated delivery date provided by the carrier (if available) - */ - est_delivery_date: string; // TODO maybe type should be Date? - - /** - * The id of the EasyPost Shipment object associated with the Tracker (if any) - */ - shipment_id: string; - - /** - * The name of the carrier handling the shipment - */ - carrier: string; - - /** - * Array of the associated TrackingDetail objects - */ - tracking_details: ITrackingDetail[]; - - /** - * The associated CarrierDetail object (if available) - */ - carrier_detail: ICarrierDetail; - - /** - * URL to a publicly-accessible html page that shows tracking details for this tracker - */ - public_url: string; - - /** - * Array of the associated Fee objects - */ - fees: IFee[]; - - finalized: boolean; - - is_return: boolean; -} - -declare class Tracker implements ITracker { - public constructor(input: ITrackerCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'Tracker'; - tracking_code: string; - status: ITrackerStatus; - status_detail: ITrackerStatusDetail; - signed_by: string; - weight: number; - est_delivery_date: string; - shipment_id: string; - carrier: string; - tracking_details: ITrackingDetail[]; - carrier_detail: ICarrierDetail; - public_url: string; - fees: IFee[]; - finalized: boolean; - is_return: boolean; - created_at: string; - updated_at: string; - - /** - * A Tracker can be created with only a tracking_code. - * Optionally, you can provide the carrier parameter, which indicates the carrier the package was shipped with. - * If no carrier is provided, EasyPost will attempt to determine the carrier based on the tracking_code provided. - * Providing a carrier parameter is recommended, since some tracking_codes are ambiguous and may match with more than one carrier. - * In addition, not having to auto-match the carrier will significantly speed up the response time. - * - * In an effort to reduce wasted resources, EasyPost prevents the creation of duplicate Trackers. - * A Tracker is considered to be a duplicate if another Tracker with the same tracking_code and carrier was created by the same User in the last three months. - * In the case where a duplicate request is submitted, the original Tracker will be returned. - * - * @see https://docs.easypost.com/docs/trackers#create-a-tracker - * - * @param {Object} params The parameters to create an {@link Tracker} with. - * @returns {Promise} The {@link Tracker}. - */ - static create(params: Object): Promise; - - /** - * The Tracker List is a paginated list of all Tracker objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The `has_more` attribute indicates whether or not additional pages can be requested. - * The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where the next page begins. - * - * Using the Tracker List endpoint is the recommended way of retrieving a Tracker by `tracking_code` or `carrier`. - * Unlike the retrieving a Tracker using the Retrieve endpoint, which accepts an id, the List endpoint accepts the tracking_code as the search parameter. - * Normally, you'll only have one Tracker with a given `tracking_code`, but it is also possible to further filter those results by including the carrier parameter in your request. - * - * @see https://docs.easypost.com/docs/trackers#retrieve-all-trackers - * - * @param params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Tracker trackers} and pagination information. - */ - static all(params?: ITrackerListParameters): Promise<{ trackers: Tracker[]; has_more: boolean }>; - - /** - * Retrieve a Tracker by id. - * - * @param trackerId Unique, starts with "trk_" - * - * @see https://docs.easypost.com/docs/trackers#retrieve-a-tracker - * - * @param trackerId The id of tracker, starts with "trk_" - * @returns {Promise} The retrieved {@link Tracker}. - */ - static retrieve(trackerId: string): Promise; - - /** - * Retrieve the next page of {@link Tracker trackers}. - * - * This automatically reuses the parameters from the previous call or the original {@link Tracker.all} call. - * - * @see https://docs.easypost.com/docs/trackers#retrieve-all-trackers - * - * @param {Object} trackers - The previous page of trackers (the response from the last {@link Tracker.getNextPage} or {@link Tracker.all} call). - * @param {number} [pageSize] - The number of trackers to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link Tracker trackers} and pagination information. - */ - static getNextPage( - trackers: Object, - pageSize?: number, - ): Promise<{ trackers: Tracker[]; has_more: boolean }>; - - /** - * Delete a Tracker. - * - * @see https://docs.easypost.com/docs/trackers#delete-a-tracker - * - * @param {string} id - The id of the tracker to delete, starts with "trk_" - * @returns {Promise} - */ - static delete(id: string): Promise; -} - -export type { Tracker }; diff --git a/types/Tracker/TrackerCreateParameters.d.ts b/types/Tracker/TrackerCreateParameters.d.ts deleted file mode 100644 index 7a46b5275..000000000 --- a/types/Tracker/TrackerCreateParameters.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export declare interface ITrackerCreateParameters { - /** - * The tracking code associated with the package you'd like to track - */ - tracking_code: string; - - /** - * The carrier associated with the tracking_code you provided. - * The carrier will get auto-detected if none is provided - */ - carrier?: string; -} diff --git a/types/Tracker/TrackerListParameters.d.ts b/types/Tracker/TrackerListParameters.d.ts deleted file mode 100644 index cdf301653..000000000 --- a/types/Tracker/TrackerListParameters.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -export declare interface ITrackerListParameters extends IAllMethodParameters { - /** - * Only returns Trackers with the given tracking_code. - * Useful for retrieving an individual Tracker by tracking_code rather than by ID - */ - tracking_code?: string | null; - - /** - * Only returns Trackers with the given carrier value - */ - carrier?: string | null; -} diff --git a/types/Tracker/TrackerStatus.d.ts b/types/Tracker/TrackerStatus.d.ts deleted file mode 100644 index 2b2291981..000000000 --- a/types/Tracker/TrackerStatus.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export declare type ITrackerStatus = - | 'unknown' - | 'pre_transit' - | 'in_transit' - | 'out_for_delivery' - | 'delivered' - | 'available_for_pickup' - | 'return_to_sender' - | 'failure' - | 'cancelled' - | 'error'; diff --git a/types/Tracker/TrackerStatusDetail.d.ts b/types/Tracker/TrackerStatusDetail.d.ts deleted file mode 100644 index 7f7d5e3a8..000000000 --- a/types/Tracker/TrackerStatusDetail.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -export declare type ITrackerStatusDetail = - | 'address_correction' - | 'arrived_at_destination' - | 'arrived_at_facility' - | 'arrived_at_pickup_location' - | 'awaiting_information' - | 'cancelled' - | 'damaged' - | 'delayed' - | 'delivery_exception' - | 'departed_facility' - | 'departed_origin_facility' - | 'expired' - | 'failure' - | 'held' - | 'in_transit' - | 'label_created' - | 'lost' - | 'missorted' - | 'out_for_delivery' - | 'received_at_destination_facility' - | 'received_at_origin_facility' - | 'refused' - | 'return' - | 'status_update' - | 'transferred_to_destination_carrier' - | 'transit_exception' - | 'unknown' - | 'weather_delay'; diff --git a/types/Tracker/TrackingDetail.d.ts b/types/Tracker/TrackingDetail.d.ts deleted file mode 100644 index b27ff7a26..000000000 --- a/types/Tracker/TrackingDetail.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { IBaseObject } from '../base'; -import { ITrackerStatus } from './TrackerStatus'; -import { ITrackingLocation } from './TrackingLocation'; - -/** - * @see https://docs.easypost.com/docs/trackers#trackingdetail-object - */ -export declare interface ITrackingDetail extends IBaseObject<'TrackingDetail'> { - /** - * Description of the scan event - */ - message: string; - - description: string; - - /** - * Status of the package at the time of the scan event, possible values are "unknown", "pre_transit", "in_transit", "out_for_delivery", "delivered", "available_for_pickup", "return_to_sender", "failure", "cancelled" or "error" - */ - status: ITrackerStatus; - - status_detail: string; - - /** - * The timestamp when the tracking scan occurred - */ - datetime: string; - - /** - * The original source of the information for this scan event, usually the carrier - */ - source: string; - - carrier_code: string; - - /** - * The location associated with the scan event - */ - tracking_location: ITrackingLocation; -} diff --git a/types/Tracker/TrackingLocation.d.ts b/types/Tracker/TrackingLocation.d.ts deleted file mode 100644 index a094ddbc6..000000000 --- a/types/Tracker/TrackingLocation.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { IBaseObject } from '../base'; - -/** - * @see https://docs.easypost.com/docs/trackers#trackinglocation-object - */ -export declare interface ITrackingLocation extends IBaseObject<'TrackingLocation'> { - /** - * The city where the scan event occurred (if available) - */ - city: string; - - /** - * The state where the scan event occurred (if available) - */ - state: string; - - /** - * The country where the scan event occurred (if available) - */ - country: string; - - /** - * The postal code where the scan event occurred (if available) - */ - zip: string; -} diff --git a/types/Tracker/index.d.ts b/types/Tracker/index.d.ts deleted file mode 100644 index 984c3f378..000000000 --- a/types/Tracker/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './CarrierDetail'; -export * from './Tracker'; -export * from './TrackerStatus'; -export * from './TrackingDetail'; -export * from './TrackingLocation'; -export * from './TrackerCreateParameters'; -export * from './TrackerListParameters'; diff --git a/types/User/User.d.ts b/types/User/User.d.ts deleted file mode 100644 index 6afb17d31..000000000 --- a/types/User/User.d.ts +++ /dev/null @@ -1,197 +0,0 @@ -import { IObjectWithId } from '../base'; -import { IUserCreateParameters } from './UserCreateParameters'; - -/** - * The User object can be used to manage your own account and to create child accounts. - * Only a Production mode API key can be used to make requests against the Users API. - * - * Balance and recharge values on User objects are expressed in higher precision USD. - * - * @see https://docs.easypost.com/docs/users-object - */ -export declare interface IUser extends IObjectWithId<'User'> { - /** - * An optional field that may be used in place of id in other API endpoints - */ - reference?: string | null; - - /** - * The ID of the parent user object. - * Top-level users are defined as users with no parent - */ - parent_id: string; - - /** - * First and last name required - */ - name: string; - - /** - * Required - */ - email: string; - - /** - * Optional - */ - phone_number?: string | null; - - /** - * Formatted as string "XX.XXXXX" - */ - balance: string; - - /** - * Cost per shipment purchase, formatted as string "XX.XXXXX" - */ - price_per_shipment: string; - /** - * USD formatted dollars and cents, delimited by a decimal point - */ - recharge_amount: string; - - /** - * USD formatted dollars and cents, delimited by a decimal point - */ - secondary_recharge_amount: string; - - /** - * Number of cents USD that when your balance drops below, we automatically recharge your account with your primary payment method. - */ - recharge_threshold: string; - - /** - * The fee rate for convenience fees - */ - cc_fee_rate: string; - - /** - * The fee rate for insurance purchases - */ - insurance_fee_rate: string; - - /** - * The minimum cost for insurance purchases - */ - insurance_fee_minimum: string; - - /** - * All associated children - */ - children: IUser[]; -} - -declare class User implements IUser { - public constructor(input: IUserCreateParameters); - - id: string; - mode: 'test' | 'production'; - object: 'User'; - reference?: string | null; - parent_id: string; - name: string; - email: string; - phone_number?: string | null; - balance: string; - price_per_shipment: string; - recharge_amount: string; - secondary_recharge_amount: string; - recharge_threshold: string; - cc_fee_rate: string; - insurance_fee_rate: string; - insurance_fee_minimum: string; - children: IUser[]; - - /** - * Creates a child user. - * - * @see https://docs.easypost.com/docs/users/child-users#create-a-child-user - * @requires production API Key. - * - * @param {Object} params The parameters to create an {@link User} with. - * @returns {Promise} The created User. - */ - static create(params: Object): Promise; - - /** - * Retrieve a child user. - * @requires production API Key. - * - * @see https://docs.easypost.com/docs/users#retrieve-a-user - * - * @param {string} id ID of the child user to retrieve - * @param urlPrefix Override the prefix to use for the request URL, optional - * @returns {Promise} The associated User. - */ - static retrieve(id: string, urlPrefix: string): Promise; - - /** - * Retrieve the current authenticated user. - * @requires production API Key. - * - * @see https://docs.easypost.com/docs/users#retrieve-a-user - * - * @returns {Promise} The current authenticated user. - */ - static retrieveMe(): Promise; - - /** - * Just like retrieving a User they can be updated using the same patterns. - * Passing an id will allow the update of a child or the authenticated User. - * Passing no id will update the authenticated User. - * Since children also have the ability to authenticate themselves they can be updated without passing an id. - * Children may only have their "name" field updated, all other fields are ignored. - * Update requests for Users are partial updates. Only attributes specifically passed in will be updated. - * The current_password attribute is required when updating email or password. - * - * @see https://docs.easypost.com/docs/users#update-a-user - * @requires production API Key. - * - * @param id The id of the user - * @param params The parameters to update the {@link User} with - * @returns {Promise} The associated User. - */ - static update(id: string, params: Object): Promise; - - /** - * Childen may be removed from its parent. The parent account's Production API key must be used for the request, - * a child may not remove itself from its parent. - * A successful delete will return HTTP status 204 and an empty object for JSON content. - * @param id The id of the users - * @requires production API Key. - */ - static delete(id: string): void; - - /** - * Retrieve a list of all children user. - * - * The Children List is a paginated list of all {@link User} objects associated with the given API Key. - * It accepts a variety of parameters which can be used to modify the scope. - * The has_more attribute indicates whether additional pages can be requested. - * The recommended way of paginating is to use either the `before_id` or `after_id` parameter to specify where the next page begins. - * - * @see https://docs.easypost.com/docs/users/child-users#retrieve-all-child-users - * - * @param {Object} params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Children children} and pagination information. - */ - static allChildren(params: Object): Promise<{ children: User[]; has_more: boolean }>; - - /** - * Retrieve the next page of {@link User child users}. - * - * This automatically reuses the parameters from the previous call or the original {@link User.allChildren} call. - * - * @see https://docs.easypost.com/docs/users/child-users#retrieve-all-child-users - * - * @param {Object} children - The previous page of child users (the response from the last {@link User.getNextPage} or {@link User.allChildren} call). - * @param {number} [pageSize] - The number of child users to retrieve per page, optional. Defaults to server-side default. - * @returns {Object} - An object containing a list of {@link User child users} and pagination information. - */ - static getNextPage( - children: Object, - pageSize?: number, - ): Promise<{ children: User[]; has_more: boolean }>; -} - -export type { User }; diff --git a/types/User/UserCreateParameters.d.ts b/types/User/UserCreateParameters.d.ts deleted file mode 100644 index d9bc3cc78..000000000 --- a/types/User/UserCreateParameters.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ParametersToOmitOnCreate } from '../utils'; -import { IUser } from './User'; - -export declare interface IUserCreateParameters extends Omit {} diff --git a/types/User/index.d.ts b/types/User/index.d.ts deleted file mode 100644 index f6b9f36c6..000000000 --- a/types/User/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './User'; diff --git a/types/Utility/Utils.d.ts b/types/Utility/Utils.d.ts deleted file mode 100644 index 0d1a18a51..000000000 --- a/types/Utility/Utils.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Rate } from '../Rate'; - -/** - * The Utils class represents a number of helper methods for the client library. - */ -declare class Utils { - /** - * Get the lowest SmartRate from a provided list of SmartRates. - * @public - * @param smartrates List of SmartRates to filter through - * @param deliveryDays The maximum number of days allowed for delivery - * @param deliveryAccuracy The target level of accuracy for the delivery days (e.g. 'percentile_95') - * @returns The lowest SmartRate - * @throws FilteringError If no applicable rates are found - * @throws InvalidParameterError If the deliveryAccuracy value is invalid - */ - static getLowestSmartRate( - smartrates: Rate[], - deliveryDays: number, - deliveryAccuracy: string, - ): Rate; - - /** - * Get the lowest rate from a provided list of rates. - * @public - * @param rates List of rates to filter through - * @param carriers List of carriers to filter by - * @param services List of services to filter by - * @returns The lowest rate - * @throws FilteringError If no applicable rates are found - */ - static getLowestRate(rates: Rate[], carriers?: string[], services?: string[]): Rate; - - /** - * Validate a webhook by comparing the HMAC signature header sent from EasyPost to your shared secret. - * If the signatures do not match, an error will be raised signifying the webhook either did not originate - * from EasyPost or the secrets do not match. If the signatures do match, the `event_body` will be returned - * as JSON. - * @public - * @param eventBody The raw body of the webhook event - * @param headers The headers of the webhook HTTP request - * @param webhookSecret The webhook secret shared between EasyPost and your application - * @returns The JSON-parsed webhook event body if the signature could be verified - * @throws SignatureVerificationError If the signature could not be verified - */ - static validateWebhook(eventBody: Buffer, headers: object, webhookSecret: string): object; -} - -export type { Utils }; diff --git a/types/Utility/index.d.ts b/types/Utility/index.d.ts deleted file mode 100644 index 6a46623dc..000000000 --- a/types/Utility/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Utils'; diff --git a/types/Webhook/Webhook.d.ts b/types/Webhook/Webhook.d.ts deleted file mode 100644 index f03f511ae..000000000 --- a/types/Webhook/Webhook.d.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { IObjectWithId } from '../base'; -import { IWebhookCreateParameters } from './WebhookCreateParameters'; -import { IWebhookListParameters } from './WebhookListParameters'; - -/** - * Each Webhook contains the url which EasyPost will notify whenever an object in our system updates. - * Several types of objects are processed asynchronously in the EasyPost system, so whenever an object updates, an Event is sent via HTTP POST to each configured webhook URL. - * The Webhook object provides CRUD operations for all Webhooks. - * - * Currently, our recommended best practice for securing Webhooks involves using basic authentication and HTTPS on your endpoint. - * This will help prevent any altering of any information communicated to you by EasyPost, prevent any third parties from seeing your webhooks in transit, and will prevent any third parties from masquerading as EasyPost and sending fraudulent data. - * EasyPost performs certificate validation and requires any TLS-enabled (HTTPS) webhook recipients to have a certificate signed by a public trusted certification authority. - * We do not support sending webhooks to over SSLv2, SSLv3, or any connection using so-called export-grade ciphers. - * For documentation on how to set up your server with TLS, we recommend Mozilla's guide to Server-Side TLS and Qualys's SSL/TLS deployment best practices guide. - * - * In general, a Webhook's endpoint should return a status code of 2XX. - * A 200 is preferred, but any 2XX status will indicate to our system that the Webhook request was successful. - * Endpoints that return a large volume and rate of failures over a period of time will get automatically disabled by the system; a disabled Webhook can be re-enabled using the Webhook update endpoint. - * - * @see https://docs.easypost.com/docs/webhooks#webhook-object - */ -export declare interface IWebhook extends IObjectWithId<'Webhook'> { - /** - * http://example.com - */ - url: string; - - /** - * the timestamp at which the webhook was most recently disabled (if any) - */ - disabled_at: string; - - /** - * custom headers to add to your webhook - */ - custom_headers: Array<{ key: string; value: string }>; -} - -declare class Webhook implements IWebhook { - public constructor(input: IWebhookCreateParameters); - - url: string; - disabled_at: string; - id: string; - mode: 'test' | 'production'; - object: 'Webhook'; - custom_headers: { key: string; value: string }[]; - - /** - * To create a Webhook, you simply need to provide a url parameter that you wish to receive notifications to. - * - * @see https://docs.easypost.com/docs/webhooks#create-a-webhook - * - * @param {Object} params The parameters to create an {@link Webhook} with - * @returns {Promise} The created and verified {@link Webhook} - */ - static create(params: Object): Promise; - - /** - * Enables a Webhook that has been disabled. You can also secure your webhook by adding a webhook_secret. - * - * @see https://docs.easypost.com/docs/webhooks#update-a-webhook - * - * @param webhookId Unique, starts with "hook_" - * @param params The parameters to update an {@link Webhook} with - * @returns {Promise} The created and verified {@link Webhook} - */ - static update(webhookId: string, params: Object): Promise; - - /** - * Retrieve an unpaginated list of all Webhooks available to the authenticated account. - * - * @see https://docs.easypost.com/docs/webhooks#retrieve-all-webhooks - * - * @param {Object} params - The parameters to use for the request. - * @returns {Object} - An object containing a list of {@link Webhook webhooks} and pagination information. - */ - static all(params?: IWebhookListParameters): Promise<{ webhooks: Webhook[] }>; - - /** - * Retrieve a Webhook by id. - * - * @param webhookId Unique, starts with "hook_" - * - * @see https://docs.easypost.com/docs/webhooks#retrieve-a-webhook - * - * @returns {Promise} The created and verified {@link Webhook} - */ - static retrieve(webhookId: string): Promise; - - /** - * Delete a Webhook by id. - * - * @param webhookId Unique, starts with "hook_" - * - * @see https://docs.easypost.com/docs/webhooks#delete-a-webhook - */ - static delete(webhookId: string): void; -} - -export type { Webhook }; diff --git a/types/Webhook/WebhookCreateParameters.d.ts b/types/Webhook/WebhookCreateParameters.d.ts deleted file mode 100644 index d0b73daf1..000000000 --- a/types/Webhook/WebhookCreateParameters.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare interface IWebhookCreateParameters { - url: string; - webhook_secret?: string; - custom_headers?: Array<{ key: string; value: string }>; -} diff --git a/types/Webhook/WebhookListParameters.d.ts b/types/Webhook/WebhookListParameters.d.ts deleted file mode 100644 index 1fb245edd..000000000 --- a/types/Webhook/WebhookListParameters.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IAllMethodParameters } from '../utils'; - -/** - * @see https://docs.easypost.com/docs/webhooks#retrieve-all-webhooks - */ -export declare interface IWebhookListParameters extends IAllMethodParameters {} diff --git a/types/Webhook/index.d.ts b/types/Webhook/index.d.ts deleted file mode 100644 index 38a45b80b..000000000 --- a/types/Webhook/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Webhook'; -export * from './WebhookCreateParameters'; diff --git a/types/base.d.ts b/types/base.d.ts deleted file mode 100644 index 3a47f43c7..000000000 --- a/types/base.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -export declare interface IDatedObject { - /** - * Date ISO String - */ - created_at: string; - - /** - * Date ISO String - */ - updated_at: string; -} - -export declare interface IBaseObject { - object: ObjectName; -} - -export declare interface IObjectWithId extends IBaseObject { - /** - * Unique identifier, begins with "adr_" / "prcl_" / "ins_" / "trk_" / "batch_" / "cstinfo_" / etc - */ - id: string; - - /** - * Set based on which api-key you used, either "test" or "production" - */ - mode: 'test' | 'production'; - - /** - * The object name, e.g. "Address", "Rate", "Shipment", etc - */ - object: ObjectName; -} diff --git a/types/constants.d.ts b/types/constants.d.ts new file mode 100644 index 000000000..1d85857c6 --- /dev/null +++ b/types/constants.d.ts @@ -0,0 +1,21 @@ +import Utils from './utils/util'; +/** + * A class containing constants used throughout the EasyPost Node.js client library. + */ +export default class Constants { + static get CARRIER_ACCOUNTS_WITH_CUSTOM_CREATE_WORKFLOWS(): string[]; + static get CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH(): string[]; + static EXTERNAL_API_CALL_FAILED: string; + static INVALID_API_KEY_TYPE: string; + static INVALID_PARAMETER: string; + static INVALID_PAYMENT: string; + static INVALID_WEBHOOK_SIGNATURE: string; + static MISSING_REQUIRED_PARAMETER: string; + static NO_OBJECT_FOUND: string; + static NO_PAYMENT_METHODS: string; + static API_DID_NOT_RETURN_ERROR_DETAILS: string; + static WEBHOOK_DOES_NOT_MATCH: string; + static END_OF_PAGINATION: string; + static ERROR_DESERIALIZATION: string; + static Utils: Utils; +} diff --git a/types/easypost.d.ts b/types/easypost.d.ts new file mode 100644 index 000000000..ef378b4b1 --- /dev/null +++ b/types/easypost.d.ts @@ -0,0 +1,199 @@ +import Utils from './utils/util'; +type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete'; +type RequestHeaders = Record; +type ClientOptions = { + apiKey?: string; + useProxy?: boolean; + timeout?: number; + baseUrl?: string; + httpMiddleware?: any; + requestMiddleware?: any; + httpClient?: any; +}; +type HookValue = { + method: string; + path: string; + requestBody: unknown; + headers: RequestHeaders; + requestTimestamp: number; + requestUUID: string; + httpStatus?: number; + responseBody?: unknown; + responseTimestamp?: number; +}; +type HookHandler = any; +/** + * The client used to access services of the EasyPost API. + * This client is configured to use the latest production version of the EasyPost API. + * @param {string} key The API key to use for API requests made by this client. + * @param {Object} [options] Additional options to use for the underlying HTTP client (e.g. middleware, proxy configuration). + */ +export default class EasyPostClient { + static MS_SECOND: number; + static DEFAULT_TIMEOUT: number; + static DEFAULT_BASE_URL: string; + static DEFAULT_HEADERS: RequestHeaders; + static METHODS: Record<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', HttpMethod>; + static SERVICES: Record; + [key: string]: any; + key?: string; + useProxy?: boolean; + timeout: number; + baseUrl: string; + httpClient: any; + requestMiddleware?: any; + requestHooks: HookHandler[]; + responseHooks: HookHandler[]; + Utils: Utils; + constructor(key?: string, options?: ClientOptions); + /** + * Add a request hook function. + * @param {(config: object) => void} hook + */ + addRequestHook(hook: HookHandler): void; + /** + * Remove a request hook function. + * @param {(config: object) => void} hook + */ + removeRequestHook(hook: HookHandler): void; + /** + * Clear all request hooks. + */ + clearRequestHooks(): void; + /** + * Add a response hook function. + * @param {(config: object) => void} hook + */ + addResponseHook(hook: HookHandler): void; + /** + * Remove a response hook function. + * @param {(config: object) => void} hook + */ + removeResponseHook(hook: HookHandler): void; + /** + * Clear all response hooks. + */ + clearResponseHooks(): void; + /** + * Make an API call to the EasyPost API. + * + * This public, generic interface is useful for making arbitrary API calls to the EasyPost API that + * are not yet supported by the client library's services. When possible, the service for your use case + * should be used instead as it provides a more convenient and higher-level interface depending on the endpoint. + * @param {string} method - The HTTP method to use (e.g. 'get', 'post', 'put', 'patch', 'delete'). + * @param {string} endpoint - The API endpoint to call (e.g. '/addresses'). + * @param {Object} [params] - The parameters to send with the request. + * @returns {Promise} The response from the API call. + */ + makeApiCall(method: string, endpoint: string, params?: Record): Promise; + /** + * Create a copy of an {@link EasyPostClient} with overridden options. + * @param {EasyPostClient} client The `EasyPostClient` instance to clone. + * @param {Object} [options] The options to override. + * @returns {EasyPostClient} A new `EasyPostClient` instance. + */ + static copyClient(client: EasyPostClient, options?: ClientOptions): EasyPostClient; + /** + * Normalize HTTP methods from public API input into fetch-compatible values. + * @param {string} method - The method passed in by callers. + * @returns {string} lowercase method suitable for fetch. + */ + static _normalizeMethod(method?: string): string; + /** + * Executes a fetch request with timeout support. + * @private + */ + _fetchWithTimeout(url: string, init: RequestInit): Promise; + /** + * Parse an HTTP response body. + * @private + */ + _parseResponseBody(response: Response): Promise; + /** + * Encodes a string to base64 in both Node and edge runtimes. + * @private + */ + static _toBase64(value: string): string; + /** + * Build request headers to be sent with each EasyPost API request, combined (or overridden) by any additional headers + * @param {Object} [additionalHeaders] Additional headers to combine or override with the default headers. + * @returns {Object} The headers to use for the request. + */ + static _buildHeaders(additionalHeaders?: RequestHeaders): RequestHeaders; + /** + * Build the default User-Agent string while remaining safe in runtimes that + * do not expose Node globals/modules. + * @returns {string} The default User-Agent header value. + */ + static _buildUserAgent(): string; + /** + * Attach services to an {@link EasyPostClient} instance. + * @param {Map} services - A map of {@link BaseService}-based service classes to construct and attach to the client. + */ + _attachServices(services: Record): void; + /** + * If the path passed in is a full URI, use it; otherwise, prepend the base url from the api. + * @param {string} path - The path to build. + * @returns {string} The full path to use for the HTTP request. + */ + _buildPath(path?: string): string; + /** + * Create a value to be passed to the responseHooks, based on the requestHooks + * value and the response. + * @param {Object} baseHooksValue - the value being passed the requestHooks + * @param {Object} response - the response from the HTTP request + * @returns {Object} - the value to be passed to the responseHooks + */ + _createResponseHooksValue(baseHooksValue: HookValue, response: any): HookValue; + /** + * Make an HTTP request. + * @param {string} [path] - The partial path to append to the base url for the request. + * @param {string} [method] - The HTTP method to use for the request, defaults to GET. + * @param {Object} [params] - The parameters to send with the request. + * @param {Object} [headers] - Additional headers to send with the request. + * @returns {*} The response from the HTTP request. + * @throws {ApiError} If the request fails. + */ + _request(path?: string, method?: string, params?: Record, headers?: RequestHeaders): Promise; + /** + * Make a GET HTTP request. + * @param {string} path - The partial path to append to the base url for the request. + * @param {Object} [params] - The parameters to send with the request. + * @param {Object} [headers] - Additional headers to send with the request. + * @returns {*} The response from the HTTP request. + */ + _get(path: string, params?: Record, headers?: RequestHeaders): Promise; + /** + * Make a POST HTTP request. + * @param {string} path - The partial path to append to the base url for the request. + * @param {Object} [params] - The parameters to send with the request. + * @param {Object} [headers] - Additional headers to send with the request. + * @returns {*} The response from the HTTP request. + */ + _post(path: string, params?: Record, headers?: RequestHeaders): Promise; + /** + * Make a PUT HTTP request. + * @param {string} path - The partial path to append to the base url for the request. + * @param {Object} [params] - The parameters to send with the request. + * @param {Object} [headers] - Additional headers to send with the request. + * @returns {*} The response from the HTTP request. + */ + _put(path: string, params?: Record, headers?: RequestHeaders): Promise; + /** + * Make a PATCH HTTP request. + * @param {string} path - The partial path to append to the base url for the request. + * @param {Object} [params] - The parameters to send with the request. + * @param {Object} [headers] - Additional headers to send with the request. + * @returns {*} The response from the HTTP request. + */ + _patch(path: string, params?: Record, headers?: RequestHeaders): Promise; + /** + * Make a DELETE HTTP request. + * @param {string} path - The partial path to append to the base url for the request. + * @param {Object} [params] - The parameters to send with the request. + * @param {Object} [headers] - Additional headers to send with the request. + * @returns {*} The response from the HTTP request. + */ + _delete(path: string, params?: Record, headers?: RequestHeaders): Promise; +} +export {}; diff --git a/types/errors/AddressVerificationFieldError.d.ts b/types/errors/AddressVerificationFieldError.d.ts deleted file mode 100644 index 09c2456bc..000000000 --- a/types/errors/AddressVerificationFieldError.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { TErrorCode } from './ErrorCode'; - -/** - * @see https://docs.easypost.com/docs/errors#addressverificationfielderror-object - */ -export declare interface IAddressVerificationFieldError { - /** - * Machine readable description of the problem - */ - code: TErrorCode; - - /** - * Field of the request that the error describes - */ - field: string; - - /** - * Human readable description of the problem - */ - message: string; - - /** - * Occasional insight on how to correct the error - */ - suggestion?: string; -} diff --git a/types/errors/Error.d.ts b/types/errors/Error.d.ts deleted file mode 100644 index ea944154d..000000000 --- a/types/errors/Error.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TErrorCode } from './ErrorCode'; -import { IFieldError } from './FieldError'; - -/** - * In the event of a client or server error, the response will contain the standard 4xx or 5xx respectively, accompanied by a well-formed JSON body describing the issue, e.g., a required field was omitted, a purchase failed, etc. - * - * Each client library will encapsulate these errors and raise an exception, in addition to other exceptional cases, such as network failures. - * It is recommended to handle exceptions gracefully and to report any issues to support@easypost.com. - * - * @see https://docs.easypost.com/docs/errors - */ -export declare interface IError { - /** - * Machine readable description of the problem - */ - code: TErrorCode; - - /** - * Human readable description of the problem - */ - message: string; - - /** - * Breakdown of errors for specific fields in the request - */ - errors: IFieldError[]; -} diff --git a/types/errors/ErrorCode.d.ts b/types/errors/ErrorCode.d.ts deleted file mode 100644 index a7da3f95f..000000000 --- a/types/errors/ErrorCode.d.ts +++ /dev/null @@ -1,173 +0,0 @@ -export declare type TErrorCode = - | 'ADDRESS.COUNTRY.INVALID' - | 'ADDRESS.PARAMETERS.INVALID_CHARACTER' - | 'ADDRESS.PARAMETERS.INVALID' - | 'ADDRESS.VERIFICATION.FAILURE' - | 'ADDRESS.VERIFICATION.INVALID' - | 'ADDRESS.VERIFICATION.NOT_FOUND' - | 'ADDRESS.VERIFY.CARRIER_INVALID' - | 'ADDRESS.VERIFY.FAILURE' - | 'ADDRESS.VERIFY.INTL_NOT_ENABLED' - | 'ADDRESS.VERIFY.MISSING_CITY_STATE_ZIP' - | 'ADDRESS.VERIFY.MISSING_STREET' - | 'ADDRESS.VERIFY.ONLY_US' - | 'ADDRESS.VERIFY.UNAVAILABLE' - | 'ADDRESS.VERIFY.UPSTREAM_UNAVAILABLE' - | 'BAD_REQUEST' - | 'BANK_ACCOUNT.CHARGE.FAILURE' - | 'BANK_ACCOUNT.VERIFY.FAILURE' - /** - * The typo "FORAMT" is in both the docs and api error response. - * @link https://github.com/EasyPost/easypost-node/pull/156#discussion_r819811282 - */ - | 'BATCH.FILE_FORAMT.INVALID' - | 'BATCH.PARAMS.INVALID' - | 'BATCH.SHIPMENT.MISSING' - | 'BATCH.SHIPMENT.TOO_LARGE' - | 'BATCH.SHIPMENTS.REQUIRED' - | 'BATCH.STATE.ALREADY_PURCHASED' - | 'BATCH.STATE.CREATING' - | 'BATCH.STATE.CREATION_FAILED' - | 'BATCH.STATE.NOT_PURCHASED' - | 'CARRIER_ACCOUNT.INVALID' - | 'CARRIER_ACCOUNT.PARAMETERS.INVALID' - | 'CARRIER_ACCOUNT.REGISTRATION.FAILED' - | 'CARRIER_ACCOUNT.TYPE.EXISTS' - | 'CARRIER_ACCOUNT.TYPE.UNKNOWN' - | 'CONTAINER.DIMENSION.REQUIRED' - | 'CONTAINER.NAME.REQUIRED' - | 'CONTAINER.TYPE.INVALID' - | 'CREDIT_CARD.CHARGE.FAILURE' - | 'CREDIT_CARD.INVALID' - | 'CUSTOMS_INFO.PARAMETERS.INVALID' - | 'CUSTOMS_ITEM.CURRENCY.ONE_CURRENCY_SUPPORTED' - | 'CUSTOMS_ITEM.ORIGIN_COUNTRY.REQUIRED' - | 'CUSTOMS_ITEM.PARAMETERS.INVALID' - | 'DATE.PARSE.FAILURE' - | 'DHLGM.ACCESS_TOKEN.GENERATION_FAILED' - | 'DHLGM.GIRTH_MAX' - | 'DHLGM.LABEL.FAILURE' - | 'DHLGM.LETTER_NOT_SUPPORTED' - | 'DHLGM.NO_ALCOHOL' - | 'DHLGM.NO_INTERNATIONAL' - | 'DHLGM.RATE_TABLE.NOT_FOUND' - | 'DHLGM.RETURN.AUTHORIZATION_NUMBER_REQUIRED' - | 'DHLGM.SCAN_FORM.GENERATION_FAILED' - | 'DOCUMENT.COMMERCIAL_INVOICE.FAILURE' - | 'DOCUMENT.CONVERSION.FAILURE' - | 'EMAIL_VERIFICATION.EXPIRED' - | 'EMAIL_VERIFICATION.NOT_FOUND' - | 'EMAIL_VERIFICATION.USED' - | 'FORBIDDEN' - | 'IMAGE.CONVERSION.FAILURE' - | 'IMAGE.WIDTH.INVALID' - | 'INSURANCE.AMOUNT.ABOVE_MAXIMUM' - | 'INSURANCE.AMOUNT.BELOW_MINIMUM' - | 'INSURANCE.AMOUNT.REQUIRED' - | 'INSURANCE.CREATE.FAILURE' - | 'INSURANCE.PARAMETERS.INVALID' - | 'INSURANCE.PURCHASE.FAILED' - | 'INSURANCE.PURCHASE.NOT_ALLOWED' - | 'INTERNAL_SERVER_ERROR' - | 'ITEM.HEIGHT.REQUIRED' - | 'ITEM.LENGTH.REQUIRED' - | 'ITEM.NAME.REQUIRED' - | 'ITEM.VALUE.REQUIRED' - | 'ITEM.WEIGHT.REQUIRED' - | 'ITEM.WIDTH.REQUIRED' - | 'MODE.CONFLICT' - | 'MODE.UNAUTHORIZED' - | 'NOT_ACCEPTABLE' - | 'NOT_FOUND' - | 'ORDER.CARRIER_ACCOUNTS.CONFLICT' - | 'ORDER.CARRIER.REQUIRED' - | 'ORDER.FROM_ADDRESS.REQUIRED' - | 'ORDER.INVALID' - | 'ORDER.LABEL_DATE.INVALID' - | 'ORDER.OPTIONS.INVALID' - | 'ORDER.PARAMS.REQUIRED' - | 'ORDER.RATE.UNAVAILABLE' - | 'ORDER.SERVICE.REQUIRED' - | 'ORDER.SHIPMENTS.REQUIRED' - | 'ORDER.TO_ADDRESS.REQUIRED' - | 'PARAMETER.FORBIDDEN' - | 'PARAMETER.REQUIRED' - | 'PARCEL.PARAMETERS.INVALID' - | 'PARCEL.PREDEFINED_PACKAGE.INVALID' - | 'PAYMENT_GATEWAY.ERROR' - | 'PAYMENT_REQUIRED' - | 'PICKUP.ADDRESS.INVALID' - | 'PICKUP.ADDRESS.REQUIRED' - | 'PICKUP.BATCH_CARRIER.INCONSISTENT' - | 'PICKUP.BATCH.INVALID' - | 'PICKUP.BATCH.REQUIRED' - | 'PICKUP.BUY.FAILED' - | 'PICKUP.BUY.FORBIDDEN' - | 'PICKUP.BUY.NO_MATCHING_RATES' - | 'PICKUP.CANCEL.FAILED' - | 'PICKUP.CARRIER.REQUIRED' - | 'PICKUP.IS_ACCOUNT_ADDRESS.REQUIRED' - | 'PICKUP.MAX_DATETIME.REQUIRED' - | 'PICKUP.MIN_DATETIME.REQUIRED' - | 'PICKUP.REQUEST.INVALID' - | 'PICKUP.SERVICE.REQUIRED' - | 'PICKUP.SHIPMENT_COUNTRY.INVALID' - | 'PICKUP.SHIPMENT_SERVICE.INVALID' - | 'PICKUP.STATUS.INVALID' - | 'REFUND.FAILURE' - | 'REFUND.NO_RESPONSE' - | 'REFUND.TRACKING_CODE.NOT_FOUND' - | 'REFUND.TRACKING_CODES.INVALID' - | 'SCAN_FORM.BATCH.MULTIPLE_CARRIERS' - | 'SCAN_FORM.BATCH.NOT_PURCHASED' - | 'SCAN_FORM.CREATE.CARRIER_NOT_SUPPORTED' - | 'SCAN_FORM.CREATE.FAILURE' - | 'SCAN_FORM.FAILURE' - | 'SCAN_FORM.SHIPMENTS.INVALID' - | 'SCAN_FORM.SHIPMENTS.REQUIRED' - | 'SHIPMENT_REPORT.ALREADY_IN_PROGRESS' - | 'SHIPMENT_REPORT.DATE_RANGE.INVALID' - | 'SHIPMENT_REPORT.DATE_RANGE.TOO_LONG' - | 'SHIPMENT.CARRIER_ACCOUNTS.CONFLICT' - | 'SHIPMENT.CUSTOMS_INFO.DESCRIPTION_REQUIRED' - | 'SHIPMENT.CUSTOMS_INFO.REQUIRED' - | 'SHIPMENT.INSURANCE.ALREADY_PURCHASED' - | 'SHIPMENT.INVALID_PARAMS' - | 'SHIPMENT.INVALID' - | 'SHIPMENT.MISSING_INFORMATION' - | 'SHIPMENT.MISSING_RATE' - | 'SHIPMENT.OPTIONS.INVALID' - | 'SHIPMENT.POSTAGE.ASCII' - | 'SHIPMENT.POSTAGE.EXISTS' - | 'SHIPMENT.POSTAGE.FAILURE' - | 'SHIPMENT.POSTAGE.FORMAT_UNAVAILABLE' - | 'SHIPMENT.POSTAGE.INVALID_FORMAT' - | 'SHIPMENT.POSTAGE.NO_RESPONSE' - | 'SHIPMENT.POSTAGE.REQUIRED' - | 'SHIPMENT.PURCHASE.FAILURE' - | 'SHIPMENT.PURCHASE.IN_PROGRESS' - | 'SHIPMENT.RATE.BARCODE_UNAVAILABLE' - | 'SHIPMENT.RATE.CARRIER_ACCOUNT_INVALID' - | 'SHIPMENT.RATE.STAMP_UNAVAILABLE' - | 'SHIPMENT.RATES.UNAVAILABLE' - | 'SHIPMENT.REFUND.FAILURE' - | 'SHIPMENT.REFUND.UNAVAILABLE' - | 'SHIPMENT.TRACKING_CODE.INVALID_CARRIER' - | 'TRACKER.CARRIER_CODE_MISMATCH' - | 'TRACKER.CREATE.ERROR' - | 'TRACKER.INVALID_PARAMS' - | 'TRACKER.INVALID_TEST_CODE' - | 'TRACKER.MULTIPLE_CARRIERS_FOR_CODE' - | 'TRACKER.NO_CARRIER_ACCOUNT' - | 'TRACKER.NO_CARRIER_FOR_CODE' - | 'TRACKER.NOT_FOUND' - | 'TRACKER.RETRIEVE.ERROR' - | 'TRACKER.RUN.ERROR' - | 'TRACKER.UNSUPPORTED_CARRIER' - | 'UNAUTHORIZED' - | 'USER.CHARGE.NOT_ALLOWED' - | 'USER.INVALID' - | 'USER.PARENT.INVALID' - | 'USER.UNAUTHORIZED' - | 'WEBHOOK.EVENT.INVALID' - | 'WEBHOOK.INVALID'; diff --git a/types/errors/FieldError.d.ts b/types/errors/FieldError.d.ts deleted file mode 100644 index 2448b13de..000000000 --- a/types/errors/FieldError.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export declare interface IFieldError { - /** - * Field of the request that the error describes - */ - field: string; - - /** - * Human readable description of the problem - */ - message: string; - - /** - * Occasional insight on how to correct the error - */ - suggestion?: string; -} diff --git a/types/errors/api/api_error.d.ts b/types/errors/api/api_error.d.ts new file mode 100644 index 000000000..7b7ac2cf5 --- /dev/null +++ b/types/errors/api/api_error.d.ts @@ -0,0 +1,24 @@ +/** + * The ApiError class is used to represent errors that occurred while communicating with the EasyPost API. + * This class should not be instantiated directly. + * @internal + * @abstract + * @extends EasyPostError + * @property {string} [message] - The message to be displayed when the error is logged. + * @property {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @property {number} [statusCode] - The HTTP status code returned by the HTTP request to the EasyPost API. + * @property {EasyPostError[]} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class ApiError extends EasyPostError { + constructor({ message, code, statusCode, errors }?: { + message: any; + code: any; + statusCode: any; + errors: any; + }); + code: any; + errors: any; + message: any; + statusCode: any; +} +import EasyPostError from '../easypost_error'; diff --git a/types/errors/api/bad_request_error.d.ts b/types/errors/api/bad_request_error.d.ts new file mode 100644 index 000000000..ae248c42d --- /dev/null +++ b/types/errors/api/bad_request_error.d.ts @@ -0,0 +1,12 @@ +/** + * The BadRequestError class is used to represent a 400 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class BadRequestError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/external_api_error.d.ts b/types/errors/api/external_api_error.d.ts new file mode 100644 index 000000000..756e54175 --- /dev/null +++ b/types/errors/api/external_api_error.d.ts @@ -0,0 +1,10 @@ +/** + * The ExternalApiError class is used to represent errors that occurred while communicating with an external API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + */ +export default class ExternalApiError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/forbidden_error.d.ts b/types/errors/api/forbidden_error.d.ts new file mode 100644 index 000000000..2d628e0ee --- /dev/null +++ b/types/errors/api/forbidden_error.d.ts @@ -0,0 +1,12 @@ +/** + * The ForbiddenError class is used to represent a 403 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class ForbiddenError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/gateway_timeout_error.d.ts b/types/errors/api/gateway_timeout_error.d.ts new file mode 100644 index 000000000..eca6b803f --- /dev/null +++ b/types/errors/api/gateway_timeout_error.d.ts @@ -0,0 +1,12 @@ +/** + * The GatewayTimeoutError class is used to represent a 504 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class GatewayTimeoutError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/http_error.d.ts b/types/errors/api/http_error.d.ts new file mode 100644 index 000000000..b7777bb6d --- /dev/null +++ b/types/errors/api/http_error.d.ts @@ -0,0 +1,11 @@ +/** + * The HttpError class is used to represent a generic HTTP-related error that occurred while communicating with the EasyPost API. + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class HTTPError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/internal_server_error.d.ts b/types/errors/api/internal_server_error.d.ts new file mode 100644 index 000000000..bf6fd3f3a --- /dev/null +++ b/types/errors/api/internal_server_error.d.ts @@ -0,0 +1,12 @@ +/** + * The InternalServerError class is used to represent a 500 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class InternalServerError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/invalid_request_error.d.ts b/types/errors/api/invalid_request_error.d.ts new file mode 100644 index 000000000..d421c4f98 --- /dev/null +++ b/types/errors/api/invalid_request_error.d.ts @@ -0,0 +1,12 @@ +/** + * The InvalidRequestError class is used to represent a 422 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class InvalidRequestError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/method_not_allowed_error.d.ts b/types/errors/api/method_not_allowed_error.d.ts new file mode 100644 index 000000000..8bdbff591 --- /dev/null +++ b/types/errors/api/method_not_allowed_error.d.ts @@ -0,0 +1,12 @@ +/** + * The MethodNotAllowedError class is used to represent a 405 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class MethodNotAllowedError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/not_found_error.d.ts b/types/errors/api/not_found_error.d.ts new file mode 100644 index 000000000..8c615d166 --- /dev/null +++ b/types/errors/api/not_found_error.d.ts @@ -0,0 +1,12 @@ +/** + * The NotFoundError class is used to represent a 404 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class NotFoundError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/payment_error.d.ts b/types/errors/api/payment_error.d.ts new file mode 100644 index 000000000..20937098d --- /dev/null +++ b/types/errors/api/payment_error.d.ts @@ -0,0 +1,12 @@ +/** + * The PaymentError class is used to represent a 402 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class PaymentError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/rate_limit_error.d.ts b/types/errors/api/rate_limit_error.d.ts new file mode 100644 index 000000000..c601b37a4 --- /dev/null +++ b/types/errors/api/rate_limit_error.d.ts @@ -0,0 +1,12 @@ +/** + * The RateLimitError class is used to represent a 429 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class RateLimitError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/redirect_error.d.ts b/types/errors/api/redirect_error.d.ts new file mode 100644 index 000000000..c01fb2b4b --- /dev/null +++ b/types/errors/api/redirect_error.d.ts @@ -0,0 +1,12 @@ +/** + * The RedirectError class is used to represent a 3xx error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class RedirectError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/service_unavailable_error.d.ts b/types/errors/api/service_unavailable_error.d.ts new file mode 100644 index 000000000..98b3d5863 --- /dev/null +++ b/types/errors/api/service_unavailable_error.d.ts @@ -0,0 +1,12 @@ +/** + * The ServiceUnavailableError class is used to represent a 503 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class ServiceUnavailableError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/timeout_error.d.ts b/types/errors/api/timeout_error.d.ts new file mode 100644 index 000000000..36eb2763b --- /dev/null +++ b/types/errors/api/timeout_error.d.ts @@ -0,0 +1,12 @@ +/** + * The TimeoutError class is used to represent a 408 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class TimeoutError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/unauthorized_error.d.ts b/types/errors/api/unauthorized_error.d.ts new file mode 100644 index 000000000..b27a9f8a8 --- /dev/null +++ b/types/errors/api/unauthorized_error.d.ts @@ -0,0 +1,12 @@ +/** + * The UnauthorizedError class is used to represent a 401 error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class UnauthorizedError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/api/unknown_api_error.d.ts b/types/errors/api/unknown_api_error.d.ts new file mode 100644 index 000000000..e1ca09270 --- /dev/null +++ b/types/errors/api/unknown_api_error.d.ts @@ -0,0 +1,12 @@ +/** + * The UnknownApiError class is used to represent a generic, unexpected error that occurred while communicating with the EasyPost API. + * @sealed + * @extends ApiError + * @param {string} [message] - The message to be displayed when the error is logged. + * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. + * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. + * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. + */ +export default class UnknownApiError extends ApiError { +} +import ApiError from './api_error'; diff --git a/types/errors/easypost_error.d.ts b/types/errors/easypost_error.d.ts new file mode 100644 index 000000000..f01ce2ee2 --- /dev/null +++ b/types/errors/easypost_error.d.ts @@ -0,0 +1,13 @@ +/** + * The EasyPostError class is the base class for all errors that occur in the EasyPost Node.js client library. + * This class should not be instantiated directly. + * @internal + * @abstract + * @extends Error + * @param {string} [message] - The message to be displayed when the error is logged. + */ +export default class EasyPostError extends Error { + constructor({ message }?: { + message: any; + }); +} diff --git a/types/errors/error_handler.d.ts b/types/errors/error_handler.d.ts new file mode 100644 index 000000000..fb08ac010 --- /dev/null +++ b/types/errors/error_handler.d.ts @@ -0,0 +1,16 @@ +export default class ErrorHandler { + /** + * Recursively traverses a JSON object or array and extracts error messages + * as strings. Adds the extracted messages to the specified messagesList array. + * + * @param {object|array|string} errorMessage - The JSON object or array to traverse. + * @param {array} messagesList - The array to which extracted error messages will be added. + */ + static traverseJsonElement(errorMessage: object | any[] | string, messagesList: any[]): void; + /** + * Calculate and generate the appropriate {@link ApiError} based on a received HTTP response error. + * @param {*} error - The errored HTTP response. + * @returns {ApiError} The `ApiError`-based error corresponding to the HTTP status code. + */ + static handleApiError(error: any): ApiError; +} diff --git a/types/errors/general/end_of_pagination_error.d.ts b/types/errors/general/end_of_pagination_error.d.ts new file mode 100644 index 000000000..0680ca37c --- /dev/null +++ b/types/errors/general/end_of_pagination_error.d.ts @@ -0,0 +1,10 @@ +/** + * The EndOfPaginationError class is used to represent an error that no more page can be retrieved + * @sealed + * @extends EasyPostError + * @param {string} [message] - The message to be displayed when the error is logged. + */ +export default class EndOfPaginationError extends EasyPostError { + constructor(); +} +import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/filtering_error.d.ts b/types/errors/general/filtering_error.d.ts new file mode 100644 index 000000000..2e0f426b5 --- /dev/null +++ b/types/errors/general/filtering_error.d.ts @@ -0,0 +1,9 @@ +/** + * The FilteringError class is used to represent an error that occurred while filtering a list (e.g. a list of rates). + * @sealed + * @extends EasyPostError + * @param {string} [message] - The message to be displayed when the error is logged. + */ +export default class FilteringError extends EasyPostError { +} +import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/invalid_object_error.d.ts b/types/errors/general/invalid_object_error.d.ts new file mode 100644 index 000000000..1b03d441e --- /dev/null +++ b/types/errors/general/invalid_object_error.d.ts @@ -0,0 +1,9 @@ +/** + * The InvalidObjectError class is used to represent an error due to an invalid object (e.g. missing an expected property). + * @sealed + * @extends EasyPostError + * @param {string} [message] - The message to be displayed when the error is logged. + */ +export default class InvalidObjectError extends EasyPostError { +} +import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/invalid_parameter_error.d.ts b/types/errors/general/invalid_parameter_error.d.ts new file mode 100644 index 000000000..3ba132eab --- /dev/null +++ b/types/errors/general/invalid_parameter_error.d.ts @@ -0,0 +1,9 @@ +/** + * The InvalidParameterError class is used to represent an error due to an invalid function parameter. + * @sealed + * @extends EasyPostError + * @param {string} [message] - The message to be displayed when the error is logged. + */ +export default class InvalidParameterError extends EasyPostError { +} +import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/missing_parameter_error.d.ts b/types/errors/general/missing_parameter_error.d.ts new file mode 100644 index 000000000..fcb556346 --- /dev/null +++ b/types/errors/general/missing_parameter_error.d.ts @@ -0,0 +1,9 @@ +/** + * The MissingParameterError class is used to represent an error due to a missing expected function parameter. + * @sealed + * @extends EasyPostError + * @param {string} [message] - The message to be displayed when the error is logged. + */ +export default class MissingParameterError extends EasyPostError { +} +import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/signature_verification_error.d.ts b/types/errors/general/signature_verification_error.d.ts new file mode 100644 index 000000000..e506560b7 --- /dev/null +++ b/types/errors/general/signature_verification_error.d.ts @@ -0,0 +1,9 @@ +/** + * The SignatureVerificationError class is used to represent an error due to a failed signature verification (e.g. a webhook HMAC signature). + * @sealed + * @extends EasyPostError + * @param {string} [message] - The message to be displayed when the error is logged. + */ +export default class SignatureVerificationError extends EasyPostError { +} +import EasyPostError from '../easypost_error'; diff --git a/types/errors/index.d.ts b/types/errors/index.d.ts deleted file mode 100644 index d76c4718b..000000000 --- a/types/errors/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './AddressVerificationFieldError'; -export * from './Error'; -export * from './ErrorCode'; -export * from './FieldError'; diff --git a/types/index.d.ts b/types/index.d.ts index 1e1481dbb..cd6fc2d3e 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,39 +1,2 @@ -export * from './Address'; -export * from './Batch'; -export * from './Billing'; -export * from './Brand'; -export * from './Carrier'; -export * from './Claim'; -export * from './CustomerPortal'; -export * from './Customs'; -export { IEasyPostOptions } from './EasyPost'; -export * from './Embeddable'; -export * from './EndShipper'; -export * from './errors'; -export * from './Event'; -export * from './Fee'; -export * from './Insurance'; -export * from './Luma'; -export * from './Order'; -export * from './Parcel'; -export * from './PaymentMethod'; -export * from './Pickup'; -export * from './Referral'; -export * from './Refund'; -export * from './Report'; -export * from './ScanForm'; -export * from './Shipment'; -export * from './SmartRate'; -export * from './Tracker'; -export * from './User'; -export * from './Utility'; -export * from './utils'; -export * from './Webhook'; - -declare const EasyPostClient: typeof import('./EasyPost').default; +import EasyPostClient from './easypost'; export default EasyPostClient; -export as namespace MainClient; - -declare module 'easypost' { - export default EasyPostClient; -} diff --git a/types/models/address.d.ts b/types/models/address.d.ts new file mode 100644 index 000000000..fe56fc0bd --- /dev/null +++ b/types/models/address.d.ts @@ -0,0 +1,23 @@ +import EasyPostObject from './easypost_object'; +/** + * An {@link https://docs.easypost.com/docs/addresses Address} represents people, places, and organizations in a number of contexts. + * @public + * @extends EasyPostObject + */ +export default class Address extends EasyPostObject { + street1?: string | null; + street2?: string | null; + city?: string | null; + state?: string | null; + zip?: string | null; + country?: string | null; + residential?: boolean | null; + carrier_facility?: string | null; + name?: string | null; + company?: string | null; + phone?: string | null; + email?: string | null; + federal_tax_id?: string | null; + state_tax_id?: string | null; + verifications?: Record | null; +} diff --git a/types/models/api_key.d.ts b/types/models/api_key.d.ts new file mode 100644 index 000000000..3e6d449c8 --- /dev/null +++ b/types/models/api_key.d.ts @@ -0,0 +1,10 @@ +import EasyPostObject from './easypost_object'; +/** + * An {@link https://docs.easypost.com/docs/api-keys ApiKey} represents an authentication token that can be used to make requests to the EasyPost API. + * @public + * @extends EasyPostObject + */ +export default class ApiKey extends EasyPostObject { + active?: boolean | null; + key?: string | null; +} diff --git a/types/models/batch.d.ts b/types/models/batch.d.ts new file mode 100644 index 000000000..6495be9e7 --- /dev/null +++ b/types/models/batch.d.ts @@ -0,0 +1,16 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/batches Batch} represents a collection of {@link Shipment shipments} that can be processed together. + * @public + * @extends EasyPostObject + */ +export default class Batch extends EasyPostObject { + label_url?: string | null; + num_shipments?: number | null; + pickup?: Record | null; + reference?: string | null; + scan_form?: Record | null; + shipments?: Record[] | null; + state?: string | null; + status?: Record | null; +} diff --git a/types/models/brand.d.ts b/types/models/brand.d.ts new file mode 100644 index 000000000..8c481a067 --- /dev/null +++ b/types/models/brand.d.ts @@ -0,0 +1,16 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/users/brand Brand} represents custom branding for an EasyPost user's public-facing tracking details page. + * @public + * @extends EasyPostObject + */ +export default class Brand extends EasyPostObject { + ad_href?: string | null; + ad?: string | null; + background_color?: string | null; + color?: string | null; + logo_href?: string | null; + logo?: string | null; + theme?: 'theme1' | 'theme2' | null; + user_id?: string | null; +} diff --git a/types/models/carrier_account.d.ts b/types/models/carrier_account.d.ts new file mode 100644 index 000000000..566d5749d --- /dev/null +++ b/types/models/carrier_account.d.ts @@ -0,0 +1,16 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/carrier-accounts CarrierAccount} represents details about a specific enabled carrier, including credentials and other information. + * @public + * @extends EasyPostObject + */ +export default class CarrierAccount extends EasyPostObject { + billing_type?: string | null; + clone?: boolean | null; + credentials?: object | null; + description?: string | null; + fields?: Record | null; + readable?: string | null; + reference?: string | null; + test_credentials?: object | null; +} diff --git a/types/models/carrier_type.d.ts b/types/models/carrier_type.d.ts new file mode 100644 index 000000000..a10d46c2c --- /dev/null +++ b/types/models/carrier_type.d.ts @@ -0,0 +1,10 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/carrier-types CarrierType} represents the valid fields for a {@link CarrierAccount carrier account}. + * @public + * @extends EasyPostObject + */ +export default class CarrierType extends EasyPostObject { + fields?: Record | null; + type?: string | null; +} diff --git a/types/models/claim.d.ts b/types/models/claim.d.ts new file mode 100644 index 000000000..271cc6405 --- /dev/null +++ b/types/models/claim.d.ts @@ -0,0 +1,27 @@ +import EasyPostObject from './easypost_object'; +/** + * An {@link https://docs.easypost.com/docs/insurance/claims Claim} object represents claim for a {@link Shipment shipment}. + * @public + * @extends EasyPostObject + */ +export default class Claim extends EasyPostObject { + approved_amount?: string | null; + attachments?: string[] | null; + check_delivery_address?: string | null; + contact_email?: string | null; + description?: string | null; + history?: Record[] | null; + insurance_amount?: string | null; + insurance_id?: string | null; + payment_method?: string | null; + recipient_name?: unknown | null; + reference?: string | null; + requested_amount?: string | null; + salvage_value?: unknown | null; + shipment_id?: string | null; + status_detail?: string | null; + status_timestamp?: string | null; + status?: string | null; + tracking_code?: string | null; + type?: string | null; +} diff --git a/types/models/customs_info.d.ts b/types/models/customs_info.d.ts new file mode 100644 index 000000000..ab81e75ba --- /dev/null +++ b/types/models/customs_info.d.ts @@ -0,0 +1,18 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/customs-infos CustomsInfo} represents a collection of {@link CustomsItem CustomsItems} and associated information for generating international shipping customs forms. + * @public + * @extends EasyPostObject + */ +export default class CustomsInfo extends EasyPostObject { + content_explanation?: string | null; + contents_type?: string | null; + customs_certify?: boolean | null; + customs_items?: unknown[] | null; + customs_signer?: string | null; + declaration?: string | null; + eel_pfc?: string | null; + non_delivery_option?: 'abandon' | 'return' | null; + restriction_comments?: string | null; + restriction_type?: 'none' | 'other' | 'quarantine' | 'sanitary_phytosanitary_inspection' | null; +} diff --git a/types/models/customs_item.d.ts b/types/models/customs_item.d.ts new file mode 100644 index 000000000..06f3d2bec --- /dev/null +++ b/types/models/customs_item.d.ts @@ -0,0 +1,16 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/customs-items CustomsItem} represents a single item being shipped internationally. + * @public + * @extends EasyPostObject + */ +export default class CustomsItem extends EasyPostObject { + code?: string | null; + currency?: string | null; + description?: string | null; + hs_tariff_number?: string | null; + origin_country?: string | null; + quantity?: number | null; + value?: number | null; + weight?: number | null; +} diff --git a/types/models/easypost_object.d.ts b/types/models/easypost_object.d.ts new file mode 100644 index 000000000..7101c8735 --- /dev/null +++ b/types/models/easypost_object.d.ts @@ -0,0 +1,14 @@ +/** + * An EasyPostObject is the base class for all EasyPost API resources. + * @internal + * @abstract + */ +export default class EasyPostObject { + static id: string; + static object: string; + static mode: string; + static created_at: string; + static updated_at: string; + static _params: Record; + static [Symbol.hasInstance](instance: unknown): boolean; +} diff --git a/types/models/end_shipper.d.ts b/types/models/end_shipper.d.ts new file mode 100644 index 000000000..35ac071f2 --- /dev/null +++ b/types/models/end_shipper.d.ts @@ -0,0 +1,18 @@ +import EasyPostObject from './easypost_object'; +/** + * An {@link https://docs.easypost.com/docs/endshippers EndShipper} represents a person or business entity that is authorized to purchase postage on behalf of another person and is ultimately responsible for the shipment. + * @public + * @extends EasyPostObject + */ +export default class EndShipper extends EasyPostObject { + street1?: string | null; + street2?: string | null; + city?: string | null; + state?: string | null; + zip?: string | null; + country?: string | null; + name?: string | null; + company?: string | null; + phone?: string | null; + email?: string | null; +} diff --git a/types/models/event.d.ts b/types/models/event.d.ts new file mode 100644 index 000000000..92831d553 --- /dev/null +++ b/types/models/event.d.ts @@ -0,0 +1,14 @@ +import EasyPostObject from './easypost_object'; +/** + * An {@link https://docs.easypost.com/docs/events Event} represents a change in state for elements such as {@link Shipment shipments} and {@link Tracker trackers}, that triggers a {@link Webhook webhook}. + * @public + * @extends EasyPostObject + */ +export default class Event extends EasyPostObject { + completed_urls?: string[] | null; + description?: string | null; + pending_urls?: string[] | null; + previous_attributes?: Record | null; + result?: Record | null; + status?: 'completed' | 'failed' | 'in_queue' | 'retrying' | 'pending' | null; +} diff --git a/types/models/form.d.ts b/types/models/form.d.ts new file mode 100644 index 000000000..ecd15f452 --- /dev/null +++ b/types/models/form.d.ts @@ -0,0 +1,11 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/shipments/forms Form} represents a printable form for a {@link Shipment shipment}, such as a return packing slip, QR code or international shipping form. + * @public + * @extends EasyPostObject + */ +export default class Form extends EasyPostObject { + form_type?: 'cn22' | 'cod_return_label' | 'commercial_invoice' | 'high_value_report' | 'label_qr_code' | 'nafta_certificate_of_origin' | 'order_summary' | 'return_packing_slip' | 'rma_qr_code'; + form_url?: string | null; + submitted_electronically?: boolean | null; +} diff --git a/types/models/insurance.d.ts b/types/models/insurance.d.ts new file mode 100644 index 000000000..a292f4e8b --- /dev/null +++ b/types/models/insurance.d.ts @@ -0,0 +1,20 @@ +import EasyPostObject from './easypost_object'; +/** + * An {@link https://docs.easypost.com/docs/api-keys Insurance} object represents insurance for a {@link Shipment shipment}. + * @public + * @extends EasyPostObject + */ +export default class Insurance extends EasyPostObject { + amount?: string | null; + fee?: Record | null; + from_address?: Record | null; + messages?: string[] | null; + provider_id?: string | null; + provider?: string | null; + reference?: string | null; + shipment_id?: string | null; + status?: 'new' | 'pending' | 'purchased' | 'failed' | 'cancelled' | null; + to_address?: Record | null; + tracking_code?: string | null; + tracker?: Record | null; +} diff --git a/types/models/order.d.ts b/types/models/order.d.ts new file mode 100644 index 000000000..e16e3c1ac --- /dev/null +++ b/types/models/order.d.ts @@ -0,0 +1,27 @@ +import Constants from '../constants'; +import EasyPostObject from './easypost_object'; +/** + * An {@link https://docs.easypost.com/docs/orders Order} represents a collection of packages, intended only for multi-parcel shipments. + * @public + * @extends EasyPostObject + */ +export default class Order extends EasyPostObject { + buyer_address?: Record | null; + from_address?: Record | null; + is_return?: boolean | null; + messages?: Record[] | null; + rates?: Parameters[0] | null; + reference?: string | null; + return_address?: Record | null; + shipments?: Record[] | null; + to_address?: Record | null; + /** + * Get the lowest rate for this {@link Order}. + * @public + * @param {string[]} [carriers] - List of allowed carriers to filter by + * @param {string[]} [services] - List of allowed services to filter by + * @returns {Rate} - The lowest rate + * @throws {FilteringError} - If no applicable rates are found + */ + lowestRate(carriers?: string[], services?: string[]): ReturnType; +} diff --git a/types/models/parcel.d.ts b/types/models/parcel.d.ts new file mode 100644 index 000000000..07a5c1b65 --- /dev/null +++ b/types/models/parcel.d.ts @@ -0,0 +1,13 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/parcels Parcel} represents a physical container being shipped, such as a box or envelope, with corresponding dimensions and weight. + * @public + * @extends EasyPostObject + */ +export default class Parcel extends EasyPostObject { + height?: number | null; + length?: number | null; + predefined_package?: string | null; + weight?: number | null; + width?: number | null; +} diff --git a/types/models/payload.d.ts b/types/models/payload.d.ts new file mode 100644 index 000000000..280e03518 --- /dev/null +++ b/types/models/payload.d.ts @@ -0,0 +1,9 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/events/payloads Payload} represents an attempt by EasyPost to send an {@link Event event} to a {@link Webhook webhook}. + * @public + * @extends EasyPostObject + */ +export default class Payload extends EasyPostObject { + response_body?: string | null; +} diff --git a/types/models/pickup.d.ts b/types/models/pickup.d.ts new file mode 100644 index 000000000..42381330c --- /dev/null +++ b/types/models/pickup.d.ts @@ -0,0 +1,30 @@ +import Constants from '../constants'; +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/pickups Pickup} represents a scheduled carrier pickup of packages from an {@link https://docs.easypost.com/docs/addresses Address}. + * @public + * @extends EasyPostObject + */ +export default class Pickup extends EasyPostObject { + address?: Record | null; + carrier_accounts?: Record[] | null; + confirmation?: string | null; + instructions?: string | null; + is_account_address?: boolean | null; + max_datetime?: string | null; + messages?: Record[] | null; + min_datetime?: string | null; + pickup_rates?: Parameters[0] | null; + reference?: string | null; + shipment?: Record | null; + status?: 'unknown' | 'scheduled' | 'canceled' | null; + /** + * Get the lowest rate for this {@link Pickup}. + * @public + * @param {string[]} [carriers] - List of allowed carriers to filter by + * @param {string[]} [services] - List of allowed services to filter by + * @returns {Rate} - The lowest rate + * @throws {FilteringError} - If no applicable rates are found + */ + lowestRate(carriers?: string[], services?: string[]): ReturnType; +} diff --git a/types/models/pickup_rate.d.ts b/types/models/pickup_rate.d.ts new file mode 100644 index 000000000..a3af928c2 --- /dev/null +++ b/types/models/pickup_rate.d.ts @@ -0,0 +1,13 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link PickupRate} represents a {@link Rate rate} for a {@link Pickup pickup}. + * @public + * @extends EasyPostObject + */ +export default class PickupRate extends EasyPostObject { + carrier?: string | null; + currency?: string | null; + pickup_id?: string | null; + rate?: string | null; + service?: string | null; +} diff --git a/types/models/postage_label.d.ts b/types/models/postage_label.d.ts new file mode 100644 index 000000000..99ec96324 --- /dev/null +++ b/types/models/postage_label.d.ts @@ -0,0 +1,17 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link PostageLabel} represents a physical label to affix to a {@link Parcel parcel} when shipping. + * @public + * @extends EasyPostObject + */ +export default class PostageLabel extends EasyPostObject { + label_date?: string | null; + label_epl2_url?: string | null; + label_file_type?: string | null; + label_pdf_url?: string | null; + label_resolution?: number | null; + label_size?: string | null; + label_type?: string | null; + label_url?: string | null; + label_zpl_url?: string | null; +} diff --git a/types/models/rate.d.ts b/types/models/rate.d.ts new file mode 100644 index 000000000..0563592a4 --- /dev/null +++ b/types/models/rate.d.ts @@ -0,0 +1,23 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/shipments/rates Rate} represents pricing information for shipping a specific {@link Parcel} with a specific carrier and service level. + * @public + * @extends EasyPostObject + */ +export default class Rate extends EasyPostObject { + billing_type?: string | null; + carrier_account_id?: string | null; + carrier?: string | null; + currency?: string | null; + delivery_date_guaranteed?: boolean | null; + delivery_date?: string | null; + delivery_days?: number | null; + est_delivery_days?: number | null; + list_currency?: string | null; + list_rate?: string | null; + rate?: string | null; + retail_currency?: string | null; + retail_rate?: string | null; + service?: string | null; + shipment_id?: string | null; +} diff --git a/types/models/refund.d.ts b/types/models/refund.d.ts new file mode 100644 index 000000000..76157dde4 --- /dev/null +++ b/types/models/refund.d.ts @@ -0,0 +1,13 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/refunds Refund} represents a refunded {@link Shipment}. + * @public + * @extends EasyPostObject + */ +export default class Refund extends EasyPostObject { + carrier?: string | null; + confirmation_number?: string | null; + shipment_id?: string | null; + status?: 'submitted' | 'refunded' | 'rejected' | null; + tracking_code?: string | null; +} diff --git a/types/models/report.d.ts b/types/models/report.d.ts new file mode 100644 index 000000000..221d7e6e6 --- /dev/null +++ b/types/models/report.d.ts @@ -0,0 +1,15 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/reports Report} represents a CSV file containing a log of all objects within a specific time frame. + * @public + * @extends EasyPostObject + */ +export default class Report extends EasyPostObject { + end_date?: string | null; + include_children?: boolean | null; + send_email?: boolean | null; + start_date?: string | null; + status?: 'new' | 'available' | 'failed' | null; + url_expires_at?: string | null; + url?: string | null; +} diff --git a/types/models/scan_form.d.ts b/types/models/scan_form.d.ts new file mode 100644 index 000000000..536057823 --- /dev/null +++ b/types/models/scan_form.d.ts @@ -0,0 +1,15 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/scan-form ScanForm} represents a single document that can be scanned to mark all included tracking codes as "Accepted for Shipment" by the carrier. + * @public + * @extends EasyPostObject + */ +export default class ScanForm extends EasyPostObject { + address?: Record | null; + batch_id?: string | null; + form_file_type?: string | null; + form_url?: string | null; + message?: string | null; + status?: 'creating' | 'created' | 'failed' | null; + tracking_codes?: string[] | null; +} diff --git a/types/models/shipment.d.ts b/types/models/shipment.d.ts new file mode 100644 index 000000000..16285e352 --- /dev/null +++ b/types/models/shipment.d.ts @@ -0,0 +1,43 @@ +import Constants from '../constants'; +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/shipments Shipment} represents a physical {@link Parcel}, the origin and destination {@link Address Addresses}, and any associated {@link CustomsInfo}. + * @public + * @extends EasyPostObject + */ +export default class Shipment extends EasyPostObject { + batch_id?: string | null; + batch_message?: string | null; + batch_status?: string | null; + buyer_address?: Record | null; + customs_info?: Record | null; + fees?: Record[] | null; + forms?: Record[] | null; + from_address?: Record | null; + insurance?: Record | null; + is_return?: boolean | null; + messages?: Record[] | null; + options?: Record | null; + parcel?: Record | null; + postage_label?: Record | null; + rates?: Parameters[0] | null; + reference?: string | null; + refund_status?: 'submitted' | 'refunded' | 'rejected' | null; + return_address?: Record | null; + scan_form?: Record | null; + selected_rate?: Parameters[0][number] | null; + status?: string | null; + to_address?: Record | null; + tracker?: Record | null; + tracking_code?: string | null; + usps_zone?: string | null; + /** + * Get the lowest rate for this {@link Shipment}. + * @public + * @param {string[]} [carriers] - List of allowed carriers to filter by + * @param {string[]} [services] - List of allowed services to filter by + * @returns {Rate} - The lowest rate + * @throws {FilteringError} - If no applicable rates are found + */ + lowestRate(carriers?: string[], services?: string[]): ReturnType; +} diff --git a/types/models/tracker.d.ts b/types/models/tracker.d.ts new file mode 100644 index 000000000..d8c87a5f9 --- /dev/null +++ b/types/models/tracker.d.ts @@ -0,0 +1,22 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/trackers Tracker} represents the available tracking information for a package. + * @public + * @extends EasyPostObject + */ +export default class Tracker extends EasyPostObject { + carrier_detail?: Record | null; + carrier?: string | null; + est_delivery_date?: string | null; + fees?: Record[] | null; + finalized?: boolean | null; + is_return?: boolean | null; + public_url?: string | null; + shipment_id?: string | null; + signed_by?: string | null; + status_detail?: string | null; + status?: string | null; + tracking_code?: string | null; + tracking_details?: Record[] | null; + weight?: number | null; +} diff --git a/types/models/user.d.ts b/types/models/user.d.ts new file mode 100644 index 000000000..20a4a5aec --- /dev/null +++ b/types/models/user.d.ts @@ -0,0 +1,22 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/users ApiKey} represents an EasyPost account or child account. + * @public + * @extends EasyPostObject + */ +export default class User extends EasyPostObject { + api_keys?: Record[] | null; + balance?: string | null; + cc_fee_rate?: string | null; + children?: Record[] | null; + email?: string | null; + insurance_fee_minimum?: string | null; + insurance_fee_rate?: string | null; + name?: string | null; + parent_id?: string | null; + phone_number?: string | null; + price_per_shipment?: string | null; + recharge_amount?: string | null; + recharge_threshold?: string | null; + secondary_recharge_amount?: string | null; +} diff --git a/types/models/webhook.d.ts b/types/models/webhook.d.ts new file mode 100644 index 000000000..9590df533 --- /dev/null +++ b/types/models/webhook.d.ts @@ -0,0 +1,14 @@ +import EasyPostObject from './easypost_object'; +/** + * A {@link https://docs.easypost.com/docs/webhooks Webhook} represents a URL that will receive notifications when certain {@link Event} occur. + * @public + * @extends EasyPostObject + */ +export default class Webhook extends EasyPostObject { + custom_headers?: { + key: string; + value: string; + }[] | null; + disabled_at?: string | null; + url?: string | null; +} diff --git a/types/services/address_service.d.ts b/types/services/address_service.d.ts new file mode 100644 index 000000000..1cae5c859 --- /dev/null +++ b/types/services/address_service.d.ts @@ -0,0 +1,59 @@ +type AddressParams = Record & { + verify?: unknown; + verify_strict?: unknown; + verify_carrier?: unknown; +}; +type PaginationCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create an {@link Address address}. + * See {@link https://docs.easypost.com/docs/addresses#create-an-address EasyPost API Documentation} for more information. + * @param {Object} params - Parameters for the address to be created. + * @returns {Address} - The created address. + */ + create(params: AddressParams): Promise; + /** + * Create and verify an {@link Address address} in a single request. + * See {@link https://docs.easypost.com/docs/addresses#verify-an-address EasyPost API Documentation} for more information. + * @param {Object} params - Parameters for the address to be created. + * @returns {Address} - The created and verified address. + */ + createAndVerify(params: AddressParams): Promise; + /** + * Retrieve all {@link Address addresses} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/addresses#retrieve-all-addresses EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the list of addresses. + * @returns {Object} - An object containing a list of {@link Address addresses} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Address collection. + * @param {Object} addresses An object containing a list of {@link Address addresses} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(addresses: PaginationCollection, pageSize?: number): Promise; + /** + * Retrieve an {@link Address address} by its ID. + * See {@link https://docs.easypost.com/docs/addresses#retrieve-an-address EasyPost API Documentation} for more information. + * @param {string} id - The ID of the address to retrieve. + * @returns {Address} - The retrieved address. + */ + retrieve(id: string): Promise; + /** + * Verify an {@link Address address} by its ID. + * See {@link https://docs.easypost.com/docs/addresses#verify-an-address EasyPost API Documentation} for more information. + * @param {string} id - The ID of the address to verify. + * @returns {Address} - The verified address. + */ + verifyAddress(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/api_key_service.d.ts b/types/services/api_key_service.d.ts new file mode 100644 index 000000000..cdce598b3 --- /dev/null +++ b/types/services/api_key_service.d.ts @@ -0,0 +1,53 @@ +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Retrieve API Keys for a specified {@link User user}. + * See {@link https://docs.easypost.com/docs/api-keys#retrieve-an-api-key EasyPost API Documentation} for more information. + * @param {string} id - The ID of the user to retrieve keys for. + * @returns {Array} - List of associated API Keys. + * @throws {FilteringError} If user or API Keys are not found. + */ + retrieveApiKeysForUser(id: string): Promise; + /** + * Retrieve all {@link ApiKey API keys} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/api-keys#retrieve-an-api-key EasyPost API Documentation} for more information. + * @returns {Object} - An object containing the API keys associated with the current authenticated user and its child users. + */ + all(params?: Record): Promise; + /** + * Create an API key for a child or referral customer user. + * See {@link https://docs.easypost.com/docs/api-keys#create-an-api-key EasyPost API Documentation} for more information. + * @param {string} mode - The mode for the API key (either "production" or "test"). + * @returns {ApiKey} - The created API key. + */ + create(mode: string): Promise; + /** + * Delete an API key for a child or referral customer user. + * See {@link https://docs.easypost.com/docs/api-keys#delete-an-api-key EasyPost API Documentation} for more information. + * @param {string} id - The ID of the API key to delete. + * @returns {Promise|Promise} - A promise that resolves if the API key was successfully deleted. + */ + delete(id: string): Promise; + /** + * Enable a child or referral customer API key. + * See {@link https://docs.easypost.com/docs/api-keys#enable-an-api-key EasyPost API Documentation} for more information. + * @param {string} id - The ID of the API key to enable. + * @returns {ApiKey} - The enabled API key. + */ + enable(id: string): Promise; + /** + * Disable a child or referral customer API key. + * See {@link https://docs.easypost.com/docs/api-keys#disable-an-api-key EasyPost API Documentation} for more information. + * @param {string} id - The ID of the API key to disable. + * @returns {ApiKey} - The disabled API key. + */ + disable(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/base_service.d.ts b/types/services/base_service.d.ts new file mode 100644 index 000000000..306182d8b --- /dev/null +++ b/types/services/base_service.d.ts @@ -0,0 +1,62 @@ +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Converts model instances and nested data into plain JSON-compatible objects while + * preserving model helper methods as non-enumerable properties. + * @internal + * @param {*} response The value to serialize. + * @returns {*} A plain object/array/scalar. + */ + _toPlainEasyPostObject(response: any): any; + /** + * Converts a JSON response and all its nested elements to associated {@link EasyPostObject}-based class instances. + * @internal + * @param {*} response The JSON response to convert (usually a `Map` or `Array`). + * @param {*} params The parameters passed when fetching the response. + * @returns {*} An {@link EasyPostObject}-based class instance or an `Array` of {@link EasyPostObject}-based class instances. + */ + _buildEasyPostObject(response: any, params: any): any; + /** + * Converts a JSON response to plain JSON-compatible output while preserving model-based conversion internally. + * @internal + * @param {*} response The JSON response to convert (usually a `Map` or `Array`). + * @param {*} params The parameters passed when fetching the response. + * @returns {*} A plain object or array suitable for JSON serialization. + */ + _convertToEasyPostObject(response: any, params?: any): any; + /** + * Creates an EasyPost Object via the API. + * @internal + * @param {string} url The URL to send the API request to. + * @param {Object} params The parameters to send with the API request. + * @returns {EasyPostObject|Promise} The created {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + _create(url: any, params: any): Promise; + /** + * Retrieve a list of records from the API. + * @internal + * @param {string} url The URL to send the API request to. + * @param {Object} [params] The parameters to send with the API request. + * @returns {EasyPostObject|EasyPostObject[]|Promise} The retrieved {@link EasyPostObject}-based class instance(s), or a `Promise` that rejects with an error. + */ + _all(url: any, params?: {}): Promise; + /** + * Retrieve a record from the API. + * @internal + * @param {string} url The URL to send the API request to. + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + _retrieve(url: any): Promise; + /** + * Retrieve the next page of specific collection of object + * @internal + * @param {string} url The URL to send the API request to. + * @param {Object} collection The collection of a specific object. + * @param {Number} pageSize The number of records to return on each page. + * @param {Object} optionalParams The optional param for additional value in the query string. + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + * TODO: Implement this function in EndShippers and Batches once the API supports them properly. + */ + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/batch_service.d.ts b/types/services/batch_service.d.ts new file mode 100644 index 000000000..541140201 --- /dev/null +++ b/types/services/batch_service.d.ts @@ -0,0 +1,72 @@ +export declare const DEFAULT_LABEL_FORMAT = "pdf"; +type BatchParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link Batch batch}. + * See {@link https://docs.easypost.com/docs/batches#create-a-batch EasyPost API Documentation} for more information. + * @param {Object} params - Parameters for the batch to be created. + * @returns {Batch} - The created batch. + */ + create(params: BatchParams): Promise; + /** + * Add {@link Shipment shipments} to a {@link Batch batch}. + * See {@link https://docs.easypost.com/docs/batches#add-shipments-to-a-batch EasyPost API Documentation} for more information. + * @param {string} id - The id of the batch to add shipments to. + * @param {Array} shipmentIds - The ids of the shipments to add to the batch. + * @returns {Batch} - The updated batch. + */ + addShipments(id: string, shipmentIds: string[]): Promise; + /** + * Removes {@link Shipment shipments} from a {@link Batch batch}. + * See {@link https://docs.easypost.com/docs/batches#remove-shipments-from-a-batch EasyPost API Documentation} for more information. + * @param {string} id - The id of the batch to remove shipments from. + * @param {Array} shipmentIds - The ids of the shipments to remove from the batch. + * @returns {Batch} - The updated batch. + */ + removeShipments(id: string, shipmentIds: string[]): Promise; + /** + * Generate a label for a {@link Batch batch}. + * See {@link https://docs.easypost.com/docs/batches#batch-labels EasyPost API Documentation} for more information. + * @param {string} id - The id of the batch to generate a label for. + * @param {string} fileFormat - The format of the label to generate. Defaults to 'pdf'. + * @returns {Batch} - The updated batch. + */ + generateLabel(id: string, fileFormat?: string): Promise; + /** + * Create a {@link ScanForm scan form} for a {@link Batch batch}. + * See {@link https://docs.easypost.com/docs/batches#manifesting-scan-form EasyPost API Documentation} for more information. + * @param {string} id - The id of the batch to create a scan form for. + * @returns {Batch} - The updated batch. + */ + createScanForm(id: string): Promise; + /** + * Purchase a {@link Batch batch}. + * See {@link https://docs.easypost.com/docs/batches#buy-a-batch EasyPost API Documentation} for more information. + * @param {string} id - The id of the batch to purchase. + * @returns {Batch} - The purchased batch. + */ + buy(id: string): Promise; + /** + * Retrieve all {@link Batch batches} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/batches#retrieve-all-batches EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the list of batches. + * @returns {Object} - An object containing a list of {@link Batch batches} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve a {@link Batch batch} by its ID. + * See {@link https://docs.easypost.com/docs/batches#retrieve-batch EasyPost API Documentation} for more information. + * @param {string} id - The ID of the batch to retrieve. + * @returns {Batch} - The retrieved batch. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/beta_rate_service.d.ts b/types/services/beta_rate_service.d.ts new file mode 100644 index 000000000..e96810bcb --- /dev/null +++ b/types/services/beta_rate_service.d.ts @@ -0,0 +1,17 @@ +declare function _default(easypostClient: any): { + new (): {}; + /** + * Retrieve a list of stateless {@link Rate rates} based on the provided parameters. + * @param {Object} params - Map of parameters for the API call + * @returns {Rate[]} - List of stateless rates + */ + retrieveStatelessRates(params: any): Rate[]; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/beta_referral_customer_service.d.ts b/types/services/beta_referral_customer_service.d.ts new file mode 100644 index 000000000..70eb9e8cb --- /dev/null +++ b/types/services/beta_referral_customer_service.d.ts @@ -0,0 +1,41 @@ +declare function _default(easypostClient: any): { + new (): {}; + /** + * Add an existing Stripe payment method to a {@link User referral customer's} account. + * @param {string} stripeCustomerId - The Stripe account's ID. + * @param {string} paymentMethodReference - Reference of Stripe payment method. + * @param {string} [priority] - Which priority to set the payment method to ('primary' or 'secondary'). + * @returns {Object} - A JSON object representing the payment method. + */ + addPaymentMethod(stripeCustomerId: string, paymentMethodReference: string, priority?: string | undefined): any; + /** + * Refund by amount for a recent payment. + * @param {number} refundAmount - Amount to be refunded by cents. + * @returns {Object} - A JSON object representing the refund. + */ + refundByAmount(refundAmount: number): any; + /** + * Refund a payment by a payment log ID. + * @param {string} paymentLogId - ID of the payment log. + * @returns {object} - Returns BetaPaymentRefund object. + */ + refundByPaymentLog(paymentLogId: string): object; + /** + * Creates a client secret to use with Stripe when adding a credit card. + * @returns {object} - A JSON object representing the client secret. + */ + createCreditCardClientSecret(): object; + /** + * Creates a client secret to use with Stripe when adding a credit card. + * @returns {object} - A JSON object representing the client secret. + */ + createBankAccountClientSecret(returnUrl: any): object; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/billing_service.d.ts b/types/services/billing_service.d.ts new file mode 100644 index 000000000..10da9598b --- /dev/null +++ b/types/services/billing_service.d.ts @@ -0,0 +1,47 @@ +type PaymentMethodObject = { + id: string; + object: string; +}; +type PaymentMethodsResponse = Record & { + id: string | null; + primary_payment_method?: PaymentMethodObject | null; + secondary_payment_method?: PaymentMethodObject | null; +}; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Fund your EasyPost wallet by charging your primary or secondary payment method on file. + * See {@link https://docs.easypost.com/docs/users/billing#add-funds-to-your-wallet-one-time-charge EasyPost API Documentation} for more information. + * @param {String} amount - The amount to charge to your payment method. + * @param {String} priority - The priority of the payment method to charge. Can be either 'primary' or 'secondary'. + */ + fundWallet(amount: string, priority?: string): Promise; + /** + * Delete a payment method from the current authenticated user's account. + * See {@link https://docs.easypost.com/docs/users/billing#delete-a-payment-method EasyPost API Documentation} for more information. + * @param {String} priority - The priority of the payment method to delete. Can be either 'primary' or 'secondary'. + */ + deletePaymentMethod(priority: string): Promise; + /** + * Retrieve all payment methods associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/users/billing#retrieve-payment-methods EasyPost API Documentation} for more information. + * @returns {Object} - An object containing the payment methods associated with the current authenticated user. + */ + retrievePaymentMethods(): Promise; + /** + * Get payment info (type of the payment method and ID of the payment method) + * This function is intended for internal use only, please avoid using this function + * @private + * @param {String} priority - The priority of the payment method to retrieve. Can be either 'primary' or 'secondary'. + * @returns {string[]} - An array of two strings, the first being the endpoint of the payment method and the second being the ID of the payment method. + */ + _getPaymentInfo(priority: string): Promise<[string, string]>; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/carrier_account_service.d.ts b/types/services/carrier_account_service.d.ts new file mode 100644 index 000000000..7c053c2ce --- /dev/null +++ b/types/services/carrier_account_service.d.ts @@ -0,0 +1,65 @@ +type CarrierAccountParams = Record & { + type?: string; +}; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link CarrierAccount carrier account}. + * See {@link https://docs.easypost.com/docs/carrier-accounts#create-a-carrieraccount EasyPost API Documentation} for more information. + * @param {Object} params - Parameters for the carrier account to be created. + * @returns {CarrierAccount} - The created carrier account. + */ + create(params: CarrierAccountParams): Promise; + /** + * Update a {@link CarrierAccount carrier account}. + * See {@link https://docs.easypost.com/docs/carrier-accounts#update-a-carrieraccount EasyPost API Documentation} for more information. + * @param {string} id - The id of the carrier account to be updated. + * @param {Object} params - Parameters for the carrier account to be updated. + * @returns {CarrierAccount} - The updated carrier account. + */ + update(id: string, params: Record): Promise; + /** + * Delete a {@link CarrierAccount carrier account}. + * See {@link https://docs.easypost.com/docs/carrier-accounts#delete-a-carrieraccount EasyPost API Documentation} for more information. + * @param {string} id - The id of the carrier account to be deleted. + * @returns {Promise|Promise} - A promise that resolves when the carrier account has been deleted. + */ + delete(id: string): Promise; + /** + * Returns the correct carrier_account endpoint when creating a record based on the type. + * @private + * @param {string} carrierAccountType - The type of carrier account to be created. + * @returns {string} - The endpoint to be used for the carrier account creation request. + */ + _selectCarrierAccountCreationEndpoint(carrierAccountType: string): string; + /** + * Wraps the carrier account parameters in the correct format based on the type. + * @private + * @param {string} carrierAccountType - The type of carrier account to be created. + * @param {Object} params - The parameters for the carrier account to be created. + * @returns {Object} - The wrapped carrier account parameters. + */ + _wrapCarrierAccountParams(carrierAccountType: string, params: Record): Record; + /** + * Retrieve all {@link CarrierAccount carrier accounts} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/carrier-accounts#retrieve-all-carrieraccounts EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the list of carrier accounts. + * @returns {Object} - An object containing a list of {@link CarrierAccount carrier accounts} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve a {@link CarrierAccount carrier account} by its ID. + * See {@link https://docs.easypost.com/docs/carrier-accounts#retrieve-a-carrieraccount EasyPost API Documentation} for more information. + * @param {string} id - The ID of the carrier account to retrieve. + * @returns {CarrierAccount} - The retrieved carrier account. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/carrier_metadata_service.d.ts b/types/services/carrier_metadata_service.d.ts new file mode 100644 index 000000000..a89bc8f99 --- /dev/null +++ b/types/services/carrier_metadata_service.d.ts @@ -0,0 +1,21 @@ +/** + * @extends baseService + */ +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Retrieve a list of carrier metadata based on the provided parameters. + * @param {Array} carriers - List of carrier in string + * @param {Array} type - List of types in string + * @returns {Object[]} - List of carrier metadata + */ + retrieve(carriers?: string[] | null, types?: string[] | null): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/carrier_type_service.d.ts b/types/services/carrier_type_service.d.ts new file mode 100644 index 000000000..74877c7ed --- /dev/null +++ b/types/services/carrier_type_service.d.ts @@ -0,0 +1,18 @@ +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Retrieve all {@link CarrierType carrier types} available to the current authenticated user. + * See {@link https://docs.easypost.com/docs/carrier-types#retrieve-available-carrier-types EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the list of carrier types. + * @returns {CarrierType[]} - A list of {@link CarrierType carrier types}. + */ + all(params?: Record): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/claim_service.d.ts b/types/services/claim_service.d.ts new file mode 100644 index 000000000..6b1b8b22b --- /dev/null +++ b/types/services/claim_service.d.ts @@ -0,0 +1,44 @@ +type ClaimParams = Record; +type ClaimCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link Claim claim} record. + * @param {Object} params - Parameters for the claim to be created. + * @returns {Claim} - The created claim. + */ + create(params: ClaimParams): Promise; + /** + * Retrieve all {@link Claim} records associated with the current authenticated user. + * @param {Object} [params] - Parameters to filter the claim records. + * @returns {Object} - An object containing the list of {@link Claim claim} records and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Claim collection. + * @param {Object} claims An object containing a list of {@link Claim claims} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(claims: ClaimCollection, pageSize?: number | null): Promise; + /** + * Retrieve a {@link Claim claim} record by its ID. + * @param {string} id - The ID of the claim to retrieve. + * @returns {Claim} - The retrieved claim. + */ + retrieve(id: string): Promise; + /** + * Cancel a {@link Claim claim} record by its ID. + * @param {string} id - The ID of the claim to be canceled. + * @returns {Claim} - The canceled claim. + */ + cancel(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/customer_portal_service.d.ts b/types/services/customer_portal_service.d.ts new file mode 100644 index 000000000..ddb58fc18 --- /dev/null +++ b/types/services/customer_portal_service.d.ts @@ -0,0 +1,17 @@ +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a Portal Session. + * @param {Object} [params] - The parameters to create a session from. + * @returns {Object} - An object containing the created session. + */ + createAccountLink(params?: Record): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/customs_info_service.d.ts b/types/services/customs_info_service.d.ts new file mode 100644 index 000000000..156cc7f89 --- /dev/null +++ b/types/services/customs_info_service.d.ts @@ -0,0 +1,26 @@ +type CustomsInfoParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link CustomsInfo customs info} record. + * See {@link https://docs.easypost.com/docs/customs-infos#create-a-customsinfo EasyPost API Documentation} for more information. + * @param {Object} params - Parameters for the customs info to be created. + * @returns {CustomsInfo} - The created customs info. + */ + create(params: CustomsInfoParams): Promise; + /** + * Retrieve a {@link CustomsInfo customs info} record by its ID. + * See {@link https://docs.easypost.com/docs/customs-infos#retrieve-a-customsinfo EasyPost API Documentation} for more information. + * @param {string} id - The ID of the customs info to retrieve. + * @returns {CustomsInfo} - The retrieved customs info. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/customs_item_service.d.ts b/types/services/customs_item_service.d.ts new file mode 100644 index 000000000..e572b382e --- /dev/null +++ b/types/services/customs_item_service.d.ts @@ -0,0 +1,26 @@ +type CustomsItemParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link CustomsItem customs item}. + * See {@link https://docs.easypost.com/docs/customs-items#create-a-customsitem EasyPost API Documentation} for more information. + * @param {Object} params - Parameters for the customs item to be created. + * @returns {CustomsItem} - The created customs item. + */ + create(params: CustomsItemParams): Promise; + /** + * Retrieve a {@link CustomsItem customs item} by its ID. + * See {@link https://docs.easypost.com/docs/customs-items#retrieve-a-customsitem EasyPost API Documentation} for more information. + * @param {string} id - The ID of the customs item to retrieve. + * @returns {CustomsItem} - The retrieved customs item. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/embeddable_service.d.ts b/types/services/embeddable_service.d.ts new file mode 100644 index 000000000..f4fcab4cb --- /dev/null +++ b/types/services/embeddable_service.d.ts @@ -0,0 +1,17 @@ +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create an Embeddable Session. + * @param {Object} [params] - The parameters to create a session from. + * @returns {Object} - An object containing the created session. + */ + createSession(params?: Record): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/end_shipper_service.d.ts b/types/services/end_shipper_service.d.ts new file mode 100644 index 000000000..d6a24618a --- /dev/null +++ b/types/services/end_shipper_service.d.ts @@ -0,0 +1,41 @@ +type EndShipperParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create an {@link EndShipper end shipper}. + * See {@link https://docs.easypost.com/docs/endshippers#create-an-endshipper EasyPost API Documentation} for more information. + * @param {Object} params - Parameters for the end shipper to be created. + * @returns {EndShipper} - The created end shipper. + */ + create(params: EndShipperParams): Promise; + /** + * Update an {@link EndShipper end shipper}. + * See {@link https://docs.easypost.com/docs/endshippers#update-an-endshipper EasyPost API Documentation} for more information. + * @param {string} id - The ID of the end shipper to update. + * @param {Object} params - Parameters for the end shipper to be updated. + * @returns {EndShipper} - The updated end shipper. + */ + update(id: string, params: EndShipperParams): Promise; + /** + * Retrieve an {@link EndShipper end shipper} by its ID. + * See {@link https://docs.easypost.com/docs/endshippers#retrieve-an-endshipper EasyPost API Documentation} for more information. + * @param {string} id - The ID of the end shipper to retrieve. + * @returns {EndShipper} - The retrieved end shipper. + */ + retrieve(id: string): Promise; + /** + * Retrieve all {@link EndShipper end shippers} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/endshippers#retrieve-all-endshippers EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the list of end shippers. + * @returns {Object} - An object containing a list of {@link EndShipper end shippers} and pagination information. + */ + all(params?: Record): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/event_service.d.ts b/types/services/event_service.d.ts new file mode 100644 index 000000000..e613f96eb --- /dev/null +++ b/types/services/event_service.d.ts @@ -0,0 +1,48 @@ +type EventCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Retrieve all {@link Payload payloads} for an {@link Event event}. + * See {@link https://docs.easypost.com/docs/events/payloads#retrieve-all-payloads EasyPost API Documentation} for more information. + * @param {string} id - The ID of the event to retrieve payloads for. + * @returns {Payload[]} - A list of {@link Payload payloads} for the event. + */ + retrieveAllPayloads(id: string): Promise; + /** + * Retrieve a specific {@link Payload payload} for an {@link Event event}. + * See {@link https://docs.easypost.com/docs/events/payloads#retrieve-a-payload EasyPost API Documentation} for more information. + * @param {string} id - The ID of the event to retrieve the payload for. + * @param {string} payloadId - The ID of the payload to retrieve. + * @returns {Payload} - The {@link Payload payload} for the event. + */ + retrievePayload(id: string, payloadId: string): Promise; + /** + * Retrieve all {@link Event events} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/events#retrieve-all-events EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the list of events. + * @returns {Object} - An object containing the list of {@link Event events} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Event collection. + * @param {Object} events An object containing a list of {@link Event events} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(events: EventCollection, pageSize?: number | null): Promise; + /** + * Retrieve an {@link Event event} by its ID. + * See {@link https://docs.easypost.com/docs/events#retrieve-an-event EasyPost API Documentation} for more information. + * @param {string} id - The ID of the event to retrieve. + * @returns {Event} - The retrieved event. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/fedex_registration_service.d.ts b/types/services/fedex_registration_service.d.ts new file mode 100644 index 000000000..3bb03f1a4 --- /dev/null +++ b/types/services/fedex_registration_service.d.ts @@ -0,0 +1,81 @@ +type FedExValidationMap = Record & { + name?: string | null; +}; +type FedExParams = Record & { + address_validation?: FedExValidationMap; + pin_validation?: FedExValidationMap; + invoice_validation?: FedExValidationMap; + easypost_details?: Record; +}; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Register the billing address for a FedEx account. + * @param {string} fedexAccountNumber - The FedEx account number. + * @param {Object} params - Map of parameters. + * @returns {Object} + */ + registerAddress(fedexAccountNumber: string, params: FedExParams): Promise; + /** + * Request a PIN for FedEx account verification. + * @param {string} fedexAccountNumber - The FedEx account number. + * @param {string} pinMethodOption - The PIN delivery method: "SMS", "CALL", or "EMAIL". + * @param {Object} params - Map of parameters. + * @returns {Object} + */ + requestPin(fedexAccountNumber: string, pinMethodOption: string, params: FedExParams): Promise; + /** + * Validate the PIN entered by the user for FedEx account verification. + * @param {string} fedexAccountNumber - The FedEx account number. + * @param {Object} params - Map of parameters. + * @returns {Object} + */ + validatePin(fedexAccountNumber: string, params: FedExParams): Promise; + /** + * Submit invoice information to complete FedEx account registration. + * @param {string} fedexAccountNumber - The FedEx account number. + * @param {Object} params - Map of parameters. + * @returns {Object} + */ + submitInvoice(fedexAccountNumber: string, params: FedExParams): Promise; + /** + * Wraps address validation parameters and ensures the "name" field exists. + * If not present, generates a UUID (with hyphens removed) as the name. + * @private + * @param {Object} params - The original parameters map. + * @returns {Object} - A new map with properly wrapped address_validation and easypost_details. + */ + _wrapAddressValidation(params: FedExParams): Record; + /** + * Wraps PIN validation parameters and ensures the "name" field exists. + * If not present, generates a UUID (with hyphens removed) as the name. + * @private + * @param {Object} params - The original parameters map. + * @returns {Object} - A new map with properly wrapped pin_validation and easypost_details. + */ + _wrapPinValidation(params: FedExParams): Record; + /** + * Wraps invoice validation parameters and ensures the "name" field exists. + * If not present, generates a UUID (with hyphens removed) as the name. + * @private + * @param {Object} params - The original parameters map. + * @returns {Object} - A new map with properly wrapped invoice_validation and easypost_details. + */ + _wrapInvoiceValidation(params: FedExParams): Record; + /** + * Ensures the "name" field exists in the provided map. + * If not present, generates a UUID (with hyphens removed) as the name. + * This follows the pattern used in the web UI implementation. + * @private + * @param {Object} map - The map to ensure the "name" field in. + */ + _ensureNameField(map: FedExValidationMap): void; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/insurance_service.d.ts b/types/services/insurance_service.d.ts new file mode 100644 index 000000000..7acb4e153 --- /dev/null +++ b/types/services/insurance_service.d.ts @@ -0,0 +1,48 @@ +type InsuranceParams = Record; +type InsuranceCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create an {@link Insurance insurance} record. + * See {@link https://docs.easypost.com/docs/insurance#create-an-insurance EasyPost API Documentation} for more information. + * @param {Object} params - Parameters for the insurance to be created. + * @returns {Insurance} - The created insurance. + */ + create(params: InsuranceParams): Promise; + /** + * Retrieve all {@link Insurance} records associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/insurance#retrieve-all-insurances EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the insurance records. + * @returns {Object} - An object containing the list of {@link Insurance insurance} records and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Insurance collection. + * @param {Object} insurances An object containing a list of {@link Insurance insurances} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(insurances: InsuranceCollection, pageSize?: number | null): Promise; + /** + * Retrieve an {@link Insurance insurance} record by its ID. + * See {@link https://docs.easypost.com/docs/insurance#retrieve-an-insurance EasyPost API Documentation} for more information. + * @param {string} id - The ID of the insurance to retrieve. + * @returns {Insurance} - The retrieved insurance. + */ + retrieve(id: string): Promise; + /** + * Refund an {@link Insurance insurance} record by its ID. + * See {@link https://docs.easypost.com/docs/insurance#refund-an-insurance EasyPost API Documentation} for more information. + * @param {string} id - The ID of the insurance to be refunded. + * @returns {Insurance} - The refunded insurance. + */ + refund(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/luma_service.d.ts b/types/services/luma_service.d.ts new file mode 100644 index 000000000..cd25aeb41 --- /dev/null +++ b/types/services/luma_service.d.ts @@ -0,0 +1,18 @@ +type LumaParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Get service recommendations from Luma that meet the criteria of your ruleset. + * @param {Object} params - The parameters to get a Luma promise with. + * @returns {Object} - An object containing the Luma promise. + */ + getPromise(params: LumaParams): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/order_service.d.ts b/types/services/order_service.d.ts new file mode 100644 index 000000000..97c083357 --- /dev/null +++ b/types/services/order_service.d.ts @@ -0,0 +1,42 @@ +type OrderParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create an {@link Order order}. + * See {@link https://docs.easypost.com/docs/orders#create-an-order EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create an order with. + * @returns {Order} - The created order. + */ + create(params: OrderParams): Promise; + /** + * Purchase an {@link Order order}. + * See {@link https://docs.easypost.com/docs/orders#buy-an-order EasyPost API Documentation} for more information. + * @param {string} id - The ID of the order to buy. + * @param {string} carrier - The carrier to use for the order purchase. + * @param {string} service - The service to use for the order purchase. + * @returns {Order} - The purchased order. + */ + buy(id: string, carrier: string, service: string): Promise; + /** + * Get updated rates for an {@link Order order}. + * See {@link https://docs.easypost.com/docs/orders EasyPost API Documentation} for more information. + * @param {string} id - The ID of the order to get rates for. + * @returns {Order} - The order with rates. + */ + getRates(id: string): Promise; + /** + * Retrieve an {@link Order order} by its ID. + * See {@link https://docs.easypost.com/docs/orders#retrieve-an-order EasyPost API Documentation} for more information. + * @param {string} id - The ID of the order to retrieve. + * @returns {Order} - The retrieved order. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/parcel_service.d.ts b/types/services/parcel_service.d.ts new file mode 100644 index 000000000..2768027b4 --- /dev/null +++ b/types/services/parcel_service.d.ts @@ -0,0 +1,26 @@ +type ParcelParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link Parcel parcel}. + * See {@link https://docs.easypost.com/docs/parcels#create-a-parcel EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a parcel with. + * @returns {Parcel} - The created parcel. + */ + create(params: ParcelParams): Promise; + /** + * Retrieve a {@link Parcel parcel} by its ID. + * See {@link https://docs.easypost.com/docs/parcels#retrieve-a-parcel EasyPost API Documentation} for more information. + * @param {string} id - The ID of the parcel to retrieve. + * @returns {Parcel} - The retrieved parcel. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/pickup_service.d.ts b/types/services/pickup_service.d.ts new file mode 100644 index 000000000..741028508 --- /dev/null +++ b/types/services/pickup_service.d.ts @@ -0,0 +1,57 @@ +type PickupParams = Record; +type PickupCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link Pickup pickup}. + * See {@link https://docs.easypost.com/docs/pickups#create-a-pickup EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a pickup with. + * @returns {Pickup} - The created pickup. + */ + create(params: PickupParams): Promise; + /** + * Purchase a {@link Pickup pickup}. + * See {@link https://docs.easypost.com/docs/pickups#buy-a-pickup EasyPost API Documentation} for more information. + * @param {string} id - The ID of the pickup to purchase. + * @param {string} carrier - The carrier to purchase the pickup with. + * @param {string} service - The service to purchase the pickup with. + * @returns {Pickup} - The purchased pickup. + */ + buy(id: string, carrier: string, service: string): Promise; + /** + * Cancel a {@link Pickup pickup}. + * See {@link https://docs.easypost.com/docs/pickups#cancel-a-pickup EasyPost API Documentation} for more information. + * @param {string} id - The ID of the pickup to cancel. + * @returns {Pickup} - The cancelled pickup. + */ + cancel(id: string): Promise; + /** + * Retrieve all {@link Pickup pickups} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/pickups#retrieve-all-pickups EasyPost API Documentation} for more information. + * @param {Object} [params] - The parameters to filter the pickups by. + * @returns {Object} - An object containing a list of {@link Pickup pickups} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Pickup collection. + * @param {Object} pickups An object containing a list of {@link Pickup pickups} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(pickups: PickupCollection, pageSize?: number | null): Promise; + /** + * Retrieve a {@link Pickup pickup} by its ID. + * See {@link https://docs.easypost.com/docs/pickups#retrieve-a-pickup EasyPost API Documentation} for more information. + * @param {string} id - The ID of the pickup to retrieve. + * @returns {Pickup} - The retrieved pickup. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/rate_service.d.ts b/types/services/rate_service.d.ts new file mode 100644 index 000000000..16f2ce322 --- /dev/null +++ b/types/services/rate_service.d.ts @@ -0,0 +1,18 @@ +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Retrieve a {@link Rate rate} by its ID. + * See {@link https://docs.easypost.com/docs/shipments/rates EasyPost API Documentation} for more information. + * @param {string} id - The ID of the rate to retrieve. + * @returns {Rate} - The retrieved rate. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/referral_customer_service.d.ts b/types/services/referral_customer_service.d.ts new file mode 100644 index 000000000..a1aabdc60 --- /dev/null +++ b/types/services/referral_customer_service.d.ts @@ -0,0 +1,66 @@ +type ReferralCustomerParams = Record; +type MandateData = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link User referral customer}. + * See {@link https://docs.easypost.com/docs/users/referral-customers#create-a-referralcustomer EasyPost API Documentation} for more information. + * @param {Object} params - The referral customer's information. + * @returns {User} - The newly created referral customer. + */ + create(params: ReferralCustomerParams): Promise; + /** + * Update a {@link User referral customer's} email address. + * See {@link https://docs.easypost.com/docs/users/referral-customers#update-a-referralcustomer EasyPost API Documentation} for more information. + * @param {string} referralUserId - The ID of the referral customer to update. + * @param {string} email - The new email address. + * @returns {boolean} - Returns true if the referral was updated successfully, false otherwise. + */ + updateEmail(referralUserId: string, email: string): Promise; + /** + * Add a credit card to EasyPost for a ReferralCustomer without needing a Stripe account. This function requires the ReferralCustomer User's API key. + * See {@link https://docs.easypost.com/docs/users/billing#create-credit-card EasyPost API Documentation} for more information. + * @param {string} referralApiKey - The referral customer's production API key. + * @param {string} number - The credit card number. + * @param {string} expirationMonth - The credit card expiration month. + * @param {string} expirationYear - The credit card expiration year. + * @param {string} cvc - The credit card CVC. + * @param {string} priority - Whether to add the card as 'primary' or 'secondary' payment method (defaults to 'primary'). + * @returns {Object} - An object representing the newly-added credit card. + */ + addCreditCard(referralApiKey: string, number: string, expirationMonth: string, expirationYear: string, cvc: string, priority?: string): Promise>; + /** + * Add a credit card to EasyPost for a ReferralCustomer with a payment method ID from Stripe. + * This function requires the ReferralCustomer User's API key. + * @returns {object} - A JSON object representing the credit card. + */ + addCreditCardFromStripe(referralApiKey: string, paymentMethodId: string, priority?: string): Promise; + /** + * Add a bank account to EasyPost for a ReferralCustomer. + * This function requires the ReferralCustomer User's API key. + * @returns {object} - A JSON object representing the bank account. + */ + addBankAccountFromStripe(referralApiKey: string, financialConnectionsId: string, mandateData: MandateData, priority?: string): Promise; + /** + * Retrieve all {@link User referral customers} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/users/referral-customers#retrieve-all-referralcustomers EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the referral customers by. + * @returns {Object} - An object containing a list of {@link User referral customers} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Referral Customer collection. + * @param {Object} referralCustomers An object containing a list of {@link referral referralCustomers} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(referralCustomers: Record, pageSize?: number | null): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/refund_service.d.ts b/types/services/refund_service.d.ts new file mode 100644 index 000000000..65a557d6d --- /dev/null +++ b/types/services/refund_service.d.ts @@ -0,0 +1,41 @@ +type RefundParams = Record; +type RefundCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link Refund refund}. + * See {@link https://docs.easypost.com/docs/refunds#create-a-refund EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a refund with. + * @returns {Refund} - The created refund. + */ + create(params: RefundParams): Promise; + /** + * Retrieve all {@link Refund refunds} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/refunds#retrieve-all-refunds EasyPost API Documentation} for more information. + * @param {Object} [params] - The parameters to filter the refunds by. + * @returns {Object} - An object containing the list of {@link Refund refunds} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Refund collection. + * @param {Object} refunds An object containing a list of {@link Refund refunds} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(refunds: RefundCollection, pageSize?: number | null): Promise; + /** + * Retrieve a {@link Refund refund} by its ID. + * See {@link https://docs.easypost.com/docs/refunds#retrieve-a-refund EasyPost API Documentation} for more information. + * @param {string} id - The ID of the refund to retrieve. + * @returns {Refund} - The retrieved refund. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/report_service.d.ts b/types/services/report_service.d.ts new file mode 100644 index 000000000..c69665452 --- /dev/null +++ b/types/services/report_service.d.ts @@ -0,0 +1,39 @@ +declare function _default(easypostClient: any): { + new (): {}; + /** + * Create a {@link Report report}. + * See {@link https://docs.easypost.com/docs/reports#create-a-report EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a report with. + * @returns {Report} - The created report. + */ + create(params: any): Report; + /** + * Retrieve all {@link Report reports} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/reports#retrieve-all-reports EasyPost API Documentation} for more information. + * @param {Object} [params] - The parameters to filter the reports by. + * @returns {Object} - An object containing the list of {@link Report reports} and pagination information. + */ + all(params?: any): any; + /** + * Retrieve the next page of Report collection. + * @param {Object} reports An object containing a list of {@link Report reports} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(reports: any, pageSize?: number): EasyPostObject | Promise; + /** + * Retrieve a {@link Report report} by its ID. + * See {@link https://docs.easypost.com/docs/reports#retrieve-a-report EasyPost API Documentation} for more information. + * @param {string} id - The ID of the report to retrieve. + * @returns {Report} - The retrieved report. + */ + retrieve(id: string): Report; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/scan_form_service.d.ts b/types/services/scan_form_service.d.ts new file mode 100644 index 000000000..75ae96615 --- /dev/null +++ b/types/services/scan_form_service.d.ts @@ -0,0 +1,45 @@ +type ScanFormParams = Record & { + shipments?: Array; +}; +type ScanFormCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link ScanForm scan form}. + * See {@link https://docs.easypost.com/docs/scan-form#create-a-scanform EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a scan form with. + * @returns {ScanForm} - The created scan form. + */ + create(params: ScanFormParams): Promise; + /** + * Retrieve all {@link ScanForm scan forms} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/scan-form#retrieve-all-scanforms EasyPost API Documentation} for more information. + * @param {Object} [params] - The parameters to filter the scan forms by. + * @returns {Object} - An object containing the list of {@link ScanForm scan forms} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of ScanForm collection. + * @param {Object} scanforms An object containing a list of {@link ScanForm scanforms} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(scanforms: ScanFormCollection, pageSize?: number | null): Promise; + /** + * Retrieve a {@link ScanForm scan form} by its ID. + * See {@link https://docs.easypost.com/docs/scan-form#retrieve-a-scanform EasyPost API Documentation} for more information. + * @param {string} id - The ID of the scan form to retrieve. + * @returns {ScanForm} - The retrieved scan form. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/shipment_service.d.ts b/types/services/shipment_service.d.ts new file mode 100644 index 000000000..8704e31e7 --- /dev/null +++ b/types/services/shipment_service.d.ts @@ -0,0 +1,135 @@ +type ShipmentParams = Record; +type ShipmentRateInput = string | { + id: string; +}; +type ShipmentCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link Shipment shipment}. + * See {@link https://docs.easypost.com/docs/shipments#create-a-shipment EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a shipment with. + * @returns {Shipment} - The created shipment. + */ + create(params: ShipmentParams): Promise; + /** + * Purchase a {@link Shipment shipment}. + * See {@link https://docs.easypost.com/docs/shipments#buy-a-shipment EasyPost API Documentation} for more information. + * @param {string} id - The ID of the shipment to purchase. + * @param {Rate} rate - The rate to purchase the shipment with. + * @param {number|null} [insuranceAmount] - The amount of insurance to purchase for the shipment. + * @param {string|null} [endShipperId] - The ID of the end shipper to purchase the shipment with. + * @returns {Shipment} - The purchased shipment. + */ + buy(id: string, rate: ShipmentRateInput, insuranceAmount?: number | null, endShipperId?: string | null): Promise; + /** + * Convert the label format of a {@link Shipment shipment}. + * See {@link https://docs.easypost.com/docs/shipments#converting-the-label-format-of-a-shipment EasyPost API Documentation} for more information. + * @param {string} id - The ID of the shipment to convert the label format of. + * @param {string} format - The format to convert the label to. + * @returns {Shipment} - The shipment with the converted label format. + */ + convertLabelFormat(id: string, format: string): Promise; + /** + * Regenerate {@link Rate rates} for a {@link Shipment shipment}. + * See {@link https://docs.easypost.com/docs/shipments/rates#regenerate-rates-for-a-shipment EasyPost API Documentation} for more information. + * @param {string} id - The ID of the shipment to regenerate rates for. + * @returns {Shipment} - The shipment with regenerated rates. + */ + regenerateRates(id: string): Promise; + /** + * Get SmartRates for a {@link Shipment shipment}. + * See {@link https://docs.easypost.com/docs/shipments/shipping-smartrate#shipping-smartrate-1 EasyPost API Documentation} for more information. + * @param {string} id - The ID of the shipment to get SmartRates for. + * @returns {Rate[]} - The SmartRates for the shipment. + */ + getSmartRates(id: string): Promise; + /** + * Insure a {@link Shipment shipment}. + * See {@link https://docs.easypost.com/docs/shipments/shipping-insurance#insure-a-shipment EasyPost API Documentation} for more information. + * @param {string} id - The ID of the shipment to insure. + * @param {number|string} amount - The amount to insure the shipment for. + * @returns {Shipment} - The insured shipment. + */ + insure(id: string, amount: number | string): Promise; + /** + * Generate a form for a {@link Shipment shipment}. + * See {@link https://docs.easypost.com/docs/shipments/forms#create-form EasyPost API Documentation} for more information. + * @param {string} id - The ID of the shipment to generate a form for. + * @param {string} formType - The type of form to generate. + * @param {Map} [formOptions] - Options for the form. + * @returns {Shipment} - The shipment with the generated form attached. + */ + generateForm(id: string, formType: string, formOptions?: Record): Promise; + /** + * Refund a {@link Shipment shipment}. + * See {@link https://docs.easypost.com/docs/shipments/shipping-refund#refund-a-shipment EasyPost API Documentation} for more information. + * @param {string} id - The ID of the shipment to refund. + * @returns {Shipment} - The refunded shipment. + */ + refund(id: string): Promise; + /** + * Get the lowest SmartRate of a shipment. + * @param {string} id - The ID of the shipment to get the lowest SmartRate of. + * @param {number} deliveryDays - The number of days the shipment will take to deliver. + * @param {string} deliveryAccuracy - The accuracy of the delivery days. + * @returns {Rate} - The lowest SmartRate of the shipment. + */ + lowestSmartRate(id: string, deliveryDays: number, deliveryAccuracy: string): Promise; + /** + * Retrieve all {@link Shipment shipments} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/shipments#retrieve-all-shipments EasyPost API Documentation} for more information. + * @param {Object} [params] - Parameters to filter the shipments by. + * @returns {Object} - An object containing a list of {@link Shipment shipments} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Shipment collection. + * @param {Object} shipments An object containing a list of {@link Shipment shipments} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(shipments: ShipmentCollection, pageSize?: number): Promise; + /** + * Retrieve a {@link Shipment shipment} by its ID. + * See {@link https://docs.easypost.com/docs/shipments#retrieve-a-shipment EasyPost API Documentation} for more information. + * @param {string} id - The ID of the shipment to retrieve. + * @returns {Shipment} - The shipment with the given ID. + */ + retrieve(id: string): Promise; + /** + * Retrieve the estimated delivery date of each Rate via SmartRate. + * @param {string} id - The ID of the shipment to retrieve the estimated delivery date for. + * @param {string} plannedShipDate - The planned ship date of the shipment. + * @returns {Array} - An array of the estimated delivery date and rates. + */ + retrieveEstimatedDeliveryDate(id: string, plannedShipDate: string): Promise; + /** + * Retrieve a recommended ship date for a {@link Shipment shipment} via the Precision Shipping API, based on a specific desired delivery date. + * @param id - The ID of the shipment to retrieve the recommended ship date for. + * @param desiredDeliveryDate - The desired delivery date for the shipment. + * @returns {Array} - An array of the recommended ship date and rates. + */ + recommendShipDate(id: string, desiredDeliveryDate: string): Promise; + /** + * Create and buy a Luma Shipment in one call. + * @param {Object} params - The parameters to create and buy a Shipment with Luma. + * @returns {Shipment} - The shipment with the given ID. + */ + createAndBuyLuma(params: ShipmentParams): Promise; + /** + * Buy a Shipment with Luma. + * @param {string} id - The ID of the Shipment to buy with Luma. + * @param {Object} params - The parameters to buy a Shipment with Luma. + * @returns {Shipment} - The shipment with the given ID. + */ + buyLuma(id: string, params: Record): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/smart_rate_service.d.ts b/types/services/smart_rate_service.d.ts new file mode 100644 index 000000000..37874fabb --- /dev/null +++ b/types/services/smart_rate_service.d.ts @@ -0,0 +1,24 @@ +type SmartRateParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Retrieve the estimated delivery date of each carrier-service level combination via the Smart Deliver By API, based on a specific ship date and origin-destination postal code pair. + * @param params - The parameters to estimate the delivery date with. + * @returns {Object} - Estimates and related metadata. + */ + estimateDeliveryDate(params: SmartRateParams): Promise; + /** + * Retrieve a recommended ship date for each carrier-service level combination via the Smart Deliver On API, based on a specific delivery date and origin-destination postal code pair. + * @param params - The parameters to recommend the ship date with. + * @returns {Object} - Recommendation and related metadata. + */ + recommendShipDate(params: SmartRateParams): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/tracker_service.d.ts b/types/services/tracker_service.d.ts new file mode 100644 index 000000000..611ba4e52 --- /dev/null +++ b/types/services/tracker_service.d.ts @@ -0,0 +1,54 @@ +type TrackerParams = Record; +type TrackerCollection = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link Tracker tracker}. + * See {@link https://docs.easypost.com/docs/trackers#create-a-tracker EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a tracker with. + * @returns {Tracker} - The created tracker. + */ + create(params: TrackerParams): Promise; + /** + * Retrieve all {@link Tracker trackers} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/trackers#retrieve-all-trackers EasyPost API Documentation} for more information. + * @param {Object} [params] - The parameters to filter the trackers by. + * @returns {Object} - An object containing the list of {@link Tracker trackers} and pagination information. + */ + all(params?: Record): Promise; + /** + * Retrieve the next page of Tracker collection. + * @param {Object} trackers An object containing a list of {@link Tracker trackers} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(trackers: TrackerCollection, pageSize?: number | null): Promise; + /** + * Retrieve a {@link Tracker tracker} by its ID. + * See {@link https://docs.easypost.com/docs/trackers#retrieve-a-tracker EasyPost API Documentation} for more information. + * @param {string} id - The ID of the tracker to retrieve. + * @returns {Tracker} - The retrieved tracker. + */ + retrieve(id: string): Promise; + /** + * Retrieve a batch of {@link Tracker trackers}. + * @param {Object} [params] - The parameters to filter the trackers by. + * @returns {Object} - An object containing the list of {@link Tracker trackers}. + */ + retrieveBatch(params?: Record): Promise; + /** + * Delete a {@link Tracker tracker}. + * See {@link https://docs.easypost.com/docs/trackers#delete-a-tracker EasyPost API Documentation} for more information. + * @param {string} id - The ID of the tracker to delete. + * @returns {Promise} + */ + delete(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/services/user_service.d.ts b/types/services/user_service.d.ts new file mode 100644 index 000000000..b256917e0 --- /dev/null +++ b/types/services/user_service.d.ts @@ -0,0 +1,74 @@ +type UserParams = Record; +type BrandParams = Record; +type UserCollection = Record & { + has_more?: boolean; + _params?: Record; +}; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link User child user}. + * See {@link https://docs.easypost.com/docs/users/child-users#create-a-child-user EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a child user with. + * @returns {User} - The created child user. + */ + create(params: UserParams): Promise; + /** + * Update a {@link User user}. + * See {@link https://docs.easypost.com/docs/users#update-a-user EasyPost API Documentation} for more information. + * @param {string} id - The ID of the user to update (either the current authenticated user or a child user). + * @param {Object} params - The parameters to update the user with. + * @returns {User} - The updated user. + */ + update(id: string, params: UserParams): Promise; + /** + * Retrieve a {@link User child user}. + * See {@link https://docs.easypost.com/docs/users#retrieve-a-user EasyPost API Documentation} for more information. + * @param {string} id - The ID of the child user to retrieve. + * @returns {User} - The retrieved child user. + */ + retrieve(id: string): Promise; + /** + * Retrieve the {@link User current authenticated user}. + * See {@link https://docs.easypost.com/docs/users#retrieve-a-user EasyPost API Documentation} for more information. + * @returns {User} - The retrieved user. + */ + retrieveMe(): Promise; + /** + * Delete a {@link User child user}. + * See {@link https://docs.easypost.com/docs/users/child-users#delete-a-child-user EasyPost API Documentation} for more information. + * @param {string} id - The ID of the child user to delete. + * @returns {Promise|Promise} - A promise that resolves when the child user is deleted successfully. + */ + delete(id: string): Promise; + /** + * Update the brand of a {@link User user}. + * See {@link https://docs.easypost.com/docs/users/brand#update-a-brand EasyPost API Documentation} for more information. + * @param {string} id - The ID of the user to update the brand of. + * @param {Object} params - The parameters to update the brand with. + * @returns {Brand} - The updated brand. + */ + updateBrand(id: string, params: BrandParams): Promise; + /** + * Retrieve a paginated list of children user {@link User user}. + * See {@link https://docs.easypost.com/docs/users/child-users#retrieve-all-child-users EasyPost API Documentation} for more information. + * @param {Object} params - Parameters to filter the list of children users. + * @returns {Object} - An object containing a list of {@link Children User} and pagination information. + */ + allChildren(params: Record): Promise; + /** + * Retrieve the next page of children collection. + * @param {Object} children An object containing a list of {@link Children children} and pagination information. + * @param {Number} pageSize The number of records to return on each page + * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. + */ + getNextPage(children: UserCollection, pageSize?: number | null): Promise; + _getNextPage(url: string, key: string, collection: UserCollection, pageSize?: number | null): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; +}; +export default _default; diff --git a/types/services/webhook_service.d.ts b/types/services/webhook_service.d.ts new file mode 100644 index 000000000..8370721de --- /dev/null +++ b/types/services/webhook_service.d.ts @@ -0,0 +1,49 @@ +type WebhookParams = Record; +declare const _default: (easypostClient: any) => { + new (): {}; + /** + * Create a {@link Webhook webhook}. + * See {@link https://docs.easypost.com/docs/webhooks#create-a-webhook EasyPost API Documentation} for more information. + * @param {Object} params - The parameters to create a webhook with. + * @returns {Webhook} - The created webhook. + */ + create(params: WebhookParams): Promise; + /** + * Update a {@link Webhook webhook}. + * A disabled webhook will be re-enabled if it is updated. + * See {@link https://docs.easypost.com/docs/webhooks#update-a-webhook EasyPost API Documentation} for more information. + * @param {string} id - The ID of the webhook to update. + * @param {Object} params - The parameters to update the webhook with. + * @returns {Webhook} - The updated webhook. + */ + update(id: string, params: Record): Promise; + /** + * Delete a {@link Webhook webhook}. + * See {@link https://docs.easypost.com/docs/webhooks#delete-a-webhook EasyPost API Documentation} for more information. + * @param {string} id - The ID of the webhook to delete. + * @returns {Promise|Promise} - A promise that resolves if the webhook was successfully deleted. + */ + delete(id: string): Promise; + /** + * Retrieve all {@link Webhook webhooks} associated with the current authenticated user. + * See {@link https://docs.easypost.com/docs/webhooks#retrieve-all-webhooks EasyPost API Documentation} for more information. + * @param {Object} [params] + * @returns {Webhook[]} + */ + all(params?: Record): Promise; + /** + * Retrieve a {@link Webhook webhook} by its ID. + * See {@link https://docs.easypost.com/docs/webhooks#retrieve-a-webhook EasyPost API Documentation} for more information. + * @param {string} id - The ID of the webhook to retrieve. + * @returns {Webhook} - The retrieved webhook. + */ + retrieve(id: string): Promise; + _toPlainEasyPostObject(response: any): any; + _buildEasyPostObject(response: any, params: any): any; + _convertToEasyPostObject(response: any, params?: any): any; + _create(url: any, params: any): Promise; + _all(url: any, params?: {}): Promise; + _retrieve(url: any): Promise; + _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; +}; +export default _default; diff --git a/types/utils.d.ts b/types/utils.d.ts deleted file mode 100644 index 0346ce471..000000000 --- a/types/utils.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -export type DeepPartial = { - [P in keyof T]?: DeepPartial; -}; - -export type ParametersToOmitOnCreate = 'id' | 'object' | 'mode' | 'created_at' | 'updated_at'; - -export declare interface IAllMethodParameters { - /** - * Optional pagination parameter. - * Only records created before the given ID will be included. - * May not be used with after_id - */ - before_id?: string; - - /** - * Optional pagination parameter. - * Only records created after the given ID will be included. - * May not be used with before_id - */ - after_id?: string; - - /** - * Only return records created after this timestamp. - * Defaults to 1 month ago, or 1 month before a passed end_datetime - */ - start_datetime?: string; - - /** - * Only return records created before this timestamp. - * Defaults to end of the current day, or 1 month after a passed start_datetime - */ - end_datetime?: string; - - /** - * The number of records to return on each page. - * The maximum value is 100 - */ - page_size?: number; -} diff --git a/types/utils/internal_util.d.ts b/types/utils/internal_util.d.ts new file mode 100644 index 000000000..f1265f5f9 --- /dev/null +++ b/types/utils/internal_util.d.ts @@ -0,0 +1,8 @@ +/** + * Utility class of various internal helper functions. + * This class is not designed to be used directly by consumers of the library. + * @internal + * @type {InternalUtils} + */ +export default class InternalUtils { +} diff --git a/types/utils/util.d.ts b/types/utils/util.d.ts new file mode 100644 index 000000000..a0e98d6de --- /dev/null +++ b/types/utils/util.d.ts @@ -0,0 +1,53 @@ +/// +/// +type SmartRate = { + rate: string; + time_in_transit: Record; +}; +type Rate = { + rate: string; + carrier: string; + service: string; +}; +/** + * Utility class of various publicly-available helper functions. + * @public + * @type {Utils} + */ +export default class Utils { + /** + * Get the lowest SmartRate from a provided list of SmartRates. + * @public + * @param {Rate[]} smartrates - List of SmartRates to filter through + * @param {number} deliveryDays - The maximum number of days allowed for delivery + * @param {string} deliveryAccuracy - The target level of accuracy for the delivery days (e.g. 'percentile_50') + * @returns {Rate} - The lowest SmartRate + * @throws {FilteringError} - If no applicable rates are found + * @throws {InvalidParameterError} - If the deliveryAccuracy value is invalid + */ + getLowestSmartRate(smartrates: SmartRate[], deliveryDays: number | string, deliveryAccuracy: string): SmartRate; + /** + * Get the lowest rate from a provided list of rates. + * @public + * @param {Rate[]} rates - List of rates to filter through + * @param {string[]} [carriers] - List of allowed carriers to filter by + * @param {string[]} [services] - List of allowed services to filter by + * @returns {Rate} - The lowest rate + * @throws {FilteringError} - If no applicable rates are found + */ + getLowestRate(rates: Rate[], carriers?: string[] | null, services?: string[] | null): Rate; + /** + * Validate a webhook by comparing the HMAC signature header sent from EasyPost to your shared secret. + * If the signatures do not match, an error will be raised signifying the webhook either did not originate + * from EasyPost or the secrets do not match. If the signatures do match, the `event_body` will be returned + * as JSON. + * @public + * @param {buffer} eventBody - The raw body of the webhook event + * @param {Object} headers - The headers of the webhook HTTP request + * @param {string} webhookSecret - The webhook secret shared between EasyPost and your application + * @returns {object} - The JSON-parsed webhook event body if the signature could be verified + * @throws {SignatureVerificationError} - If the signature could not be verified + */ + validateWebhook(eventBody: Buffer | string, headers: Record, webhookSecret: string): Record; +} +export {}; From 86da1845e00cea4ded53c58831c3c67fa448713a Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:53:54 -0600 Subject: [PATCH 2/3] TSM-90: remove tracked root types output --- .npmignore | 3 - package.json | 8 +- test/services/claim.test.js | 2 +- tsconfig.json | 2 +- types/.eslintrc | 9 - types/constants.d.ts | 21 -- types/demo/README.md | 3 - types/demo/index.ts | 10 - types/demo/package-lock.json | 227 ------------------ types/demo/package.json | 19 -- types/easypost.d.ts | 199 --------------- types/errors/api/api_error.d.ts | 24 -- types/errors/api/bad_request_error.d.ts | 12 - types/errors/api/external_api_error.d.ts | 10 - types/errors/api/forbidden_error.d.ts | 12 - types/errors/api/gateway_timeout_error.d.ts | 12 - types/errors/api/http_error.d.ts | 11 - types/errors/api/internal_server_error.d.ts | 12 - types/errors/api/invalid_request_error.d.ts | 12 - .../errors/api/method_not_allowed_error.d.ts | 12 - types/errors/api/not_found_error.d.ts | 12 - types/errors/api/payment_error.d.ts | 12 - types/errors/api/rate_limit_error.d.ts | 12 - types/errors/api/redirect_error.d.ts | 12 - .../errors/api/service_unavailable_error.d.ts | 12 - types/errors/api/timeout_error.d.ts | 12 - types/errors/api/unauthorized_error.d.ts | 12 - types/errors/api/unknown_api_error.d.ts | 12 - types/errors/easypost_error.d.ts | 13 - types/errors/error_handler.d.ts | 16 -- .../general/end_of_pagination_error.d.ts | 10 - types/errors/general/filtering_error.d.ts | 9 - .../errors/general/invalid_object_error.d.ts | 9 - .../general/invalid_parameter_error.d.ts | 9 - .../general/missing_parameter_error.d.ts | 9 - .../general/signature_verification_error.d.ts | 9 - types/index.d.ts | 2 - types/models/address.d.ts | 23 -- types/models/api_key.d.ts | 10 - types/models/batch.d.ts | 16 -- types/models/brand.d.ts | 16 -- types/models/carrier_account.d.ts | 16 -- types/models/carrier_type.d.ts | 10 - types/models/claim.d.ts | 27 --- types/models/customs_info.d.ts | 18 -- types/models/customs_item.d.ts | 16 -- types/models/easypost_object.d.ts | 14 -- types/models/end_shipper.d.ts | 18 -- types/models/event.d.ts | 14 -- types/models/form.d.ts | 11 - types/models/insurance.d.ts | 20 -- types/models/order.d.ts | 27 --- types/models/parcel.d.ts | 13 - types/models/payload.d.ts | 9 - types/models/pickup.d.ts | 30 --- types/models/pickup_rate.d.ts | 13 - types/models/postage_label.d.ts | 17 -- types/models/rate.d.ts | 23 -- types/models/refund.d.ts | 13 - types/models/report.d.ts | 15 -- types/models/scan_form.d.ts | 15 -- types/models/shipment.d.ts | 43 ---- types/models/tracker.d.ts | 22 -- types/models/user.d.ts | 22 -- types/models/webhook.d.ts | 14 -- types/services/address_service.d.ts | 59 ----- types/services/api_key_service.d.ts | 53 ---- types/services/base_service.d.ts | 62 ----- types/services/batch_service.d.ts | 72 ------ types/services/beta_rate_service.d.ts | 17 -- .../beta_referral_customer_service.d.ts | 41 ---- types/services/billing_service.d.ts | 47 ---- types/services/carrier_account_service.d.ts | 65 ----- types/services/carrier_metadata_service.d.ts | 21 -- types/services/carrier_type_service.d.ts | 18 -- types/services/claim_service.d.ts | 44 ---- types/services/customer_portal_service.d.ts | 17 -- types/services/customs_info_service.d.ts | 26 -- types/services/customs_item_service.d.ts | 26 -- types/services/embeddable_service.d.ts | 17 -- types/services/end_shipper_service.d.ts | 41 ---- types/services/event_service.d.ts | 48 ---- .../services/fedex_registration_service.d.ts | 81 ------- types/services/insurance_service.d.ts | 48 ---- types/services/luma_service.d.ts | 18 -- types/services/order_service.d.ts | 42 ---- types/services/parcel_service.d.ts | 26 -- types/services/pickup_service.d.ts | 57 ----- types/services/rate_service.d.ts | 18 -- types/services/referral_customer_service.d.ts | 66 ----- types/services/refund_service.d.ts | 41 ---- types/services/report_service.d.ts | 39 --- types/services/scan_form_service.d.ts | 45 ---- types/services/shipment_service.d.ts | 135 ----------- types/services/smart_rate_service.d.ts | 24 -- types/services/tracker_service.d.ts | 54 ----- types/services/user_service.d.ts | 74 ------ types/services/webhook_service.d.ts | 49 ---- types/utils/internal_util.d.ts | 8 - types/utils/util.d.ts | 53 ---- 100 files changed, 6 insertions(+), 2853 deletions(-) delete mode 100644 types/.eslintrc delete mode 100644 types/constants.d.ts delete mode 100644 types/demo/README.md delete mode 100644 types/demo/index.ts delete mode 100644 types/demo/package-lock.json delete mode 100644 types/demo/package.json delete mode 100644 types/easypost.d.ts delete mode 100644 types/errors/api/api_error.d.ts delete mode 100644 types/errors/api/bad_request_error.d.ts delete mode 100644 types/errors/api/external_api_error.d.ts delete mode 100644 types/errors/api/forbidden_error.d.ts delete mode 100644 types/errors/api/gateway_timeout_error.d.ts delete mode 100644 types/errors/api/http_error.d.ts delete mode 100644 types/errors/api/internal_server_error.d.ts delete mode 100644 types/errors/api/invalid_request_error.d.ts delete mode 100644 types/errors/api/method_not_allowed_error.d.ts delete mode 100644 types/errors/api/not_found_error.d.ts delete mode 100644 types/errors/api/payment_error.d.ts delete mode 100644 types/errors/api/rate_limit_error.d.ts delete mode 100644 types/errors/api/redirect_error.d.ts delete mode 100644 types/errors/api/service_unavailable_error.d.ts delete mode 100644 types/errors/api/timeout_error.d.ts delete mode 100644 types/errors/api/unauthorized_error.d.ts delete mode 100644 types/errors/api/unknown_api_error.d.ts delete mode 100644 types/errors/easypost_error.d.ts delete mode 100644 types/errors/error_handler.d.ts delete mode 100644 types/errors/general/end_of_pagination_error.d.ts delete mode 100644 types/errors/general/filtering_error.d.ts delete mode 100644 types/errors/general/invalid_object_error.d.ts delete mode 100644 types/errors/general/invalid_parameter_error.d.ts delete mode 100644 types/errors/general/missing_parameter_error.d.ts delete mode 100644 types/errors/general/signature_verification_error.d.ts delete mode 100644 types/index.d.ts delete mode 100644 types/models/address.d.ts delete mode 100644 types/models/api_key.d.ts delete mode 100644 types/models/batch.d.ts delete mode 100644 types/models/brand.d.ts delete mode 100644 types/models/carrier_account.d.ts delete mode 100644 types/models/carrier_type.d.ts delete mode 100644 types/models/claim.d.ts delete mode 100644 types/models/customs_info.d.ts delete mode 100644 types/models/customs_item.d.ts delete mode 100644 types/models/easypost_object.d.ts delete mode 100644 types/models/end_shipper.d.ts delete mode 100644 types/models/event.d.ts delete mode 100644 types/models/form.d.ts delete mode 100644 types/models/insurance.d.ts delete mode 100644 types/models/order.d.ts delete mode 100644 types/models/parcel.d.ts delete mode 100644 types/models/payload.d.ts delete mode 100644 types/models/pickup.d.ts delete mode 100644 types/models/pickup_rate.d.ts delete mode 100644 types/models/postage_label.d.ts delete mode 100644 types/models/rate.d.ts delete mode 100644 types/models/refund.d.ts delete mode 100644 types/models/report.d.ts delete mode 100644 types/models/scan_form.d.ts delete mode 100644 types/models/shipment.d.ts delete mode 100644 types/models/tracker.d.ts delete mode 100644 types/models/user.d.ts delete mode 100644 types/models/webhook.d.ts delete mode 100644 types/services/address_service.d.ts delete mode 100644 types/services/api_key_service.d.ts delete mode 100644 types/services/base_service.d.ts delete mode 100644 types/services/batch_service.d.ts delete mode 100644 types/services/beta_rate_service.d.ts delete mode 100644 types/services/beta_referral_customer_service.d.ts delete mode 100644 types/services/billing_service.d.ts delete mode 100644 types/services/carrier_account_service.d.ts delete mode 100644 types/services/carrier_metadata_service.d.ts delete mode 100644 types/services/carrier_type_service.d.ts delete mode 100644 types/services/claim_service.d.ts delete mode 100644 types/services/customer_portal_service.d.ts delete mode 100644 types/services/customs_info_service.d.ts delete mode 100644 types/services/customs_item_service.d.ts delete mode 100644 types/services/embeddable_service.d.ts delete mode 100644 types/services/end_shipper_service.d.ts delete mode 100644 types/services/event_service.d.ts delete mode 100644 types/services/fedex_registration_service.d.ts delete mode 100644 types/services/insurance_service.d.ts delete mode 100644 types/services/luma_service.d.ts delete mode 100644 types/services/order_service.d.ts delete mode 100644 types/services/parcel_service.d.ts delete mode 100644 types/services/pickup_service.d.ts delete mode 100644 types/services/rate_service.d.ts delete mode 100644 types/services/referral_customer_service.d.ts delete mode 100644 types/services/refund_service.d.ts delete mode 100644 types/services/report_service.d.ts delete mode 100644 types/services/scan_form_service.d.ts delete mode 100644 types/services/shipment_service.d.ts delete mode 100644 types/services/smart_rate_service.d.ts delete mode 100644 types/services/tracker_service.d.ts delete mode 100644 types/services/user_service.d.ts delete mode 100644 types/services/webhook_service.d.ts delete mode 100644 types/utils/internal_util.d.ts delete mode 100644 types/utils/util.d.ts diff --git a/.npmignore b/.npmignore index ede4dd4da..f5efe921a 100644 --- a/.npmignore +++ b/.npmignore @@ -10,10 +10,7 @@ !/prop_types.js !/README.md !/src/**/* -!/types/**/* !/UPGRADE_GUIDE.md # Here we exclude files that we pulled in from above that should be removed .DS_Store -types/.eslintrc -types/demo diff --git a/package.json b/package.json index 7ec7d4446..43b486d6e 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,14 @@ "homepage": "https://easypost.com", "exports": { ".": { - "types": "./types/index.d.ts", + "types": "./dist/types/index.d.ts", "import": "./dist/easypost.mjs", "require": "./dist/easypost.js" } }, "main": "./dist/easypost.js", "module": "./dist/easypost.mjs", - "types": "./types/index.d.ts", + "types": "./dist/types/index.d.ts", "repository": { "type": "git", "url": "git://github.com/easypost/easypost-node.git" @@ -31,12 +31,12 @@ "formatCheck": "prettier --check .", "lint": "eslint --ext .js,.ts --ignore-pattern 'examples/**' .", "lintFix": "eslint --ext .js,.ts --ignore-pattern 'examples/**' --fix .", - "prepublishOnly": "npm run clean && npm run build && npm run test && npm run lint && npm run formatCheck", + "prepublishOnly": "npm run clean && npm run build && npm run typescript:declarations && npm run test && npm run lint && npm run formatCheck", "scan": "npx audit-ci -m --config ./audit-ci.jsonc", "test": "cross-env NODE_ENV=test vitest run", "test:node-compatibility": "cross-env NODE_ENV=test node ./test/node_compatibility", "typescript": "npm run typescript:declarations && npm run typescript:source && npm run typescript:compat", - "typescript:declarations": "rm -rf ./types && npx tsc -p tsconfig.json", + "typescript:declarations": "rm -rf ./dist/types && npx tsc -p tsconfig.json", "typescript:source": "npx tsc -p tsconfig.build.json", "typescript:compat": "npx tsc -p tsconfig.type-tests.json", "watch": "vite build --watch" diff --git a/test/services/claim.test.js b/test/services/claim.test.js index 3cf7a7c4d..879539598 100644 --- a/test/services/claim.test.js +++ b/test/services/claim.test.js @@ -7,7 +7,7 @@ import Claim from '../../src/models/claim'; import Fixture from '../helpers/fixture'; import * as setupPolly from '../helpers/setup_polly'; -/** @typedef {import("../../types/easypost").default} Client */ +/** @typedef {import("../../src/easypost").default} Client */ const CLAIM_AMOUNT = 100; diff --git a/tsconfig.json b/tsconfig.json index 0b5302a49..e2377ec65 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "declaration": true, "emitDeclarationOnly": true, "rootDir": "./src", - "outDir": "./types", + "outDir": "./dist/types", "noEmit": false }, "include": ["src/**/*.js", "src/**/*.ts"], diff --git a/types/.eslintrc b/types/.eslintrc deleted file mode 100644 index bbe18a1d1..000000000 --- a/types/.eslintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint"], - "extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended"], - "rules": { - "no-unused-vars": "off" - } -} diff --git a/types/constants.d.ts b/types/constants.d.ts deleted file mode 100644 index 1d85857c6..000000000 --- a/types/constants.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Utils from './utils/util'; -/** - * A class containing constants used throughout the EasyPost Node.js client library. - */ -export default class Constants { - static get CARRIER_ACCOUNTS_WITH_CUSTOM_CREATE_WORKFLOWS(): string[]; - static get CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH(): string[]; - static EXTERNAL_API_CALL_FAILED: string; - static INVALID_API_KEY_TYPE: string; - static INVALID_PARAMETER: string; - static INVALID_PAYMENT: string; - static INVALID_WEBHOOK_SIGNATURE: string; - static MISSING_REQUIRED_PARAMETER: string; - static NO_OBJECT_FOUND: string; - static NO_PAYMENT_METHODS: string; - static API_DID_NOT_RETURN_ERROR_DETAILS: string; - static WEBHOOK_DOES_NOT_MATCH: string; - static END_OF_PAGINATION: string; - static ERROR_DESERIALIZATION: string; - static Utils: Utils; -} diff --git a/types/demo/README.md b/types/demo/README.md deleted file mode 100644 index 61eb856f1..000000000 --- a/types/demo/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Typescript Demo - -This is a simple project to demonstrate and test how to use the EasyPost Typescript definitions. diff --git a/types/demo/index.ts b/types/demo/index.ts deleted file mode 100644 index 8924c9fec..000000000 --- a/types/demo/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import EasyPostClient from '@easypost/api'; - -// This file is intended to demo how you could use the EasyPost Typescript definitions. -(async () => { - const client = new EasyPostClient(process.env.EASYPOST_TEST_API_KEY || ''); - - const customsInfo = await client.CustomsInfo.retrieve('cstinfo_...'); - - console.log(customsInfo); -})(); diff --git a/types/demo/package-lock.json b/types/demo/package-lock.json deleted file mode 100644 index 84ca6ffe2..000000000 --- a/types/demo/package-lock.json +++ /dev/null @@ -1,227 +0,0 @@ -{ - "name": "demo", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "demo", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "@easypost/api": "file:../" - }, - "devDependencies": { - "ts-node": "10.7.0", - "typescript": "~5.3.0" - } - }, - "..": {}, - "node_modules/@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">= 12" - } - }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspotcode/source-map-consumer": "0.8.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@easypost/api": { - "resolved": "..", - "link": true - }, - "node_modules/@tsconfig/node10": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.12.tgz", - "integrity": "sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "25.3.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.3.0.tgz", - "integrity": "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "undici-types": "~7.18.0" - } - }, - "node_modules/acorn": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", - "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", - "dev": true, - "license": "MIT", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-walk": { - "version": "8.3.5", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.5.tgz", - "integrity": "sha512-HEHNfbars9v4pgpW6SO1KSPkfoS0xVOM/9UzkJltjlsHZmJasxg8aXkuZa7SMf8vKGIBhpUsPluQSqhJFCqebw==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true, - "license": "MIT" - }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/diff": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz", - "integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, - "license": "ISC" - }, - "node_modules/ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspotcode/source-map-support": "0.7.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/undici-types": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", - "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true, - "license": "MIT" - }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - } - } -} diff --git a/types/demo/package.json b/types/demo/package.json deleted file mode 100644 index dfd3c7c97..000000000 --- a/types/demo/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "demo", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "ts-node src/index.ts" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@easypost/api": "file:../" - }, - "devDependencies": { - "typescript": "~5.3.0", - "ts-node": "10.7.0" - } -} diff --git a/types/easypost.d.ts b/types/easypost.d.ts deleted file mode 100644 index ef378b4b1..000000000 --- a/types/easypost.d.ts +++ /dev/null @@ -1,199 +0,0 @@ -import Utils from './utils/util'; -type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete'; -type RequestHeaders = Record; -type ClientOptions = { - apiKey?: string; - useProxy?: boolean; - timeout?: number; - baseUrl?: string; - httpMiddleware?: any; - requestMiddleware?: any; - httpClient?: any; -}; -type HookValue = { - method: string; - path: string; - requestBody: unknown; - headers: RequestHeaders; - requestTimestamp: number; - requestUUID: string; - httpStatus?: number; - responseBody?: unknown; - responseTimestamp?: number; -}; -type HookHandler = any; -/** - * The client used to access services of the EasyPost API. - * This client is configured to use the latest production version of the EasyPost API. - * @param {string} key The API key to use for API requests made by this client. - * @param {Object} [options] Additional options to use for the underlying HTTP client (e.g. middleware, proxy configuration). - */ -export default class EasyPostClient { - static MS_SECOND: number; - static DEFAULT_TIMEOUT: number; - static DEFAULT_BASE_URL: string; - static DEFAULT_HEADERS: RequestHeaders; - static METHODS: Record<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', HttpMethod>; - static SERVICES: Record; - [key: string]: any; - key?: string; - useProxy?: boolean; - timeout: number; - baseUrl: string; - httpClient: any; - requestMiddleware?: any; - requestHooks: HookHandler[]; - responseHooks: HookHandler[]; - Utils: Utils; - constructor(key?: string, options?: ClientOptions); - /** - * Add a request hook function. - * @param {(config: object) => void} hook - */ - addRequestHook(hook: HookHandler): void; - /** - * Remove a request hook function. - * @param {(config: object) => void} hook - */ - removeRequestHook(hook: HookHandler): void; - /** - * Clear all request hooks. - */ - clearRequestHooks(): void; - /** - * Add a response hook function. - * @param {(config: object) => void} hook - */ - addResponseHook(hook: HookHandler): void; - /** - * Remove a response hook function. - * @param {(config: object) => void} hook - */ - removeResponseHook(hook: HookHandler): void; - /** - * Clear all response hooks. - */ - clearResponseHooks(): void; - /** - * Make an API call to the EasyPost API. - * - * This public, generic interface is useful for making arbitrary API calls to the EasyPost API that - * are not yet supported by the client library's services. When possible, the service for your use case - * should be used instead as it provides a more convenient and higher-level interface depending on the endpoint. - * @param {string} method - The HTTP method to use (e.g. 'get', 'post', 'put', 'patch', 'delete'). - * @param {string} endpoint - The API endpoint to call (e.g. '/addresses'). - * @param {Object} [params] - The parameters to send with the request. - * @returns {Promise} The response from the API call. - */ - makeApiCall(method: string, endpoint: string, params?: Record): Promise; - /** - * Create a copy of an {@link EasyPostClient} with overridden options. - * @param {EasyPostClient} client The `EasyPostClient` instance to clone. - * @param {Object} [options] The options to override. - * @returns {EasyPostClient} A new `EasyPostClient` instance. - */ - static copyClient(client: EasyPostClient, options?: ClientOptions): EasyPostClient; - /** - * Normalize HTTP methods from public API input into fetch-compatible values. - * @param {string} method - The method passed in by callers. - * @returns {string} lowercase method suitable for fetch. - */ - static _normalizeMethod(method?: string): string; - /** - * Executes a fetch request with timeout support. - * @private - */ - _fetchWithTimeout(url: string, init: RequestInit): Promise; - /** - * Parse an HTTP response body. - * @private - */ - _parseResponseBody(response: Response): Promise; - /** - * Encodes a string to base64 in both Node and edge runtimes. - * @private - */ - static _toBase64(value: string): string; - /** - * Build request headers to be sent with each EasyPost API request, combined (or overridden) by any additional headers - * @param {Object} [additionalHeaders] Additional headers to combine or override with the default headers. - * @returns {Object} The headers to use for the request. - */ - static _buildHeaders(additionalHeaders?: RequestHeaders): RequestHeaders; - /** - * Build the default User-Agent string while remaining safe in runtimes that - * do not expose Node globals/modules. - * @returns {string} The default User-Agent header value. - */ - static _buildUserAgent(): string; - /** - * Attach services to an {@link EasyPostClient} instance. - * @param {Map} services - A map of {@link BaseService}-based service classes to construct and attach to the client. - */ - _attachServices(services: Record): void; - /** - * If the path passed in is a full URI, use it; otherwise, prepend the base url from the api. - * @param {string} path - The path to build. - * @returns {string} The full path to use for the HTTP request. - */ - _buildPath(path?: string): string; - /** - * Create a value to be passed to the responseHooks, based on the requestHooks - * value and the response. - * @param {Object} baseHooksValue - the value being passed the requestHooks - * @param {Object} response - the response from the HTTP request - * @returns {Object} - the value to be passed to the responseHooks - */ - _createResponseHooksValue(baseHooksValue: HookValue, response: any): HookValue; - /** - * Make an HTTP request. - * @param {string} [path] - The partial path to append to the base url for the request. - * @param {string} [method] - The HTTP method to use for the request, defaults to GET. - * @param {Object} [params] - The parameters to send with the request. - * @param {Object} [headers] - Additional headers to send with the request. - * @returns {*} The response from the HTTP request. - * @throws {ApiError} If the request fails. - */ - _request(path?: string, method?: string, params?: Record, headers?: RequestHeaders): Promise; - /** - * Make a GET HTTP request. - * @param {string} path - The partial path to append to the base url for the request. - * @param {Object} [params] - The parameters to send with the request. - * @param {Object} [headers] - Additional headers to send with the request. - * @returns {*} The response from the HTTP request. - */ - _get(path: string, params?: Record, headers?: RequestHeaders): Promise; - /** - * Make a POST HTTP request. - * @param {string} path - The partial path to append to the base url for the request. - * @param {Object} [params] - The parameters to send with the request. - * @param {Object} [headers] - Additional headers to send with the request. - * @returns {*} The response from the HTTP request. - */ - _post(path: string, params?: Record, headers?: RequestHeaders): Promise; - /** - * Make a PUT HTTP request. - * @param {string} path - The partial path to append to the base url for the request. - * @param {Object} [params] - The parameters to send with the request. - * @param {Object} [headers] - Additional headers to send with the request. - * @returns {*} The response from the HTTP request. - */ - _put(path: string, params?: Record, headers?: RequestHeaders): Promise; - /** - * Make a PATCH HTTP request. - * @param {string} path - The partial path to append to the base url for the request. - * @param {Object} [params] - The parameters to send with the request. - * @param {Object} [headers] - Additional headers to send with the request. - * @returns {*} The response from the HTTP request. - */ - _patch(path: string, params?: Record, headers?: RequestHeaders): Promise; - /** - * Make a DELETE HTTP request. - * @param {string} path - The partial path to append to the base url for the request. - * @param {Object} [params] - The parameters to send with the request. - * @param {Object} [headers] - Additional headers to send with the request. - * @returns {*} The response from the HTTP request. - */ - _delete(path: string, params?: Record, headers?: RequestHeaders): Promise; -} -export {}; diff --git a/types/errors/api/api_error.d.ts b/types/errors/api/api_error.d.ts deleted file mode 100644 index 7b7ac2cf5..000000000 --- a/types/errors/api/api_error.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * The ApiError class is used to represent errors that occurred while communicating with the EasyPost API. - * This class should not be instantiated directly. - * @internal - * @abstract - * @extends EasyPostError - * @property {string} [message] - The message to be displayed when the error is logged. - * @property {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @property {number} [statusCode] - The HTTP status code returned by the HTTP request to the EasyPost API. - * @property {EasyPostError[]} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class ApiError extends EasyPostError { - constructor({ message, code, statusCode, errors }?: { - message: any; - code: any; - statusCode: any; - errors: any; - }); - code: any; - errors: any; - message: any; - statusCode: any; -} -import EasyPostError from '../easypost_error'; diff --git a/types/errors/api/bad_request_error.d.ts b/types/errors/api/bad_request_error.d.ts deleted file mode 100644 index ae248c42d..000000000 --- a/types/errors/api/bad_request_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The BadRequestError class is used to represent a 400 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class BadRequestError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/external_api_error.d.ts b/types/errors/api/external_api_error.d.ts deleted file mode 100644 index 756e54175..000000000 --- a/types/errors/api/external_api_error.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * The ExternalApiError class is used to represent errors that occurred while communicating with an external API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - */ -export default class ExternalApiError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/forbidden_error.d.ts b/types/errors/api/forbidden_error.d.ts deleted file mode 100644 index 2d628e0ee..000000000 --- a/types/errors/api/forbidden_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The ForbiddenError class is used to represent a 403 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class ForbiddenError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/gateway_timeout_error.d.ts b/types/errors/api/gateway_timeout_error.d.ts deleted file mode 100644 index eca6b803f..000000000 --- a/types/errors/api/gateway_timeout_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The GatewayTimeoutError class is used to represent a 504 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class GatewayTimeoutError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/http_error.d.ts b/types/errors/api/http_error.d.ts deleted file mode 100644 index b7777bb6d..000000000 --- a/types/errors/api/http_error.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * The HttpError class is used to represent a generic HTTP-related error that occurred while communicating with the EasyPost API. - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class HTTPError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/internal_server_error.d.ts b/types/errors/api/internal_server_error.d.ts deleted file mode 100644 index bf6fd3f3a..000000000 --- a/types/errors/api/internal_server_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The InternalServerError class is used to represent a 500 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class InternalServerError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/invalid_request_error.d.ts b/types/errors/api/invalid_request_error.d.ts deleted file mode 100644 index d421c4f98..000000000 --- a/types/errors/api/invalid_request_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The InvalidRequestError class is used to represent a 422 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class InvalidRequestError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/method_not_allowed_error.d.ts b/types/errors/api/method_not_allowed_error.d.ts deleted file mode 100644 index 8bdbff591..000000000 --- a/types/errors/api/method_not_allowed_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The MethodNotAllowedError class is used to represent a 405 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class MethodNotAllowedError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/not_found_error.d.ts b/types/errors/api/not_found_error.d.ts deleted file mode 100644 index 8c615d166..000000000 --- a/types/errors/api/not_found_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The NotFoundError class is used to represent a 404 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class NotFoundError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/payment_error.d.ts b/types/errors/api/payment_error.d.ts deleted file mode 100644 index 20937098d..000000000 --- a/types/errors/api/payment_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The PaymentError class is used to represent a 402 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class PaymentError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/rate_limit_error.d.ts b/types/errors/api/rate_limit_error.d.ts deleted file mode 100644 index c601b37a4..000000000 --- a/types/errors/api/rate_limit_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The RateLimitError class is used to represent a 429 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class RateLimitError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/redirect_error.d.ts b/types/errors/api/redirect_error.d.ts deleted file mode 100644 index c01fb2b4b..000000000 --- a/types/errors/api/redirect_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The RedirectError class is used to represent a 3xx error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class RedirectError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/service_unavailable_error.d.ts b/types/errors/api/service_unavailable_error.d.ts deleted file mode 100644 index 98b3d5863..000000000 --- a/types/errors/api/service_unavailable_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The ServiceUnavailableError class is used to represent a 503 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class ServiceUnavailableError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/timeout_error.d.ts b/types/errors/api/timeout_error.d.ts deleted file mode 100644 index 36eb2763b..000000000 --- a/types/errors/api/timeout_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The TimeoutError class is used to represent a 408 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class TimeoutError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/unauthorized_error.d.ts b/types/errors/api/unauthorized_error.d.ts deleted file mode 100644 index b27a9f8a8..000000000 --- a/types/errors/api/unauthorized_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The UnauthorizedError class is used to represent a 401 error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class UnauthorizedError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/api/unknown_api_error.d.ts b/types/errors/api/unknown_api_error.d.ts deleted file mode 100644 index e1ca09270..000000000 --- a/types/errors/api/unknown_api_error.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The UnknownApiError class is used to represent a generic, unexpected error that occurred while communicating with the EasyPost API. - * @sealed - * @extends ApiError - * @param {string} [message] - The message to be displayed when the error is logged. - * @param {number} [statusCode] - The HTTP status code returned by the HTTP request. - * @param {string} [code] - The EasyPost-related error code returned by the EasyPost API. - * @param {Array} [errors] - An array of sub-errors returned by the EasyPost API. - */ -export default class UnknownApiError extends ApiError { -} -import ApiError from './api_error'; diff --git a/types/errors/easypost_error.d.ts b/types/errors/easypost_error.d.ts deleted file mode 100644 index f01ce2ee2..000000000 --- a/types/errors/easypost_error.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * The EasyPostError class is the base class for all errors that occur in the EasyPost Node.js client library. - * This class should not be instantiated directly. - * @internal - * @abstract - * @extends Error - * @param {string} [message] - The message to be displayed when the error is logged. - */ -export default class EasyPostError extends Error { - constructor({ message }?: { - message: any; - }); -} diff --git a/types/errors/error_handler.d.ts b/types/errors/error_handler.d.ts deleted file mode 100644 index fb08ac010..000000000 --- a/types/errors/error_handler.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export default class ErrorHandler { - /** - * Recursively traverses a JSON object or array and extracts error messages - * as strings. Adds the extracted messages to the specified messagesList array. - * - * @param {object|array|string} errorMessage - The JSON object or array to traverse. - * @param {array} messagesList - The array to which extracted error messages will be added. - */ - static traverseJsonElement(errorMessage: object | any[] | string, messagesList: any[]): void; - /** - * Calculate and generate the appropriate {@link ApiError} based on a received HTTP response error. - * @param {*} error - The errored HTTP response. - * @returns {ApiError} The `ApiError`-based error corresponding to the HTTP status code. - */ - static handleApiError(error: any): ApiError; -} diff --git a/types/errors/general/end_of_pagination_error.d.ts b/types/errors/general/end_of_pagination_error.d.ts deleted file mode 100644 index 0680ca37c..000000000 --- a/types/errors/general/end_of_pagination_error.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * The EndOfPaginationError class is used to represent an error that no more page can be retrieved - * @sealed - * @extends EasyPostError - * @param {string} [message] - The message to be displayed when the error is logged. - */ -export default class EndOfPaginationError extends EasyPostError { - constructor(); -} -import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/filtering_error.d.ts b/types/errors/general/filtering_error.d.ts deleted file mode 100644 index 2e0f426b5..000000000 --- a/types/errors/general/filtering_error.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * The FilteringError class is used to represent an error that occurred while filtering a list (e.g. a list of rates). - * @sealed - * @extends EasyPostError - * @param {string} [message] - The message to be displayed when the error is logged. - */ -export default class FilteringError extends EasyPostError { -} -import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/invalid_object_error.d.ts b/types/errors/general/invalid_object_error.d.ts deleted file mode 100644 index 1b03d441e..000000000 --- a/types/errors/general/invalid_object_error.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * The InvalidObjectError class is used to represent an error due to an invalid object (e.g. missing an expected property). - * @sealed - * @extends EasyPostError - * @param {string} [message] - The message to be displayed when the error is logged. - */ -export default class InvalidObjectError extends EasyPostError { -} -import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/invalid_parameter_error.d.ts b/types/errors/general/invalid_parameter_error.d.ts deleted file mode 100644 index 3ba132eab..000000000 --- a/types/errors/general/invalid_parameter_error.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * The InvalidParameterError class is used to represent an error due to an invalid function parameter. - * @sealed - * @extends EasyPostError - * @param {string} [message] - The message to be displayed when the error is logged. - */ -export default class InvalidParameterError extends EasyPostError { -} -import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/missing_parameter_error.d.ts b/types/errors/general/missing_parameter_error.d.ts deleted file mode 100644 index fcb556346..000000000 --- a/types/errors/general/missing_parameter_error.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * The MissingParameterError class is used to represent an error due to a missing expected function parameter. - * @sealed - * @extends EasyPostError - * @param {string} [message] - The message to be displayed when the error is logged. - */ -export default class MissingParameterError extends EasyPostError { -} -import EasyPostError from '../easypost_error'; diff --git a/types/errors/general/signature_verification_error.d.ts b/types/errors/general/signature_verification_error.d.ts deleted file mode 100644 index e506560b7..000000000 --- a/types/errors/general/signature_verification_error.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * The SignatureVerificationError class is used to represent an error due to a failed signature verification (e.g. a webhook HMAC signature). - * @sealed - * @extends EasyPostError - * @param {string} [message] - The message to be displayed when the error is logged. - */ -export default class SignatureVerificationError extends EasyPostError { -} -import EasyPostError from '../easypost_error'; diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index cd6fc2d3e..000000000 --- a/types/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import EasyPostClient from './easypost'; -export default EasyPostClient; diff --git a/types/models/address.d.ts b/types/models/address.d.ts deleted file mode 100644 index fe56fc0bd..000000000 --- a/types/models/address.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * An {@link https://docs.easypost.com/docs/addresses Address} represents people, places, and organizations in a number of contexts. - * @public - * @extends EasyPostObject - */ -export default class Address extends EasyPostObject { - street1?: string | null; - street2?: string | null; - city?: string | null; - state?: string | null; - zip?: string | null; - country?: string | null; - residential?: boolean | null; - carrier_facility?: string | null; - name?: string | null; - company?: string | null; - phone?: string | null; - email?: string | null; - federal_tax_id?: string | null; - state_tax_id?: string | null; - verifications?: Record | null; -} diff --git a/types/models/api_key.d.ts b/types/models/api_key.d.ts deleted file mode 100644 index 3e6d449c8..000000000 --- a/types/models/api_key.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * An {@link https://docs.easypost.com/docs/api-keys ApiKey} represents an authentication token that can be used to make requests to the EasyPost API. - * @public - * @extends EasyPostObject - */ -export default class ApiKey extends EasyPostObject { - active?: boolean | null; - key?: string | null; -} diff --git a/types/models/batch.d.ts b/types/models/batch.d.ts deleted file mode 100644 index 6495be9e7..000000000 --- a/types/models/batch.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/batches Batch} represents a collection of {@link Shipment shipments} that can be processed together. - * @public - * @extends EasyPostObject - */ -export default class Batch extends EasyPostObject { - label_url?: string | null; - num_shipments?: number | null; - pickup?: Record | null; - reference?: string | null; - scan_form?: Record | null; - shipments?: Record[] | null; - state?: string | null; - status?: Record | null; -} diff --git a/types/models/brand.d.ts b/types/models/brand.d.ts deleted file mode 100644 index 8c481a067..000000000 --- a/types/models/brand.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/users/brand Brand} represents custom branding for an EasyPost user's public-facing tracking details page. - * @public - * @extends EasyPostObject - */ -export default class Brand extends EasyPostObject { - ad_href?: string | null; - ad?: string | null; - background_color?: string | null; - color?: string | null; - logo_href?: string | null; - logo?: string | null; - theme?: 'theme1' | 'theme2' | null; - user_id?: string | null; -} diff --git a/types/models/carrier_account.d.ts b/types/models/carrier_account.d.ts deleted file mode 100644 index 566d5749d..000000000 --- a/types/models/carrier_account.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/carrier-accounts CarrierAccount} represents details about a specific enabled carrier, including credentials and other information. - * @public - * @extends EasyPostObject - */ -export default class CarrierAccount extends EasyPostObject { - billing_type?: string | null; - clone?: boolean | null; - credentials?: object | null; - description?: string | null; - fields?: Record | null; - readable?: string | null; - reference?: string | null; - test_credentials?: object | null; -} diff --git a/types/models/carrier_type.d.ts b/types/models/carrier_type.d.ts deleted file mode 100644 index a10d46c2c..000000000 --- a/types/models/carrier_type.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/carrier-types CarrierType} represents the valid fields for a {@link CarrierAccount carrier account}. - * @public - * @extends EasyPostObject - */ -export default class CarrierType extends EasyPostObject { - fields?: Record | null; - type?: string | null; -} diff --git a/types/models/claim.d.ts b/types/models/claim.d.ts deleted file mode 100644 index 271cc6405..000000000 --- a/types/models/claim.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * An {@link https://docs.easypost.com/docs/insurance/claims Claim} object represents claim for a {@link Shipment shipment}. - * @public - * @extends EasyPostObject - */ -export default class Claim extends EasyPostObject { - approved_amount?: string | null; - attachments?: string[] | null; - check_delivery_address?: string | null; - contact_email?: string | null; - description?: string | null; - history?: Record[] | null; - insurance_amount?: string | null; - insurance_id?: string | null; - payment_method?: string | null; - recipient_name?: unknown | null; - reference?: string | null; - requested_amount?: string | null; - salvage_value?: unknown | null; - shipment_id?: string | null; - status_detail?: string | null; - status_timestamp?: string | null; - status?: string | null; - tracking_code?: string | null; - type?: string | null; -} diff --git a/types/models/customs_info.d.ts b/types/models/customs_info.d.ts deleted file mode 100644 index ab81e75ba..000000000 --- a/types/models/customs_info.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/customs-infos CustomsInfo} represents a collection of {@link CustomsItem CustomsItems} and associated information for generating international shipping customs forms. - * @public - * @extends EasyPostObject - */ -export default class CustomsInfo extends EasyPostObject { - content_explanation?: string | null; - contents_type?: string | null; - customs_certify?: boolean | null; - customs_items?: unknown[] | null; - customs_signer?: string | null; - declaration?: string | null; - eel_pfc?: string | null; - non_delivery_option?: 'abandon' | 'return' | null; - restriction_comments?: string | null; - restriction_type?: 'none' | 'other' | 'quarantine' | 'sanitary_phytosanitary_inspection' | null; -} diff --git a/types/models/customs_item.d.ts b/types/models/customs_item.d.ts deleted file mode 100644 index 06f3d2bec..000000000 --- a/types/models/customs_item.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/customs-items CustomsItem} represents a single item being shipped internationally. - * @public - * @extends EasyPostObject - */ -export default class CustomsItem extends EasyPostObject { - code?: string | null; - currency?: string | null; - description?: string | null; - hs_tariff_number?: string | null; - origin_country?: string | null; - quantity?: number | null; - value?: number | null; - weight?: number | null; -} diff --git a/types/models/easypost_object.d.ts b/types/models/easypost_object.d.ts deleted file mode 100644 index 7101c8735..000000000 --- a/types/models/easypost_object.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * An EasyPostObject is the base class for all EasyPost API resources. - * @internal - * @abstract - */ -export default class EasyPostObject { - static id: string; - static object: string; - static mode: string; - static created_at: string; - static updated_at: string; - static _params: Record; - static [Symbol.hasInstance](instance: unknown): boolean; -} diff --git a/types/models/end_shipper.d.ts b/types/models/end_shipper.d.ts deleted file mode 100644 index 35ac071f2..000000000 --- a/types/models/end_shipper.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * An {@link https://docs.easypost.com/docs/endshippers EndShipper} represents a person or business entity that is authorized to purchase postage on behalf of another person and is ultimately responsible for the shipment. - * @public - * @extends EasyPostObject - */ -export default class EndShipper extends EasyPostObject { - street1?: string | null; - street2?: string | null; - city?: string | null; - state?: string | null; - zip?: string | null; - country?: string | null; - name?: string | null; - company?: string | null; - phone?: string | null; - email?: string | null; -} diff --git a/types/models/event.d.ts b/types/models/event.d.ts deleted file mode 100644 index 92831d553..000000000 --- a/types/models/event.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * An {@link https://docs.easypost.com/docs/events Event} represents a change in state for elements such as {@link Shipment shipments} and {@link Tracker trackers}, that triggers a {@link Webhook webhook}. - * @public - * @extends EasyPostObject - */ -export default class Event extends EasyPostObject { - completed_urls?: string[] | null; - description?: string | null; - pending_urls?: string[] | null; - previous_attributes?: Record | null; - result?: Record | null; - status?: 'completed' | 'failed' | 'in_queue' | 'retrying' | 'pending' | null; -} diff --git a/types/models/form.d.ts b/types/models/form.d.ts deleted file mode 100644 index ecd15f452..000000000 --- a/types/models/form.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/shipments/forms Form} represents a printable form for a {@link Shipment shipment}, such as a return packing slip, QR code or international shipping form. - * @public - * @extends EasyPostObject - */ -export default class Form extends EasyPostObject { - form_type?: 'cn22' | 'cod_return_label' | 'commercial_invoice' | 'high_value_report' | 'label_qr_code' | 'nafta_certificate_of_origin' | 'order_summary' | 'return_packing_slip' | 'rma_qr_code'; - form_url?: string | null; - submitted_electronically?: boolean | null; -} diff --git a/types/models/insurance.d.ts b/types/models/insurance.d.ts deleted file mode 100644 index a292f4e8b..000000000 --- a/types/models/insurance.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * An {@link https://docs.easypost.com/docs/api-keys Insurance} object represents insurance for a {@link Shipment shipment}. - * @public - * @extends EasyPostObject - */ -export default class Insurance extends EasyPostObject { - amount?: string | null; - fee?: Record | null; - from_address?: Record | null; - messages?: string[] | null; - provider_id?: string | null; - provider?: string | null; - reference?: string | null; - shipment_id?: string | null; - status?: 'new' | 'pending' | 'purchased' | 'failed' | 'cancelled' | null; - to_address?: Record | null; - tracking_code?: string | null; - tracker?: Record | null; -} diff --git a/types/models/order.d.ts b/types/models/order.d.ts deleted file mode 100644 index e16e3c1ac..000000000 --- a/types/models/order.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Constants from '../constants'; -import EasyPostObject from './easypost_object'; -/** - * An {@link https://docs.easypost.com/docs/orders Order} represents a collection of packages, intended only for multi-parcel shipments. - * @public - * @extends EasyPostObject - */ -export default class Order extends EasyPostObject { - buyer_address?: Record | null; - from_address?: Record | null; - is_return?: boolean | null; - messages?: Record[] | null; - rates?: Parameters[0] | null; - reference?: string | null; - return_address?: Record | null; - shipments?: Record[] | null; - to_address?: Record | null; - /** - * Get the lowest rate for this {@link Order}. - * @public - * @param {string[]} [carriers] - List of allowed carriers to filter by - * @param {string[]} [services] - List of allowed services to filter by - * @returns {Rate} - The lowest rate - * @throws {FilteringError} - If no applicable rates are found - */ - lowestRate(carriers?: string[], services?: string[]): ReturnType; -} diff --git a/types/models/parcel.d.ts b/types/models/parcel.d.ts deleted file mode 100644 index 07a5c1b65..000000000 --- a/types/models/parcel.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/parcels Parcel} represents a physical container being shipped, such as a box or envelope, with corresponding dimensions and weight. - * @public - * @extends EasyPostObject - */ -export default class Parcel extends EasyPostObject { - height?: number | null; - length?: number | null; - predefined_package?: string | null; - weight?: number | null; - width?: number | null; -} diff --git a/types/models/payload.d.ts b/types/models/payload.d.ts deleted file mode 100644 index 280e03518..000000000 --- a/types/models/payload.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/events/payloads Payload} represents an attempt by EasyPost to send an {@link Event event} to a {@link Webhook webhook}. - * @public - * @extends EasyPostObject - */ -export default class Payload extends EasyPostObject { - response_body?: string | null; -} diff --git a/types/models/pickup.d.ts b/types/models/pickup.d.ts deleted file mode 100644 index 42381330c..000000000 --- a/types/models/pickup.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import Constants from '../constants'; -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/pickups Pickup} represents a scheduled carrier pickup of packages from an {@link https://docs.easypost.com/docs/addresses Address}. - * @public - * @extends EasyPostObject - */ -export default class Pickup extends EasyPostObject { - address?: Record | null; - carrier_accounts?: Record[] | null; - confirmation?: string | null; - instructions?: string | null; - is_account_address?: boolean | null; - max_datetime?: string | null; - messages?: Record[] | null; - min_datetime?: string | null; - pickup_rates?: Parameters[0] | null; - reference?: string | null; - shipment?: Record | null; - status?: 'unknown' | 'scheduled' | 'canceled' | null; - /** - * Get the lowest rate for this {@link Pickup}. - * @public - * @param {string[]} [carriers] - List of allowed carriers to filter by - * @param {string[]} [services] - List of allowed services to filter by - * @returns {Rate} - The lowest rate - * @throws {FilteringError} - If no applicable rates are found - */ - lowestRate(carriers?: string[], services?: string[]): ReturnType; -} diff --git a/types/models/pickup_rate.d.ts b/types/models/pickup_rate.d.ts deleted file mode 100644 index a3af928c2..000000000 --- a/types/models/pickup_rate.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link PickupRate} represents a {@link Rate rate} for a {@link Pickup pickup}. - * @public - * @extends EasyPostObject - */ -export default class PickupRate extends EasyPostObject { - carrier?: string | null; - currency?: string | null; - pickup_id?: string | null; - rate?: string | null; - service?: string | null; -} diff --git a/types/models/postage_label.d.ts b/types/models/postage_label.d.ts deleted file mode 100644 index 99ec96324..000000000 --- a/types/models/postage_label.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link PostageLabel} represents a physical label to affix to a {@link Parcel parcel} when shipping. - * @public - * @extends EasyPostObject - */ -export default class PostageLabel extends EasyPostObject { - label_date?: string | null; - label_epl2_url?: string | null; - label_file_type?: string | null; - label_pdf_url?: string | null; - label_resolution?: number | null; - label_size?: string | null; - label_type?: string | null; - label_url?: string | null; - label_zpl_url?: string | null; -} diff --git a/types/models/rate.d.ts b/types/models/rate.d.ts deleted file mode 100644 index 0563592a4..000000000 --- a/types/models/rate.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/shipments/rates Rate} represents pricing information for shipping a specific {@link Parcel} with a specific carrier and service level. - * @public - * @extends EasyPostObject - */ -export default class Rate extends EasyPostObject { - billing_type?: string | null; - carrier_account_id?: string | null; - carrier?: string | null; - currency?: string | null; - delivery_date_guaranteed?: boolean | null; - delivery_date?: string | null; - delivery_days?: number | null; - est_delivery_days?: number | null; - list_currency?: string | null; - list_rate?: string | null; - rate?: string | null; - retail_currency?: string | null; - retail_rate?: string | null; - service?: string | null; - shipment_id?: string | null; -} diff --git a/types/models/refund.d.ts b/types/models/refund.d.ts deleted file mode 100644 index 76157dde4..000000000 --- a/types/models/refund.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/refunds Refund} represents a refunded {@link Shipment}. - * @public - * @extends EasyPostObject - */ -export default class Refund extends EasyPostObject { - carrier?: string | null; - confirmation_number?: string | null; - shipment_id?: string | null; - status?: 'submitted' | 'refunded' | 'rejected' | null; - tracking_code?: string | null; -} diff --git a/types/models/report.d.ts b/types/models/report.d.ts deleted file mode 100644 index 221d7e6e6..000000000 --- a/types/models/report.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/reports Report} represents a CSV file containing a log of all objects within a specific time frame. - * @public - * @extends EasyPostObject - */ -export default class Report extends EasyPostObject { - end_date?: string | null; - include_children?: boolean | null; - send_email?: boolean | null; - start_date?: string | null; - status?: 'new' | 'available' | 'failed' | null; - url_expires_at?: string | null; - url?: string | null; -} diff --git a/types/models/scan_form.d.ts b/types/models/scan_form.d.ts deleted file mode 100644 index 536057823..000000000 --- a/types/models/scan_form.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/scan-form ScanForm} represents a single document that can be scanned to mark all included tracking codes as "Accepted for Shipment" by the carrier. - * @public - * @extends EasyPostObject - */ -export default class ScanForm extends EasyPostObject { - address?: Record | null; - batch_id?: string | null; - form_file_type?: string | null; - form_url?: string | null; - message?: string | null; - status?: 'creating' | 'created' | 'failed' | null; - tracking_codes?: string[] | null; -} diff --git a/types/models/shipment.d.ts b/types/models/shipment.d.ts deleted file mode 100644 index 16285e352..000000000 --- a/types/models/shipment.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Constants from '../constants'; -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/shipments Shipment} represents a physical {@link Parcel}, the origin and destination {@link Address Addresses}, and any associated {@link CustomsInfo}. - * @public - * @extends EasyPostObject - */ -export default class Shipment extends EasyPostObject { - batch_id?: string | null; - batch_message?: string | null; - batch_status?: string | null; - buyer_address?: Record | null; - customs_info?: Record | null; - fees?: Record[] | null; - forms?: Record[] | null; - from_address?: Record | null; - insurance?: Record | null; - is_return?: boolean | null; - messages?: Record[] | null; - options?: Record | null; - parcel?: Record | null; - postage_label?: Record | null; - rates?: Parameters[0] | null; - reference?: string | null; - refund_status?: 'submitted' | 'refunded' | 'rejected' | null; - return_address?: Record | null; - scan_form?: Record | null; - selected_rate?: Parameters[0][number] | null; - status?: string | null; - to_address?: Record | null; - tracker?: Record | null; - tracking_code?: string | null; - usps_zone?: string | null; - /** - * Get the lowest rate for this {@link Shipment}. - * @public - * @param {string[]} [carriers] - List of allowed carriers to filter by - * @param {string[]} [services] - List of allowed services to filter by - * @returns {Rate} - The lowest rate - * @throws {FilteringError} - If no applicable rates are found - */ - lowestRate(carriers?: string[], services?: string[]): ReturnType; -} diff --git a/types/models/tracker.d.ts b/types/models/tracker.d.ts deleted file mode 100644 index d8c87a5f9..000000000 --- a/types/models/tracker.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/trackers Tracker} represents the available tracking information for a package. - * @public - * @extends EasyPostObject - */ -export default class Tracker extends EasyPostObject { - carrier_detail?: Record | null; - carrier?: string | null; - est_delivery_date?: string | null; - fees?: Record[] | null; - finalized?: boolean | null; - is_return?: boolean | null; - public_url?: string | null; - shipment_id?: string | null; - signed_by?: string | null; - status_detail?: string | null; - status?: string | null; - tracking_code?: string | null; - tracking_details?: Record[] | null; - weight?: number | null; -} diff --git a/types/models/user.d.ts b/types/models/user.d.ts deleted file mode 100644 index 20a4a5aec..000000000 --- a/types/models/user.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/users ApiKey} represents an EasyPost account or child account. - * @public - * @extends EasyPostObject - */ -export default class User extends EasyPostObject { - api_keys?: Record[] | null; - balance?: string | null; - cc_fee_rate?: string | null; - children?: Record[] | null; - email?: string | null; - insurance_fee_minimum?: string | null; - insurance_fee_rate?: string | null; - name?: string | null; - parent_id?: string | null; - phone_number?: string | null; - price_per_shipment?: string | null; - recharge_amount?: string | null; - recharge_threshold?: string | null; - secondary_recharge_amount?: string | null; -} diff --git a/types/models/webhook.d.ts b/types/models/webhook.d.ts deleted file mode 100644 index 9590df533..000000000 --- a/types/models/webhook.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import EasyPostObject from './easypost_object'; -/** - * A {@link https://docs.easypost.com/docs/webhooks Webhook} represents a URL that will receive notifications when certain {@link Event} occur. - * @public - * @extends EasyPostObject - */ -export default class Webhook extends EasyPostObject { - custom_headers?: { - key: string; - value: string; - }[] | null; - disabled_at?: string | null; - url?: string | null; -} diff --git a/types/services/address_service.d.ts b/types/services/address_service.d.ts deleted file mode 100644 index 1cae5c859..000000000 --- a/types/services/address_service.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -type AddressParams = Record & { - verify?: unknown; - verify_strict?: unknown; - verify_carrier?: unknown; -}; -type PaginationCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create an {@link Address address}. - * See {@link https://docs.easypost.com/docs/addresses#create-an-address EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the address to be created. - * @returns {Address} - The created address. - */ - create(params: AddressParams): Promise; - /** - * Create and verify an {@link Address address} in a single request. - * See {@link https://docs.easypost.com/docs/addresses#verify-an-address EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the address to be created. - * @returns {Address} - The created and verified address. - */ - createAndVerify(params: AddressParams): Promise; - /** - * Retrieve all {@link Address addresses} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/addresses#retrieve-all-addresses EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the list of addresses. - * @returns {Object} - An object containing a list of {@link Address addresses} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Address collection. - * @param {Object} addresses An object containing a list of {@link Address addresses} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(addresses: PaginationCollection, pageSize?: number): Promise; - /** - * Retrieve an {@link Address address} by its ID. - * See {@link https://docs.easypost.com/docs/addresses#retrieve-an-address EasyPost API Documentation} for more information. - * @param {string} id - The ID of the address to retrieve. - * @returns {Address} - The retrieved address. - */ - retrieve(id: string): Promise; - /** - * Verify an {@link Address address} by its ID. - * See {@link https://docs.easypost.com/docs/addresses#verify-an-address EasyPost API Documentation} for more information. - * @param {string} id - The ID of the address to verify. - * @returns {Address} - The verified address. - */ - verifyAddress(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/api_key_service.d.ts b/types/services/api_key_service.d.ts deleted file mode 100644 index cdce598b3..000000000 --- a/types/services/api_key_service.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Retrieve API Keys for a specified {@link User user}. - * See {@link https://docs.easypost.com/docs/api-keys#retrieve-an-api-key EasyPost API Documentation} for more information. - * @param {string} id - The ID of the user to retrieve keys for. - * @returns {Array} - List of associated API Keys. - * @throws {FilteringError} If user or API Keys are not found. - */ - retrieveApiKeysForUser(id: string): Promise; - /** - * Retrieve all {@link ApiKey API keys} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/api-keys#retrieve-an-api-key EasyPost API Documentation} for more information. - * @returns {Object} - An object containing the API keys associated with the current authenticated user and its child users. - */ - all(params?: Record): Promise; - /** - * Create an API key for a child or referral customer user. - * See {@link https://docs.easypost.com/docs/api-keys#create-an-api-key EasyPost API Documentation} for more information. - * @param {string} mode - The mode for the API key (either "production" or "test"). - * @returns {ApiKey} - The created API key. - */ - create(mode: string): Promise; - /** - * Delete an API key for a child or referral customer user. - * See {@link https://docs.easypost.com/docs/api-keys#delete-an-api-key EasyPost API Documentation} for more information. - * @param {string} id - The ID of the API key to delete. - * @returns {Promise|Promise} - A promise that resolves if the API key was successfully deleted. - */ - delete(id: string): Promise; - /** - * Enable a child or referral customer API key. - * See {@link https://docs.easypost.com/docs/api-keys#enable-an-api-key EasyPost API Documentation} for more information. - * @param {string} id - The ID of the API key to enable. - * @returns {ApiKey} - The enabled API key. - */ - enable(id: string): Promise; - /** - * Disable a child or referral customer API key. - * See {@link https://docs.easypost.com/docs/api-keys#disable-an-api-key EasyPost API Documentation} for more information. - * @param {string} id - The ID of the API key to disable. - * @returns {ApiKey} - The disabled API key. - */ - disable(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/base_service.d.ts b/types/services/base_service.d.ts deleted file mode 100644 index 306182d8b..000000000 --- a/types/services/base_service.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Converts model instances and nested data into plain JSON-compatible objects while - * preserving model helper methods as non-enumerable properties. - * @internal - * @param {*} response The value to serialize. - * @returns {*} A plain object/array/scalar. - */ - _toPlainEasyPostObject(response: any): any; - /** - * Converts a JSON response and all its nested elements to associated {@link EasyPostObject}-based class instances. - * @internal - * @param {*} response The JSON response to convert (usually a `Map` or `Array`). - * @param {*} params The parameters passed when fetching the response. - * @returns {*} An {@link EasyPostObject}-based class instance or an `Array` of {@link EasyPostObject}-based class instances. - */ - _buildEasyPostObject(response: any, params: any): any; - /** - * Converts a JSON response to plain JSON-compatible output while preserving model-based conversion internally. - * @internal - * @param {*} response The JSON response to convert (usually a `Map` or `Array`). - * @param {*} params The parameters passed when fetching the response. - * @returns {*} A plain object or array suitable for JSON serialization. - */ - _convertToEasyPostObject(response: any, params?: any): any; - /** - * Creates an EasyPost Object via the API. - * @internal - * @param {string} url The URL to send the API request to. - * @param {Object} params The parameters to send with the API request. - * @returns {EasyPostObject|Promise} The created {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - _create(url: any, params: any): Promise; - /** - * Retrieve a list of records from the API. - * @internal - * @param {string} url The URL to send the API request to. - * @param {Object} [params] The parameters to send with the API request. - * @returns {EasyPostObject|EasyPostObject[]|Promise} The retrieved {@link EasyPostObject}-based class instance(s), or a `Promise` that rejects with an error. - */ - _all(url: any, params?: {}): Promise; - /** - * Retrieve a record from the API. - * @internal - * @param {string} url The URL to send the API request to. - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - _retrieve(url: any): Promise; - /** - * Retrieve the next page of specific collection of object - * @internal - * @param {string} url The URL to send the API request to. - * @param {Object} collection The collection of a specific object. - * @param {Number} pageSize The number of records to return on each page. - * @param {Object} optionalParams The optional param for additional value in the query string. - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - * TODO: Implement this function in EndShippers and Batches once the API supports them properly. - */ - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/batch_service.d.ts b/types/services/batch_service.d.ts deleted file mode 100644 index 541140201..000000000 --- a/types/services/batch_service.d.ts +++ /dev/null @@ -1,72 +0,0 @@ -export declare const DEFAULT_LABEL_FORMAT = "pdf"; -type BatchParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link Batch batch}. - * See {@link https://docs.easypost.com/docs/batches#create-a-batch EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the batch to be created. - * @returns {Batch} - The created batch. - */ - create(params: BatchParams): Promise; - /** - * Add {@link Shipment shipments} to a {@link Batch batch}. - * See {@link https://docs.easypost.com/docs/batches#add-shipments-to-a-batch EasyPost API Documentation} for more information. - * @param {string} id - The id of the batch to add shipments to. - * @param {Array} shipmentIds - The ids of the shipments to add to the batch. - * @returns {Batch} - The updated batch. - */ - addShipments(id: string, shipmentIds: string[]): Promise; - /** - * Removes {@link Shipment shipments} from a {@link Batch batch}. - * See {@link https://docs.easypost.com/docs/batches#remove-shipments-from-a-batch EasyPost API Documentation} for more information. - * @param {string} id - The id of the batch to remove shipments from. - * @param {Array} shipmentIds - The ids of the shipments to remove from the batch. - * @returns {Batch} - The updated batch. - */ - removeShipments(id: string, shipmentIds: string[]): Promise; - /** - * Generate a label for a {@link Batch batch}. - * See {@link https://docs.easypost.com/docs/batches#batch-labels EasyPost API Documentation} for more information. - * @param {string} id - The id of the batch to generate a label for. - * @param {string} fileFormat - The format of the label to generate. Defaults to 'pdf'. - * @returns {Batch} - The updated batch. - */ - generateLabel(id: string, fileFormat?: string): Promise; - /** - * Create a {@link ScanForm scan form} for a {@link Batch batch}. - * See {@link https://docs.easypost.com/docs/batches#manifesting-scan-form EasyPost API Documentation} for more information. - * @param {string} id - The id of the batch to create a scan form for. - * @returns {Batch} - The updated batch. - */ - createScanForm(id: string): Promise; - /** - * Purchase a {@link Batch batch}. - * See {@link https://docs.easypost.com/docs/batches#buy-a-batch EasyPost API Documentation} for more information. - * @param {string} id - The id of the batch to purchase. - * @returns {Batch} - The purchased batch. - */ - buy(id: string): Promise; - /** - * Retrieve all {@link Batch batches} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/batches#retrieve-all-batches EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the list of batches. - * @returns {Object} - An object containing a list of {@link Batch batches} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve a {@link Batch batch} by its ID. - * See {@link https://docs.easypost.com/docs/batches#retrieve-batch EasyPost API Documentation} for more information. - * @param {string} id - The ID of the batch to retrieve. - * @returns {Batch} - The retrieved batch. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/beta_rate_service.d.ts b/types/services/beta_rate_service.d.ts deleted file mode 100644 index e96810bcb..000000000 --- a/types/services/beta_rate_service.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare function _default(easypostClient: any): { - new (): {}; - /** - * Retrieve a list of stateless {@link Rate rates} based on the provided parameters. - * @param {Object} params - Map of parameters for the API call - * @returns {Rate[]} - List of stateless rates - */ - retrieveStatelessRates(params: any): Rate[]; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/beta_referral_customer_service.d.ts b/types/services/beta_referral_customer_service.d.ts deleted file mode 100644 index 70eb9e8cb..000000000 --- a/types/services/beta_referral_customer_service.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -declare function _default(easypostClient: any): { - new (): {}; - /** - * Add an existing Stripe payment method to a {@link User referral customer's} account. - * @param {string} stripeCustomerId - The Stripe account's ID. - * @param {string} paymentMethodReference - Reference of Stripe payment method. - * @param {string} [priority] - Which priority to set the payment method to ('primary' or 'secondary'). - * @returns {Object} - A JSON object representing the payment method. - */ - addPaymentMethod(stripeCustomerId: string, paymentMethodReference: string, priority?: string | undefined): any; - /** - * Refund by amount for a recent payment. - * @param {number} refundAmount - Amount to be refunded by cents. - * @returns {Object} - A JSON object representing the refund. - */ - refundByAmount(refundAmount: number): any; - /** - * Refund a payment by a payment log ID. - * @param {string} paymentLogId - ID of the payment log. - * @returns {object} - Returns BetaPaymentRefund object. - */ - refundByPaymentLog(paymentLogId: string): object; - /** - * Creates a client secret to use with Stripe when adding a credit card. - * @returns {object} - A JSON object representing the client secret. - */ - createCreditCardClientSecret(): object; - /** - * Creates a client secret to use with Stripe when adding a credit card. - * @returns {object} - A JSON object representing the client secret. - */ - createBankAccountClientSecret(returnUrl: any): object; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/billing_service.d.ts b/types/services/billing_service.d.ts deleted file mode 100644 index 10da9598b..000000000 --- a/types/services/billing_service.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -type PaymentMethodObject = { - id: string; - object: string; -}; -type PaymentMethodsResponse = Record & { - id: string | null; - primary_payment_method?: PaymentMethodObject | null; - secondary_payment_method?: PaymentMethodObject | null; -}; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Fund your EasyPost wallet by charging your primary or secondary payment method on file. - * See {@link https://docs.easypost.com/docs/users/billing#add-funds-to-your-wallet-one-time-charge EasyPost API Documentation} for more information. - * @param {String} amount - The amount to charge to your payment method. - * @param {String} priority - The priority of the payment method to charge. Can be either 'primary' or 'secondary'. - */ - fundWallet(amount: string, priority?: string): Promise; - /** - * Delete a payment method from the current authenticated user's account. - * See {@link https://docs.easypost.com/docs/users/billing#delete-a-payment-method EasyPost API Documentation} for more information. - * @param {String} priority - The priority of the payment method to delete. Can be either 'primary' or 'secondary'. - */ - deletePaymentMethod(priority: string): Promise; - /** - * Retrieve all payment methods associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/users/billing#retrieve-payment-methods EasyPost API Documentation} for more information. - * @returns {Object} - An object containing the payment methods associated with the current authenticated user. - */ - retrievePaymentMethods(): Promise; - /** - * Get payment info (type of the payment method and ID of the payment method) - * This function is intended for internal use only, please avoid using this function - * @private - * @param {String} priority - The priority of the payment method to retrieve. Can be either 'primary' or 'secondary'. - * @returns {string[]} - An array of two strings, the first being the endpoint of the payment method and the second being the ID of the payment method. - */ - _getPaymentInfo(priority: string): Promise<[string, string]>; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/carrier_account_service.d.ts b/types/services/carrier_account_service.d.ts deleted file mode 100644 index 7c053c2ce..000000000 --- a/types/services/carrier_account_service.d.ts +++ /dev/null @@ -1,65 +0,0 @@ -type CarrierAccountParams = Record & { - type?: string; -}; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link CarrierAccount carrier account}. - * See {@link https://docs.easypost.com/docs/carrier-accounts#create-a-carrieraccount EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the carrier account to be created. - * @returns {CarrierAccount} - The created carrier account. - */ - create(params: CarrierAccountParams): Promise; - /** - * Update a {@link CarrierAccount carrier account}. - * See {@link https://docs.easypost.com/docs/carrier-accounts#update-a-carrieraccount EasyPost API Documentation} for more information. - * @param {string} id - The id of the carrier account to be updated. - * @param {Object} params - Parameters for the carrier account to be updated. - * @returns {CarrierAccount} - The updated carrier account. - */ - update(id: string, params: Record): Promise; - /** - * Delete a {@link CarrierAccount carrier account}. - * See {@link https://docs.easypost.com/docs/carrier-accounts#delete-a-carrieraccount EasyPost API Documentation} for more information. - * @param {string} id - The id of the carrier account to be deleted. - * @returns {Promise|Promise} - A promise that resolves when the carrier account has been deleted. - */ - delete(id: string): Promise; - /** - * Returns the correct carrier_account endpoint when creating a record based on the type. - * @private - * @param {string} carrierAccountType - The type of carrier account to be created. - * @returns {string} - The endpoint to be used for the carrier account creation request. - */ - _selectCarrierAccountCreationEndpoint(carrierAccountType: string): string; - /** - * Wraps the carrier account parameters in the correct format based on the type. - * @private - * @param {string} carrierAccountType - The type of carrier account to be created. - * @param {Object} params - The parameters for the carrier account to be created. - * @returns {Object} - The wrapped carrier account parameters. - */ - _wrapCarrierAccountParams(carrierAccountType: string, params: Record): Record; - /** - * Retrieve all {@link CarrierAccount carrier accounts} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/carrier-accounts#retrieve-all-carrieraccounts EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the list of carrier accounts. - * @returns {Object} - An object containing a list of {@link CarrierAccount carrier accounts} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve a {@link CarrierAccount carrier account} by its ID. - * See {@link https://docs.easypost.com/docs/carrier-accounts#retrieve-a-carrieraccount EasyPost API Documentation} for more information. - * @param {string} id - The ID of the carrier account to retrieve. - * @returns {CarrierAccount} - The retrieved carrier account. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/carrier_metadata_service.d.ts b/types/services/carrier_metadata_service.d.ts deleted file mode 100644 index a89bc8f99..000000000 --- a/types/services/carrier_metadata_service.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @extends baseService - */ -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Retrieve a list of carrier metadata based on the provided parameters. - * @param {Array} carriers - List of carrier in string - * @param {Array} type - List of types in string - * @returns {Object[]} - List of carrier metadata - */ - retrieve(carriers?: string[] | null, types?: string[] | null): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/carrier_type_service.d.ts b/types/services/carrier_type_service.d.ts deleted file mode 100644 index 74877c7ed..000000000 --- a/types/services/carrier_type_service.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Retrieve all {@link CarrierType carrier types} available to the current authenticated user. - * See {@link https://docs.easypost.com/docs/carrier-types#retrieve-available-carrier-types EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the list of carrier types. - * @returns {CarrierType[]} - A list of {@link CarrierType carrier types}. - */ - all(params?: Record): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/claim_service.d.ts b/types/services/claim_service.d.ts deleted file mode 100644 index 6b1b8b22b..000000000 --- a/types/services/claim_service.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -type ClaimParams = Record; -type ClaimCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link Claim claim} record. - * @param {Object} params - Parameters for the claim to be created. - * @returns {Claim} - The created claim. - */ - create(params: ClaimParams): Promise; - /** - * Retrieve all {@link Claim} records associated with the current authenticated user. - * @param {Object} [params] - Parameters to filter the claim records. - * @returns {Object} - An object containing the list of {@link Claim claim} records and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Claim collection. - * @param {Object} claims An object containing a list of {@link Claim claims} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(claims: ClaimCollection, pageSize?: number | null): Promise; - /** - * Retrieve a {@link Claim claim} record by its ID. - * @param {string} id - The ID of the claim to retrieve. - * @returns {Claim} - The retrieved claim. - */ - retrieve(id: string): Promise; - /** - * Cancel a {@link Claim claim} record by its ID. - * @param {string} id - The ID of the claim to be canceled. - * @returns {Claim} - The canceled claim. - */ - cancel(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/customer_portal_service.d.ts b/types/services/customer_portal_service.d.ts deleted file mode 100644 index ddb58fc18..000000000 --- a/types/services/customer_portal_service.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a Portal Session. - * @param {Object} [params] - The parameters to create a session from. - * @returns {Object} - An object containing the created session. - */ - createAccountLink(params?: Record): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/customs_info_service.d.ts b/types/services/customs_info_service.d.ts deleted file mode 100644 index 156cc7f89..000000000 --- a/types/services/customs_info_service.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -type CustomsInfoParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link CustomsInfo customs info} record. - * See {@link https://docs.easypost.com/docs/customs-infos#create-a-customsinfo EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the customs info to be created. - * @returns {CustomsInfo} - The created customs info. - */ - create(params: CustomsInfoParams): Promise; - /** - * Retrieve a {@link CustomsInfo customs info} record by its ID. - * See {@link https://docs.easypost.com/docs/customs-infos#retrieve-a-customsinfo EasyPost API Documentation} for more information. - * @param {string} id - The ID of the customs info to retrieve. - * @returns {CustomsInfo} - The retrieved customs info. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/customs_item_service.d.ts b/types/services/customs_item_service.d.ts deleted file mode 100644 index e572b382e..000000000 --- a/types/services/customs_item_service.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -type CustomsItemParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link CustomsItem customs item}. - * See {@link https://docs.easypost.com/docs/customs-items#create-a-customsitem EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the customs item to be created. - * @returns {CustomsItem} - The created customs item. - */ - create(params: CustomsItemParams): Promise; - /** - * Retrieve a {@link CustomsItem customs item} by its ID. - * See {@link https://docs.easypost.com/docs/customs-items#retrieve-a-customsitem EasyPost API Documentation} for more information. - * @param {string} id - The ID of the customs item to retrieve. - * @returns {CustomsItem} - The retrieved customs item. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/embeddable_service.d.ts b/types/services/embeddable_service.d.ts deleted file mode 100644 index f4fcab4cb..000000000 --- a/types/services/embeddable_service.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create an Embeddable Session. - * @param {Object} [params] - The parameters to create a session from. - * @returns {Object} - An object containing the created session. - */ - createSession(params?: Record): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/end_shipper_service.d.ts b/types/services/end_shipper_service.d.ts deleted file mode 100644 index d6a24618a..000000000 --- a/types/services/end_shipper_service.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -type EndShipperParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create an {@link EndShipper end shipper}. - * See {@link https://docs.easypost.com/docs/endshippers#create-an-endshipper EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the end shipper to be created. - * @returns {EndShipper} - The created end shipper. - */ - create(params: EndShipperParams): Promise; - /** - * Update an {@link EndShipper end shipper}. - * See {@link https://docs.easypost.com/docs/endshippers#update-an-endshipper EasyPost API Documentation} for more information. - * @param {string} id - The ID of the end shipper to update. - * @param {Object} params - Parameters for the end shipper to be updated. - * @returns {EndShipper} - The updated end shipper. - */ - update(id: string, params: EndShipperParams): Promise; - /** - * Retrieve an {@link EndShipper end shipper} by its ID. - * See {@link https://docs.easypost.com/docs/endshippers#retrieve-an-endshipper EasyPost API Documentation} for more information. - * @param {string} id - The ID of the end shipper to retrieve. - * @returns {EndShipper} - The retrieved end shipper. - */ - retrieve(id: string): Promise; - /** - * Retrieve all {@link EndShipper end shippers} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/endshippers#retrieve-all-endshippers EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the list of end shippers. - * @returns {Object} - An object containing a list of {@link EndShipper end shippers} and pagination information. - */ - all(params?: Record): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/event_service.d.ts b/types/services/event_service.d.ts deleted file mode 100644 index e613f96eb..000000000 --- a/types/services/event_service.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -type EventCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Retrieve all {@link Payload payloads} for an {@link Event event}. - * See {@link https://docs.easypost.com/docs/events/payloads#retrieve-all-payloads EasyPost API Documentation} for more information. - * @param {string} id - The ID of the event to retrieve payloads for. - * @returns {Payload[]} - A list of {@link Payload payloads} for the event. - */ - retrieveAllPayloads(id: string): Promise; - /** - * Retrieve a specific {@link Payload payload} for an {@link Event event}. - * See {@link https://docs.easypost.com/docs/events/payloads#retrieve-a-payload EasyPost API Documentation} for more information. - * @param {string} id - The ID of the event to retrieve the payload for. - * @param {string} payloadId - The ID of the payload to retrieve. - * @returns {Payload} - The {@link Payload payload} for the event. - */ - retrievePayload(id: string, payloadId: string): Promise; - /** - * Retrieve all {@link Event events} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/events#retrieve-all-events EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the list of events. - * @returns {Object} - An object containing the list of {@link Event events} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Event collection. - * @param {Object} events An object containing a list of {@link Event events} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(events: EventCollection, pageSize?: number | null): Promise; - /** - * Retrieve an {@link Event event} by its ID. - * See {@link https://docs.easypost.com/docs/events#retrieve-an-event EasyPost API Documentation} for more information. - * @param {string} id - The ID of the event to retrieve. - * @returns {Event} - The retrieved event. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/fedex_registration_service.d.ts b/types/services/fedex_registration_service.d.ts deleted file mode 100644 index 3bb03f1a4..000000000 --- a/types/services/fedex_registration_service.d.ts +++ /dev/null @@ -1,81 +0,0 @@ -type FedExValidationMap = Record & { - name?: string | null; -}; -type FedExParams = Record & { - address_validation?: FedExValidationMap; - pin_validation?: FedExValidationMap; - invoice_validation?: FedExValidationMap; - easypost_details?: Record; -}; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Register the billing address for a FedEx account. - * @param {string} fedexAccountNumber - The FedEx account number. - * @param {Object} params - Map of parameters. - * @returns {Object} - */ - registerAddress(fedexAccountNumber: string, params: FedExParams): Promise; - /** - * Request a PIN for FedEx account verification. - * @param {string} fedexAccountNumber - The FedEx account number. - * @param {string} pinMethodOption - The PIN delivery method: "SMS", "CALL", or "EMAIL". - * @param {Object} params - Map of parameters. - * @returns {Object} - */ - requestPin(fedexAccountNumber: string, pinMethodOption: string, params: FedExParams): Promise; - /** - * Validate the PIN entered by the user for FedEx account verification. - * @param {string} fedexAccountNumber - The FedEx account number. - * @param {Object} params - Map of parameters. - * @returns {Object} - */ - validatePin(fedexAccountNumber: string, params: FedExParams): Promise; - /** - * Submit invoice information to complete FedEx account registration. - * @param {string} fedexAccountNumber - The FedEx account number. - * @param {Object} params - Map of parameters. - * @returns {Object} - */ - submitInvoice(fedexAccountNumber: string, params: FedExParams): Promise; - /** - * Wraps address validation parameters and ensures the "name" field exists. - * If not present, generates a UUID (with hyphens removed) as the name. - * @private - * @param {Object} params - The original parameters map. - * @returns {Object} - A new map with properly wrapped address_validation and easypost_details. - */ - _wrapAddressValidation(params: FedExParams): Record; - /** - * Wraps PIN validation parameters and ensures the "name" field exists. - * If not present, generates a UUID (with hyphens removed) as the name. - * @private - * @param {Object} params - The original parameters map. - * @returns {Object} - A new map with properly wrapped pin_validation and easypost_details. - */ - _wrapPinValidation(params: FedExParams): Record; - /** - * Wraps invoice validation parameters and ensures the "name" field exists. - * If not present, generates a UUID (with hyphens removed) as the name. - * @private - * @param {Object} params - The original parameters map. - * @returns {Object} - A new map with properly wrapped invoice_validation and easypost_details. - */ - _wrapInvoiceValidation(params: FedExParams): Record; - /** - * Ensures the "name" field exists in the provided map. - * If not present, generates a UUID (with hyphens removed) as the name. - * This follows the pattern used in the web UI implementation. - * @private - * @param {Object} map - The map to ensure the "name" field in. - */ - _ensureNameField(map: FedExValidationMap): void; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/insurance_service.d.ts b/types/services/insurance_service.d.ts deleted file mode 100644 index 7acb4e153..000000000 --- a/types/services/insurance_service.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -type InsuranceParams = Record; -type InsuranceCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create an {@link Insurance insurance} record. - * See {@link https://docs.easypost.com/docs/insurance#create-an-insurance EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the insurance to be created. - * @returns {Insurance} - The created insurance. - */ - create(params: InsuranceParams): Promise; - /** - * Retrieve all {@link Insurance} records associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/insurance#retrieve-all-insurances EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the insurance records. - * @returns {Object} - An object containing the list of {@link Insurance insurance} records and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Insurance collection. - * @param {Object} insurances An object containing a list of {@link Insurance insurances} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(insurances: InsuranceCollection, pageSize?: number | null): Promise; - /** - * Retrieve an {@link Insurance insurance} record by its ID. - * See {@link https://docs.easypost.com/docs/insurance#retrieve-an-insurance EasyPost API Documentation} for more information. - * @param {string} id - The ID of the insurance to retrieve. - * @returns {Insurance} - The retrieved insurance. - */ - retrieve(id: string): Promise; - /** - * Refund an {@link Insurance insurance} record by its ID. - * See {@link https://docs.easypost.com/docs/insurance#refund-an-insurance EasyPost API Documentation} for more information. - * @param {string} id - The ID of the insurance to be refunded. - * @returns {Insurance} - The refunded insurance. - */ - refund(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/luma_service.d.ts b/types/services/luma_service.d.ts deleted file mode 100644 index cd25aeb41..000000000 --- a/types/services/luma_service.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -type LumaParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Get service recommendations from Luma that meet the criteria of your ruleset. - * @param {Object} params - The parameters to get a Luma promise with. - * @returns {Object} - An object containing the Luma promise. - */ - getPromise(params: LumaParams): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/order_service.d.ts b/types/services/order_service.d.ts deleted file mode 100644 index 97c083357..000000000 --- a/types/services/order_service.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -type OrderParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create an {@link Order order}. - * See {@link https://docs.easypost.com/docs/orders#create-an-order EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create an order with. - * @returns {Order} - The created order. - */ - create(params: OrderParams): Promise; - /** - * Purchase an {@link Order order}. - * See {@link https://docs.easypost.com/docs/orders#buy-an-order EasyPost API Documentation} for more information. - * @param {string} id - The ID of the order to buy. - * @param {string} carrier - The carrier to use for the order purchase. - * @param {string} service - The service to use for the order purchase. - * @returns {Order} - The purchased order. - */ - buy(id: string, carrier: string, service: string): Promise; - /** - * Get updated rates for an {@link Order order}. - * See {@link https://docs.easypost.com/docs/orders EasyPost API Documentation} for more information. - * @param {string} id - The ID of the order to get rates for. - * @returns {Order} - The order with rates. - */ - getRates(id: string): Promise; - /** - * Retrieve an {@link Order order} by its ID. - * See {@link https://docs.easypost.com/docs/orders#retrieve-an-order EasyPost API Documentation} for more information. - * @param {string} id - The ID of the order to retrieve. - * @returns {Order} - The retrieved order. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/parcel_service.d.ts b/types/services/parcel_service.d.ts deleted file mode 100644 index 2768027b4..000000000 --- a/types/services/parcel_service.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -type ParcelParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link Parcel parcel}. - * See {@link https://docs.easypost.com/docs/parcels#create-a-parcel EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a parcel with. - * @returns {Parcel} - The created parcel. - */ - create(params: ParcelParams): Promise; - /** - * Retrieve a {@link Parcel parcel} by its ID. - * See {@link https://docs.easypost.com/docs/parcels#retrieve-a-parcel EasyPost API Documentation} for more information. - * @param {string} id - The ID of the parcel to retrieve. - * @returns {Parcel} - The retrieved parcel. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/pickup_service.d.ts b/types/services/pickup_service.d.ts deleted file mode 100644 index 741028508..000000000 --- a/types/services/pickup_service.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -type PickupParams = Record; -type PickupCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link Pickup pickup}. - * See {@link https://docs.easypost.com/docs/pickups#create-a-pickup EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a pickup with. - * @returns {Pickup} - The created pickup. - */ - create(params: PickupParams): Promise; - /** - * Purchase a {@link Pickup pickup}. - * See {@link https://docs.easypost.com/docs/pickups#buy-a-pickup EasyPost API Documentation} for more information. - * @param {string} id - The ID of the pickup to purchase. - * @param {string} carrier - The carrier to purchase the pickup with. - * @param {string} service - The service to purchase the pickup with. - * @returns {Pickup} - The purchased pickup. - */ - buy(id: string, carrier: string, service: string): Promise; - /** - * Cancel a {@link Pickup pickup}. - * See {@link https://docs.easypost.com/docs/pickups#cancel-a-pickup EasyPost API Documentation} for more information. - * @param {string} id - The ID of the pickup to cancel. - * @returns {Pickup} - The cancelled pickup. - */ - cancel(id: string): Promise; - /** - * Retrieve all {@link Pickup pickups} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/pickups#retrieve-all-pickups EasyPost API Documentation} for more information. - * @param {Object} [params] - The parameters to filter the pickups by. - * @returns {Object} - An object containing a list of {@link Pickup pickups} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Pickup collection. - * @param {Object} pickups An object containing a list of {@link Pickup pickups} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(pickups: PickupCollection, pageSize?: number | null): Promise; - /** - * Retrieve a {@link Pickup pickup} by its ID. - * See {@link https://docs.easypost.com/docs/pickups#retrieve-a-pickup EasyPost API Documentation} for more information. - * @param {string} id - The ID of the pickup to retrieve. - * @returns {Pickup} - The retrieved pickup. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/rate_service.d.ts b/types/services/rate_service.d.ts deleted file mode 100644 index 16f2ce322..000000000 --- a/types/services/rate_service.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Retrieve a {@link Rate rate} by its ID. - * See {@link https://docs.easypost.com/docs/shipments/rates EasyPost API Documentation} for more information. - * @param {string} id - The ID of the rate to retrieve. - * @returns {Rate} - The retrieved rate. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/referral_customer_service.d.ts b/types/services/referral_customer_service.d.ts deleted file mode 100644 index a1aabdc60..000000000 --- a/types/services/referral_customer_service.d.ts +++ /dev/null @@ -1,66 +0,0 @@ -type ReferralCustomerParams = Record; -type MandateData = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link User referral customer}. - * See {@link https://docs.easypost.com/docs/users/referral-customers#create-a-referralcustomer EasyPost API Documentation} for more information. - * @param {Object} params - The referral customer's information. - * @returns {User} - The newly created referral customer. - */ - create(params: ReferralCustomerParams): Promise; - /** - * Update a {@link User referral customer's} email address. - * See {@link https://docs.easypost.com/docs/users/referral-customers#update-a-referralcustomer EasyPost API Documentation} for more information. - * @param {string} referralUserId - The ID of the referral customer to update. - * @param {string} email - The new email address. - * @returns {boolean} - Returns true if the referral was updated successfully, false otherwise. - */ - updateEmail(referralUserId: string, email: string): Promise; - /** - * Add a credit card to EasyPost for a ReferralCustomer without needing a Stripe account. This function requires the ReferralCustomer User's API key. - * See {@link https://docs.easypost.com/docs/users/billing#create-credit-card EasyPost API Documentation} for more information. - * @param {string} referralApiKey - The referral customer's production API key. - * @param {string} number - The credit card number. - * @param {string} expirationMonth - The credit card expiration month. - * @param {string} expirationYear - The credit card expiration year. - * @param {string} cvc - The credit card CVC. - * @param {string} priority - Whether to add the card as 'primary' or 'secondary' payment method (defaults to 'primary'). - * @returns {Object} - An object representing the newly-added credit card. - */ - addCreditCard(referralApiKey: string, number: string, expirationMonth: string, expirationYear: string, cvc: string, priority?: string): Promise>; - /** - * Add a credit card to EasyPost for a ReferralCustomer with a payment method ID from Stripe. - * This function requires the ReferralCustomer User's API key. - * @returns {object} - A JSON object representing the credit card. - */ - addCreditCardFromStripe(referralApiKey: string, paymentMethodId: string, priority?: string): Promise; - /** - * Add a bank account to EasyPost for a ReferralCustomer. - * This function requires the ReferralCustomer User's API key. - * @returns {object} - A JSON object representing the bank account. - */ - addBankAccountFromStripe(referralApiKey: string, financialConnectionsId: string, mandateData: MandateData, priority?: string): Promise; - /** - * Retrieve all {@link User referral customers} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/users/referral-customers#retrieve-all-referralcustomers EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the referral customers by. - * @returns {Object} - An object containing a list of {@link User referral customers} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Referral Customer collection. - * @param {Object} referralCustomers An object containing a list of {@link referral referralCustomers} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(referralCustomers: Record, pageSize?: number | null): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/refund_service.d.ts b/types/services/refund_service.d.ts deleted file mode 100644 index 65a557d6d..000000000 --- a/types/services/refund_service.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -type RefundParams = Record; -type RefundCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link Refund refund}. - * See {@link https://docs.easypost.com/docs/refunds#create-a-refund EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a refund with. - * @returns {Refund} - The created refund. - */ - create(params: RefundParams): Promise; - /** - * Retrieve all {@link Refund refunds} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/refunds#retrieve-all-refunds EasyPost API Documentation} for more information. - * @param {Object} [params] - The parameters to filter the refunds by. - * @returns {Object} - An object containing the list of {@link Refund refunds} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Refund collection. - * @param {Object} refunds An object containing a list of {@link Refund refunds} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(refunds: RefundCollection, pageSize?: number | null): Promise; - /** - * Retrieve a {@link Refund refund} by its ID. - * See {@link https://docs.easypost.com/docs/refunds#retrieve-a-refund EasyPost API Documentation} for more information. - * @param {string} id - The ID of the refund to retrieve. - * @returns {Refund} - The retrieved refund. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/report_service.d.ts b/types/services/report_service.d.ts deleted file mode 100644 index c69665452..000000000 --- a/types/services/report_service.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -declare function _default(easypostClient: any): { - new (): {}; - /** - * Create a {@link Report report}. - * See {@link https://docs.easypost.com/docs/reports#create-a-report EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a report with. - * @returns {Report} - The created report. - */ - create(params: any): Report; - /** - * Retrieve all {@link Report reports} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/reports#retrieve-all-reports EasyPost API Documentation} for more information. - * @param {Object} [params] - The parameters to filter the reports by. - * @returns {Object} - An object containing the list of {@link Report reports} and pagination information. - */ - all(params?: any): any; - /** - * Retrieve the next page of Report collection. - * @param {Object} reports An object containing a list of {@link Report reports} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(reports: any, pageSize?: number): EasyPostObject | Promise; - /** - * Retrieve a {@link Report report} by its ID. - * See {@link https://docs.easypost.com/docs/reports#retrieve-a-report EasyPost API Documentation} for more information. - * @param {string} id - The ID of the report to retrieve. - * @returns {Report} - The retrieved report. - */ - retrieve(id: string): Report; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/scan_form_service.d.ts b/types/services/scan_form_service.d.ts deleted file mode 100644 index 75ae96615..000000000 --- a/types/services/scan_form_service.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -type ScanFormParams = Record & { - shipments?: Array; -}; -type ScanFormCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link ScanForm scan form}. - * See {@link https://docs.easypost.com/docs/scan-form#create-a-scanform EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a scan form with. - * @returns {ScanForm} - The created scan form. - */ - create(params: ScanFormParams): Promise; - /** - * Retrieve all {@link ScanForm scan forms} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/scan-form#retrieve-all-scanforms EasyPost API Documentation} for more information. - * @param {Object} [params] - The parameters to filter the scan forms by. - * @returns {Object} - An object containing the list of {@link ScanForm scan forms} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of ScanForm collection. - * @param {Object} scanforms An object containing a list of {@link ScanForm scanforms} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(scanforms: ScanFormCollection, pageSize?: number | null): Promise; - /** - * Retrieve a {@link ScanForm scan form} by its ID. - * See {@link https://docs.easypost.com/docs/scan-form#retrieve-a-scanform EasyPost API Documentation} for more information. - * @param {string} id - The ID of the scan form to retrieve. - * @returns {ScanForm} - The retrieved scan form. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/shipment_service.d.ts b/types/services/shipment_service.d.ts deleted file mode 100644 index 8704e31e7..000000000 --- a/types/services/shipment_service.d.ts +++ /dev/null @@ -1,135 +0,0 @@ -type ShipmentParams = Record; -type ShipmentRateInput = string | { - id: string; -}; -type ShipmentCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link Shipment shipment}. - * See {@link https://docs.easypost.com/docs/shipments#create-a-shipment EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a shipment with. - * @returns {Shipment} - The created shipment. - */ - create(params: ShipmentParams): Promise; - /** - * Purchase a {@link Shipment shipment}. - * See {@link https://docs.easypost.com/docs/shipments#buy-a-shipment EasyPost API Documentation} for more information. - * @param {string} id - The ID of the shipment to purchase. - * @param {Rate} rate - The rate to purchase the shipment with. - * @param {number|null} [insuranceAmount] - The amount of insurance to purchase for the shipment. - * @param {string|null} [endShipperId] - The ID of the end shipper to purchase the shipment with. - * @returns {Shipment} - The purchased shipment. - */ - buy(id: string, rate: ShipmentRateInput, insuranceAmount?: number | null, endShipperId?: string | null): Promise; - /** - * Convert the label format of a {@link Shipment shipment}. - * See {@link https://docs.easypost.com/docs/shipments#converting-the-label-format-of-a-shipment EasyPost API Documentation} for more information. - * @param {string} id - The ID of the shipment to convert the label format of. - * @param {string} format - The format to convert the label to. - * @returns {Shipment} - The shipment with the converted label format. - */ - convertLabelFormat(id: string, format: string): Promise; - /** - * Regenerate {@link Rate rates} for a {@link Shipment shipment}. - * See {@link https://docs.easypost.com/docs/shipments/rates#regenerate-rates-for-a-shipment EasyPost API Documentation} for more information. - * @param {string} id - The ID of the shipment to regenerate rates for. - * @returns {Shipment} - The shipment with regenerated rates. - */ - regenerateRates(id: string): Promise; - /** - * Get SmartRates for a {@link Shipment shipment}. - * See {@link https://docs.easypost.com/docs/shipments/shipping-smartrate#shipping-smartrate-1 EasyPost API Documentation} for more information. - * @param {string} id - The ID of the shipment to get SmartRates for. - * @returns {Rate[]} - The SmartRates for the shipment. - */ - getSmartRates(id: string): Promise; - /** - * Insure a {@link Shipment shipment}. - * See {@link https://docs.easypost.com/docs/shipments/shipping-insurance#insure-a-shipment EasyPost API Documentation} for more information. - * @param {string} id - The ID of the shipment to insure. - * @param {number|string} amount - The amount to insure the shipment for. - * @returns {Shipment} - The insured shipment. - */ - insure(id: string, amount: number | string): Promise; - /** - * Generate a form for a {@link Shipment shipment}. - * See {@link https://docs.easypost.com/docs/shipments/forms#create-form EasyPost API Documentation} for more information. - * @param {string} id - The ID of the shipment to generate a form for. - * @param {string} formType - The type of form to generate. - * @param {Map} [formOptions] - Options for the form. - * @returns {Shipment} - The shipment with the generated form attached. - */ - generateForm(id: string, formType: string, formOptions?: Record): Promise; - /** - * Refund a {@link Shipment shipment}. - * See {@link https://docs.easypost.com/docs/shipments/shipping-refund#refund-a-shipment EasyPost API Documentation} for more information. - * @param {string} id - The ID of the shipment to refund. - * @returns {Shipment} - The refunded shipment. - */ - refund(id: string): Promise; - /** - * Get the lowest SmartRate of a shipment. - * @param {string} id - The ID of the shipment to get the lowest SmartRate of. - * @param {number} deliveryDays - The number of days the shipment will take to deliver. - * @param {string} deliveryAccuracy - The accuracy of the delivery days. - * @returns {Rate} - The lowest SmartRate of the shipment. - */ - lowestSmartRate(id: string, deliveryDays: number, deliveryAccuracy: string): Promise; - /** - * Retrieve all {@link Shipment shipments} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/shipments#retrieve-all-shipments EasyPost API Documentation} for more information. - * @param {Object} [params] - Parameters to filter the shipments by. - * @returns {Object} - An object containing a list of {@link Shipment shipments} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Shipment collection. - * @param {Object} shipments An object containing a list of {@link Shipment shipments} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(shipments: ShipmentCollection, pageSize?: number): Promise; - /** - * Retrieve a {@link Shipment shipment} by its ID. - * See {@link https://docs.easypost.com/docs/shipments#retrieve-a-shipment EasyPost API Documentation} for more information. - * @param {string} id - The ID of the shipment to retrieve. - * @returns {Shipment} - The shipment with the given ID. - */ - retrieve(id: string): Promise; - /** - * Retrieve the estimated delivery date of each Rate via SmartRate. - * @param {string} id - The ID of the shipment to retrieve the estimated delivery date for. - * @param {string} plannedShipDate - The planned ship date of the shipment. - * @returns {Array} - An array of the estimated delivery date and rates. - */ - retrieveEstimatedDeliveryDate(id: string, plannedShipDate: string): Promise; - /** - * Retrieve a recommended ship date for a {@link Shipment shipment} via the Precision Shipping API, based on a specific desired delivery date. - * @param id - The ID of the shipment to retrieve the recommended ship date for. - * @param desiredDeliveryDate - The desired delivery date for the shipment. - * @returns {Array} - An array of the recommended ship date and rates. - */ - recommendShipDate(id: string, desiredDeliveryDate: string): Promise; - /** - * Create and buy a Luma Shipment in one call. - * @param {Object} params - The parameters to create and buy a Shipment with Luma. - * @returns {Shipment} - The shipment with the given ID. - */ - createAndBuyLuma(params: ShipmentParams): Promise; - /** - * Buy a Shipment with Luma. - * @param {string} id - The ID of the Shipment to buy with Luma. - * @param {Object} params - The parameters to buy a Shipment with Luma. - * @returns {Shipment} - The shipment with the given ID. - */ - buyLuma(id: string, params: Record): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/smart_rate_service.d.ts b/types/services/smart_rate_service.d.ts deleted file mode 100644 index 37874fabb..000000000 --- a/types/services/smart_rate_service.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -type SmartRateParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Retrieve the estimated delivery date of each carrier-service level combination via the Smart Deliver By API, based on a specific ship date and origin-destination postal code pair. - * @param params - The parameters to estimate the delivery date with. - * @returns {Object} - Estimates and related metadata. - */ - estimateDeliveryDate(params: SmartRateParams): Promise; - /** - * Retrieve a recommended ship date for each carrier-service level combination via the Smart Deliver On API, based on a specific delivery date and origin-destination postal code pair. - * @param params - The parameters to recommend the ship date with. - * @returns {Object} - Recommendation and related metadata. - */ - recommendShipDate(params: SmartRateParams): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/tracker_service.d.ts b/types/services/tracker_service.d.ts deleted file mode 100644 index 611ba4e52..000000000 --- a/types/services/tracker_service.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -type TrackerParams = Record; -type TrackerCollection = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link Tracker tracker}. - * See {@link https://docs.easypost.com/docs/trackers#create-a-tracker EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a tracker with. - * @returns {Tracker} - The created tracker. - */ - create(params: TrackerParams): Promise; - /** - * Retrieve all {@link Tracker trackers} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/trackers#retrieve-all-trackers EasyPost API Documentation} for more information. - * @param {Object} [params] - The parameters to filter the trackers by. - * @returns {Object} - An object containing the list of {@link Tracker trackers} and pagination information. - */ - all(params?: Record): Promise; - /** - * Retrieve the next page of Tracker collection. - * @param {Object} trackers An object containing a list of {@link Tracker trackers} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(trackers: TrackerCollection, pageSize?: number | null): Promise; - /** - * Retrieve a {@link Tracker tracker} by its ID. - * See {@link https://docs.easypost.com/docs/trackers#retrieve-a-tracker EasyPost API Documentation} for more information. - * @param {string} id - The ID of the tracker to retrieve. - * @returns {Tracker} - The retrieved tracker. - */ - retrieve(id: string): Promise; - /** - * Retrieve a batch of {@link Tracker trackers}. - * @param {Object} [params] - The parameters to filter the trackers by. - * @returns {Object} - An object containing the list of {@link Tracker trackers}. - */ - retrieveBatch(params?: Record): Promise; - /** - * Delete a {@link Tracker tracker}. - * See {@link https://docs.easypost.com/docs/trackers#delete-a-tracker EasyPost API Documentation} for more information. - * @param {string} id - The ID of the tracker to delete. - * @returns {Promise} - */ - delete(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/services/user_service.d.ts b/types/services/user_service.d.ts deleted file mode 100644 index b256917e0..000000000 --- a/types/services/user_service.d.ts +++ /dev/null @@ -1,74 +0,0 @@ -type UserParams = Record; -type BrandParams = Record; -type UserCollection = Record & { - has_more?: boolean; - _params?: Record; -}; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link User child user}. - * See {@link https://docs.easypost.com/docs/users/child-users#create-a-child-user EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a child user with. - * @returns {User} - The created child user. - */ - create(params: UserParams): Promise; - /** - * Update a {@link User user}. - * See {@link https://docs.easypost.com/docs/users#update-a-user EasyPost API Documentation} for more information. - * @param {string} id - The ID of the user to update (either the current authenticated user or a child user). - * @param {Object} params - The parameters to update the user with. - * @returns {User} - The updated user. - */ - update(id: string, params: UserParams): Promise; - /** - * Retrieve a {@link User child user}. - * See {@link https://docs.easypost.com/docs/users#retrieve-a-user EasyPost API Documentation} for more information. - * @param {string} id - The ID of the child user to retrieve. - * @returns {User} - The retrieved child user. - */ - retrieve(id: string): Promise; - /** - * Retrieve the {@link User current authenticated user}. - * See {@link https://docs.easypost.com/docs/users#retrieve-a-user EasyPost API Documentation} for more information. - * @returns {User} - The retrieved user. - */ - retrieveMe(): Promise; - /** - * Delete a {@link User child user}. - * See {@link https://docs.easypost.com/docs/users/child-users#delete-a-child-user EasyPost API Documentation} for more information. - * @param {string} id - The ID of the child user to delete. - * @returns {Promise|Promise} - A promise that resolves when the child user is deleted successfully. - */ - delete(id: string): Promise; - /** - * Update the brand of a {@link User user}. - * See {@link https://docs.easypost.com/docs/users/brand#update-a-brand EasyPost API Documentation} for more information. - * @param {string} id - The ID of the user to update the brand of. - * @param {Object} params - The parameters to update the brand with. - * @returns {Brand} - The updated brand. - */ - updateBrand(id: string, params: BrandParams): Promise; - /** - * Retrieve a paginated list of children user {@link User user}. - * See {@link https://docs.easypost.com/docs/users/child-users#retrieve-all-child-users EasyPost API Documentation} for more information. - * @param {Object} params - Parameters to filter the list of children users. - * @returns {Object} - An object containing a list of {@link Children User} and pagination information. - */ - allChildren(params: Record): Promise; - /** - * Retrieve the next page of children collection. - * @param {Object} children An object containing a list of {@link Children children} and pagination information. - * @param {Number} pageSize The number of records to return on each page - * @returns {EasyPostObject|Promise} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. - */ - getNextPage(children: UserCollection, pageSize?: number | null): Promise; - _getNextPage(url: string, key: string, collection: UserCollection, pageSize?: number | null): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; -}; -export default _default; diff --git a/types/services/webhook_service.d.ts b/types/services/webhook_service.d.ts deleted file mode 100644 index 8370721de..000000000 --- a/types/services/webhook_service.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -type WebhookParams = Record; -declare const _default: (easypostClient: any) => { - new (): {}; - /** - * Create a {@link Webhook webhook}. - * See {@link https://docs.easypost.com/docs/webhooks#create-a-webhook EasyPost API Documentation} for more information. - * @param {Object} params - The parameters to create a webhook with. - * @returns {Webhook} - The created webhook. - */ - create(params: WebhookParams): Promise; - /** - * Update a {@link Webhook webhook}. - * A disabled webhook will be re-enabled if it is updated. - * See {@link https://docs.easypost.com/docs/webhooks#update-a-webhook EasyPost API Documentation} for more information. - * @param {string} id - The ID of the webhook to update. - * @param {Object} params - The parameters to update the webhook with. - * @returns {Webhook} - The updated webhook. - */ - update(id: string, params: Record): Promise; - /** - * Delete a {@link Webhook webhook}. - * See {@link https://docs.easypost.com/docs/webhooks#delete-a-webhook EasyPost API Documentation} for more information. - * @param {string} id - The ID of the webhook to delete. - * @returns {Promise|Promise} - A promise that resolves if the webhook was successfully deleted. - */ - delete(id: string): Promise; - /** - * Retrieve all {@link Webhook webhooks} associated with the current authenticated user. - * See {@link https://docs.easypost.com/docs/webhooks#retrieve-all-webhooks EasyPost API Documentation} for more information. - * @param {Object} [params] - * @returns {Webhook[]} - */ - all(params?: Record): Promise; - /** - * Retrieve a {@link Webhook webhook} by its ID. - * See {@link https://docs.easypost.com/docs/webhooks#retrieve-a-webhook EasyPost API Documentation} for more information. - * @param {string} id - The ID of the webhook to retrieve. - * @returns {Webhook} - The retrieved webhook. - */ - retrieve(id: string): Promise; - _toPlainEasyPostObject(response: any): any; - _buildEasyPostObject(response: any, params: any): any; - _convertToEasyPostObject(response: any, params?: any): any; - _create(url: any, params: any): Promise; - _all(url: any, params?: {}): Promise; - _retrieve(url: any): Promise; - _getNextPage(url: string, key: string, collection: any, pageSize?: number | null, optionalParams?: any): Promise; -}; -export default _default; diff --git a/types/utils/internal_util.d.ts b/types/utils/internal_util.d.ts deleted file mode 100644 index f1265f5f9..000000000 --- a/types/utils/internal_util.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Utility class of various internal helper functions. - * This class is not designed to be used directly by consumers of the library. - * @internal - * @type {InternalUtils} - */ -export default class InternalUtils { -} diff --git a/types/utils/util.d.ts b/types/utils/util.d.ts deleted file mode 100644 index a0e98d6de..000000000 --- a/types/utils/util.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/// -/// -type SmartRate = { - rate: string; - time_in_transit: Record; -}; -type Rate = { - rate: string; - carrier: string; - service: string; -}; -/** - * Utility class of various publicly-available helper functions. - * @public - * @type {Utils} - */ -export default class Utils { - /** - * Get the lowest SmartRate from a provided list of SmartRates. - * @public - * @param {Rate[]} smartrates - List of SmartRates to filter through - * @param {number} deliveryDays - The maximum number of days allowed for delivery - * @param {string} deliveryAccuracy - The target level of accuracy for the delivery days (e.g. 'percentile_50') - * @returns {Rate} - The lowest SmartRate - * @throws {FilteringError} - If no applicable rates are found - * @throws {InvalidParameterError} - If the deliveryAccuracy value is invalid - */ - getLowestSmartRate(smartrates: SmartRate[], deliveryDays: number | string, deliveryAccuracy: string): SmartRate; - /** - * Get the lowest rate from a provided list of rates. - * @public - * @param {Rate[]} rates - List of rates to filter through - * @param {string[]} [carriers] - List of allowed carriers to filter by - * @param {string[]} [services] - List of allowed services to filter by - * @returns {Rate} - The lowest rate - * @throws {FilteringError} - If no applicable rates are found - */ - getLowestRate(rates: Rate[], carriers?: string[] | null, services?: string[] | null): Rate; - /** - * Validate a webhook by comparing the HMAC signature header sent from EasyPost to your shared secret. - * If the signatures do not match, an error will be raised signifying the webhook either did not originate - * from EasyPost or the secrets do not match. If the signatures do match, the `event_body` will be returned - * as JSON. - * @public - * @param {buffer} eventBody - The raw body of the webhook event - * @param {Object} headers - The headers of the webhook HTTP request - * @param {string} webhookSecret - The webhook secret shared between EasyPost and your application - * @returns {object} - The JSON-parsed webhook event body if the signature could be verified - * @throws {SignatureVerificationError} - If the signature could not be verified - */ - validateWebhook(eventBody: Buffer | string, headers: Record, webhookSecret: string): Record; -} -export {}; From 7d95561abb37e669ab51014e9ae383101dfdf866 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 10 Aug 2026 13:00:20 -0600 Subject: [PATCH 3/3] TSM-90: fix CI typescript job after types/demo removal --- .github/workflows/ci.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a01aadc2..bf23ddb41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 just test-node-compatibility - # typescript checks that the our Typescript definitions can be compiled without errors + # typescript checks that TypeScript declarations and compatibility tests compile without errors typescript: runs-on: ubuntu-latest steps: @@ -44,11 +44,7 @@ jobs: - uses: actions/setup-node@v7 with: node-version: 24 - - run: | - cd types/demo - npm install - cd ../../ - just install typescript + - run: just install typescript lint: runs-on: ubuntu-latest steps: