diff --git a/META-INF/context.xml b/META-INF/context.xml new file mode 100644 index 0000000..5b05045 --- /dev/null +++ b/META-INF/context.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5440e65..cb5e1a3 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ org.projectlombok lombok - 1.18.22 + 1.18.38 provided diff --git a/src/main/java/io/ljunggren/ups/api/model/Address.java b/src/main/java/io/ljunggren/ups/api/model/Address.java index 46ab077..c24740e 100644 --- a/src/main/java/io/ljunggren/ups/api/model/Address.java +++ b/src/main/java/io/ljunggren/ups/api/model/Address.java @@ -1,28 +1,30 @@ -package io.ljunggren.ups.api.model; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Data; - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class Address { - - @JsonProperty("AddressLine") - private List addressLines; - @JsonProperty("City") - private String city; - @JsonProperty("StateProvinceCode") - private String stateProvinceCode; - @JsonProperty("PostalCode") - private String postalCode; - @JsonProperty("CountryCode") - private String countryCode; - -} +package io.ljunggren.ups.api.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class Address { + + @JsonProperty("AddressLine") + private List addressLines; + @JsonProperty("City") + private String city; + @JsonProperty("StateProvinceCode") + private String stateProvinceCode; + @JsonProperty("PostalCode") + private String postalCode; + @JsonProperty("CountryCode") + private String countryCode; + @JsonProperty("ResidentialAddressIndicator") + private String residentialAddressIndicator; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/CurrencyValue.java b/src/main/java/io/ljunggren/ups/api/model/CurrencyValue.java new file mode 100644 index 0000000..ac4945f --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/CurrencyValue.java @@ -0,0 +1,26 @@ +package io.ljunggren.ups.api.model; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class CurrencyValue { + + @JsonProperty("CurrencyCode") + private String currencyCode; + @JsonProperty("MonetaryValue") + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Double monetaryValue; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/ItemizedCurrencyValue.java b/src/main/java/io/ljunggren/ups/api/model/ItemizedCurrencyValue.java new file mode 100644 index 0000000..38fd011 --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/ItemizedCurrencyValue.java @@ -0,0 +1,28 @@ +package io.ljunggren.ups.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper=false) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class ItemizedCurrencyValue extends CurrencyValue { + + @JsonProperty("Code") + private String code; + @JsonProperty("Description") + private String description; + @JsonProperty("SubType") + private String subType; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/PackageType.java b/src/main/java/io/ljunggren/ups/api/model/PackageType.java new file mode 100644 index 0000000..383303d --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/PackageType.java @@ -0,0 +1,47 @@ +package io.ljunggren.ups.api.model; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import lombok.Getter; + +@Getter +public enum PackageType { + + UPS_LETTER("01", "UPS Letter", false, false, "03"), + CUSTOM_PACKAGE("02", "Custom Package", true, true, "03"), + UPS_SMALL_BOX("2a", "UPS Small Box", false, true, "03"), + UPS_MEDIUM_BOX("2b", "UPS Medium Box", false, true, "03"), + UPS_LARGE_BOX("2c", "UPS Large Box", false, true, "03"), + UPS_TUBE("03", "UPS Tube", false, true, "03"), + UPS_PAK("04", "UPS Pak", false, true, "03"); + + private String value; + private String text; + private boolean dimensional; + private boolean multipackage; + private String packageBillType; + + private PackageType(String value, String text, boolean dimensional, boolean multipackage, String packageBillType) { + this.value = value; + this.text = text; + this.dimensional = dimensional; + this.multipackage = multipackage; + this.packageBillType = packageBillType; + } + + public static List getNonDimensionals() { + return Arrays.stream(PackageType.values()) + .filter(type -> !type.isDimensional()) + .collect(Collectors.toList()); + } + + public static PackageType getByValue(String value) { + return Arrays.stream(PackageType.values()) + .filter(type -> type.getValue().equals(value)) + .findFirst() + .orElse(null); + } + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/Surcharge.java b/src/main/java/io/ljunggren/ups/api/model/Surcharge.java new file mode 100644 index 0000000..4b0290b --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/Surcharge.java @@ -0,0 +1,154 @@ +package io.ljunggren.ups.api.model; + +import java.util.Arrays; + +public enum Surcharge { + + ADDITIONAL_HANDLING("100", "Additional Handling"), + COD("110", "Cod"), + DELIVERY_CONFIRMATION("120", "Delivery Confirmation"), + SHIP_DELIVERY_CONFIRMATION("121", "Ship Delivery Confirmation"), + PKG_EMAIL_SHIP_NOTIFICATION("153", "Pkg Email Ship Notification"), + PKG_EMAIL_RETURN_NOTIFICATION("154", "Pkg Email Return Notification"), + PKG_EMAIL_INBOUND_RETURN_NOTIFICATION("155", "Pkg Email Inbound Return Notification"), + PKG_EMAIL_QUANTUM_VIEW_SHIP_NOTIFICATION("156", "Pkg Email Quantum View Ship Notification"), + PKG_EMAIL_QUANTUM_VIEW_EXCEPTION_NOTIFICATION("157", "Pkg Email Quantum View Exception Notification"), + PKG_EMAIL_QUANTUM_VIEW_DELIVERY_NOTIFICATION("158", "Pkg Email Quantum View Delivery Notification"), + PKG_FAX_INBOUND_RETURN_NOTIFICATION("165", "Pkg Fax Inbound Return Notification"), + PKG_FAX_QUANTUM_VIEW_SHIP_NOTIFICATION("166", "Pkg Fax Quantum View Ship Notification"), + SHIP_EMAIL_ERL_NOTIFICATION("171", "Ship Email Erl Notification"), + SHIP_EMAIL_SHIP_NOTIFICATION("173", "Ship Email Ship Notification"), + SHIP_EMAIL_RETURN_NOTIFICATION("174", "Ship Email Return Notification"), + SHIP_EMAIL_INBOUND_RETURN_NOTIFICATION("175", "Ship Email Inbound Return Notification"), + SHIP_EMAIL_QUANTUM_VIEW_SHIP_NOTIFICATION("176", "Ship Email Quantum View Ship Notification"), + SHIP_EMAIL_QUANTUM_VIEW_EXCEPTION_NOTIFICATION("177", "Ship Email Quantum View Exception Notification"), + SHIP_EMAIL_QUANTUM_VIEW_DELIVERY_NOTIFICATION("178", "Ship Email Quantum View Delivery Notification"), + SHIP_EMAIL_QUANTUM_VIEW_NOTIFY("179", "Ship Email Quantum View Notify"), + SHIP_UPS_ACCESS_POINT_NOTIFICATION("187", "Ship Ups Access Point Notification"), + SHIP_EEI_FILING_NOTIFICATION("188", "Ship Eei Filing Notification"), + SHIP_UAP_SHIPPER_NOTIFICATION("189", "Ship Uap Shipper Notification"), + EXTENDED_AREA("190", "Extended Area"), + HAZ_MAT("199", "Haz Mat"), + DRY_ICE("200", "Dry Ice"), + ISC_SEEDS("201", "Isc Seeds"), + ISC_PERISHABLES("202", "Isc Perishables"), + ISC_TOBACCO("203", "Isc Tobacco"), + ISC_PLANTS("204", "Isc Plants"), + ISC_ALCOHOLIC_BEVERAGES("205", "Isc Alcoholic Beverages"), + ISC_BIOLOGICAL_SUBSTANCES("206", "Isc Biological Substances"), + ISC_SPECIAL_EXCEPTIONS("207", "Isc Special Exceptions"), + HOLD_FOR_PICKUP("220", "Hold For Pickup"), + ORIGIN_CERTIFICATE("240", "Origin Certificate"), + PRINT_RETURN_LABEL("250", "Print Return Label"), + EXPORT_LICENSE_VERIFICATION("258", "Export License Verification"), + PRINT_N_MAIL("260", "Print N Mail"), + RESIDENTIAL_ADDRESS("270", "Residential Address"), + RETURN_SERVICE_1ATTEMPT("280", "Return Service 1Attempt"), + RETURN_SERVICE_3ATTEMPT("290", "Return Service 3Attempt"), + SATURDAY_DELIVERY("300", "Saturday Delivery"), + SATURDAY_INTERNATIONAL_PROCESSING_FEE("310", "Saturday International Processing Fee"), + ELECTRONIC_RETURN_LABEL("350", "Electronic Return Label"), + QUANTUM_VIEW_NOTIFY_DELIVERY("372", "Quantum View Notify Delivery"), + UPS_PREPARED_SED_FORM("374", "Ups Prepared Sed Form"), + FUEL_SURCHARGE("375", "Fuel Surcharge"), + DELIVERY_AREA("376", "Delivery Area"), + LARGE_PACKAGE("377", "Large Package"), + SHIPPER_PAYS_DUTY_TAX("378", "Shipper Pays Duty Tax"), + SHIPPER_PAYS_DUTY_TAX_UNPAID("379", "Shipper Pays Duty Tax Unpaid"), + EXPRESS_PLUS_SURCHARGE("380", "Express Plus Surcharge"), + INSURANCE("400", "Insurance"), + SHIP_ADDITIONAL_HANDLING("401", "Ship Additional Handling"), + SHIPPER_RELEASE("402", "Shipper Release"), + CHECK_TO_SHIPPER("403", "Check To Shipper"), + UPS_PROACTIVE_RESPONSE("404", "Ups Proactive Response"), + GERMAN_PICKUP("405", "German Pickup"), + GERMAN_ROAD_TAX("406", "German Road Tax"), + EXTENDED_AREA_PICKUP("407", "Extended Area Pickup"), + RETURN_OF_DOCUMENT("410", "Return Of Document"), + PEAK_SEASON("430", "Peak Season"), + PEAK_SEASON_SURCHARGE_LARGE_PACKAGE("431", "Peak Season Surcharge - Large Package"), + PEAK_SEASON_SURCHARGE_ADDITIONAL_HANDLING440_SHIP_LARGE_PACKAGE("432", "Peak Season Surcharge - Additional Handling Ship Large Package"), + CARBON_NEUTRAL("441", "Carbon Neutral"), + PKG_QV_IN_TRANSIT_NOTIFICATION("442", "Pkg Qv In Transit Notification"), + SHIP_QV_IN_TRANSIT_NOTIFICATION("443", "Ship Qv In Transit Notification"), + IMPORT_CONTROL("444", "Import Control"), + COMMERCIAL_INVOICE_REMOVAL("445", "Commercial Invoice Removal"), + IMPORT_CONTROL_ELECTRONIC_LABEL("446", "Import Control Electronic Label"), + IMPORT_CONTROL_PRINT_LABEL("447", "Import Control Print Label"), + IMPORT_CONTROL_PRINT_AND_MAIL_LABEL("448", "Import Control Print And Mail Label"), + IMPORT_CONTROL_ONE_PICK_UP_ATTEMPT_LABEL("449", "Import Control One Pick Up Attempt Label"), + IMPORT_CONTROL_THREE_PICK_UP_ATTEMPT_LABEL("450", "Import Control Three Pick Up Attempt Label"), + REFRIGERATION("452", "Refrigeration"), + PAC_1A_BOX1("454", "Pac 1A Box1"), + PAC_3A_BOX1("455", "Pac 3A Box1"), + PAC_1A_BOX2("456", "Pac 1A Box2"), + PAC_3A_BOX2("457", "Pac 3A Box2"), + PAC_1A_BOX3("458", "Pac 1A Box3"), + PAC_3A_BOX3("459", "Pac 3A Box3"), + PAC_1A_BOX4("460", "Pac 1A Box4"), + PAC_3A_BOX4("461", "Pac 3A Box4"), + PAC_1A_BOX5("462", "Pac 1A Box5"), + PAC_3A_BOX5("463", "Pac 3A Box5"), + EXCHANGE_PRINT_RETURN_LABEL("464", "Exchange Print Return Label"), + EXCHANGE_FORWARD("465", "Exchange Forward"), + SHIP_PREALERT_NOTIFICATION("466", "Ship Prealert Notification"), + COMMITTED_DELIVERY_WINDOW("470", "Committed Delivery Window"), + SECURITY_SURCHARGE("480", "Security Surcharge"), + CUSTOMER_TRANSACTION_FEE("492", "Customer Transaction Fee"), + SHIPMENT_COD("500", "Shipment Cod"), + LIFT_GATE_FOR_PICKUP("510", "Lift Gate For Pickup"), + LIFT_GATE_FOR_DELIVERY("511", "Lift Gate For Delivery"), + DROP_OFF_AT_UPS_FACILITY("512", "Drop Off At Ups Facility"), + UPS_PREMIUM_CARE("515", "Ups Premium Care"), + OVERSIZE_PALLET("520", "Oversize Pallet"), + MI_DUAL_LABEL_RETURN("524", "Mi Dual Label Return"), + FREIGHT_DELIVERY_SURCHARGE("530", "Freight Delivery Surcharge"), + FREIGHT_PICKUP_SURCHARGE("531", "Freight Pickup Surcharge"), + DIRECT_TO_RETAIL("540", "Direct To Retail"), + DIRECT_DELIVERY_ONLY("541", "Direct Delivery Only"), + DELIVER_TO_ADDRESSEE_ONLY("542", "Deliver To Addressee Only"), + DIRECT_TO_RETAIL_COD("543", "Direct To Retail Cod"), + RETAIL_ACCESS_POINT("544", "Retail Access Point"), + SHIPPING_TICKET_NOTIFICATION("545", "Shipping Ticket Notification"), + ELECTRONIC_PACKAGE_RELEASE_AUTHENTICATION("546", "Electronic Package Release Authentication"), + PAY_AT_STORE("547", "Pay At Store"), + ICOD_NOTIFICATION("548", "Icod Notification"), + ITEM_DISPOSAL("550", "Item Disposal"), + UK_BORDER_FEE("551", "Uk Border Fee"), + MASTER_CARTON("552", "Master Carton"), + SIMPLE_RATE_ACCESSORIAL("553", "Simple Rate Accessorial"), + UPS_PREMIER_GOLD("555", "Ups Premier Gold"), + UPS_PREMIER_SILVER("556", "Ups Premier Silver"), + UPS_PREMIER_PLATINUM("557", "Ups Premier Platinum"), + DDU_OVERSIZE("558", "Ddu Oversize"), + INTERNATIONAL_PROCESS_FEE("573", "International Process Fee"); + + private String code; + private String description; + + private Surcharge(String code, String description) { + this.code = code; + this.description = description; + } + + public String getCode() { + return code; + } + + public String getDescription() { + return description; + } + + public static Surcharge getByCode(String code) { + return Arrays.stream(Surcharge.values()) + .filter(charge -> charge.getCode().equals(code)) + .findFirst() + .orElse(null); + } + + public static String getDescriptionByCode(String code) { + Surcharge charge = getByCode(code); + return charge == null ? null : charge.getDescription(); + } + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/request/DateTime.java b/src/main/java/io/ljunggren/ups/api/model/rate/request/DateTime.java new file mode 100644 index 0000000..4157947 --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/request/DateTime.java @@ -0,0 +1,20 @@ +package io.ljunggren.ups.api.model.rate.request; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class DateTime { + + @JsonProperty("Date") + private String date; + @JsonProperty("Time") + private String time; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/request/DeliveryTimeInformation.java b/src/main/java/io/ljunggren/ups/api/model/rate/request/DeliveryTimeInformation.java new file mode 100644 index 0000000..4923793 --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/request/DeliveryTimeInformation.java @@ -0,0 +1,20 @@ +package io.ljunggren.ups.api.model.rate.request; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class DeliveryTimeInformation { + + @JsonProperty("PackageBillType") + private String packageBillType; + @JsonProperty("Pickup") + private DateTime pickup; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/request/Dimensions.java b/src/main/java/io/ljunggren/ups/api/model/rate/request/Dimensions.java index d4480b2..2e4d3f8 100644 --- a/src/main/java/io/ljunggren/ups/api/model/rate/request/Dimensions.java +++ b/src/main/java/io/ljunggren/ups/api/model/rate/request/Dimensions.java @@ -1,32 +1,30 @@ -package io.ljunggren.ups.api.model.rate.request; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class Dimensions { - - @JsonProperty("Length") - @JsonFormat(shape = JsonFormat.Shape.STRING) - private double lenght; - @JsonProperty("Width") - @JsonFormat(shape = JsonFormat.Shape.STRING) - private double width; - @JsonProperty("Height") - @JsonFormat(shape = JsonFormat.Shape.STRING) - private double height; - @JsonProperty("UnitOfMeasurement") - private CodeDescription unitOfMeasurement; - -} +package io.ljunggren.ups.api.model.rate.request; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class Dimensions { + + @JsonProperty("Length") + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Double length; + @JsonProperty("Width") + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Double width; + @JsonProperty("Height") + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Double height; + @JsonProperty("UnitOfMeasurement") + private CodeDescription unitOfMeasurement; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/request/Package.java b/src/main/java/io/ljunggren/ups/api/model/rate/request/Package.java index 003887f..2905146 100644 --- a/src/main/java/io/ljunggren/ups/api/model/rate/request/Package.java +++ b/src/main/java/io/ljunggren/ups/api/model/rate/request/Package.java @@ -1,22 +1,24 @@ -package io.ljunggren.ups.api.model.rate.request; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Data; - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class Package { - - @JsonProperty("Dimensions") - private Dimensions dimensions; - @JsonProperty("PackageWeight") - private PackageWeight packageWeight; - @JsonProperty("PackagingType") - private CodeDescription packagingType; - -} +package io.ljunggren.ups.api.model.rate.request; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class Package { + + @JsonProperty("Dimensions") + private Dimensions dimensions; + @JsonProperty("PackageWeight") + private PackageWeight packageWeight; + @JsonProperty("PackagingType") + private CodeDescription packagingType; + @JsonProperty("PackageServiceOptions") + private PackageServiceOptions packageServiceOptions; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/request/PackageServiceOptions.java b/src/main/java/io/ljunggren/ups/api/model/rate/request/PackageServiceOptions.java new file mode 100644 index 0000000..9555e45 --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/request/PackageServiceOptions.java @@ -0,0 +1,21 @@ +package io.ljunggren.ups.api.model.rate.request; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import io.ljunggren.ups.api.model.CurrencyValue; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class PackageServiceOptions { + + @JsonProperty("DeclaredValue") + private CurrencyValue declaredValue; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/request/PackageWeight.java b/src/main/java/io/ljunggren/ups/api/model/rate/request/PackageWeight.java index c693881..7207e66 100644 --- a/src/main/java/io/ljunggren/ups/api/model/rate/request/PackageWeight.java +++ b/src/main/java/io/ljunggren/ups/api/model/rate/request/PackageWeight.java @@ -1,26 +1,26 @@ -package io.ljunggren.ups.api.model.rate.request; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class PackageWeight { - - @JsonProperty("Weight") - @JsonFormat(shape = JsonFormat.Shape.STRING) - private Integer weight; - @JsonProperty("UnitOfMeasurement") - private CodeDescription unitOfMeasurement; - -} +package io.ljunggren.ups.api.model.rate.request; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class PackageWeight { + + @JsonProperty("Weight") + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Double weight; + @JsonProperty("UnitOfMeasurement") + private CodeDescription unitOfMeasurement; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/request/Shipment.java b/src/main/java/io/ljunggren/ups/api/model/rate/request/Shipment.java index 0421351..f15a186 100644 --- a/src/main/java/io/ljunggren/ups/api/model/rate/request/Shipment.java +++ b/src/main/java/io/ljunggren/ups/api/model/rate/request/Shipment.java @@ -1,34 +1,47 @@ -package io.ljunggren.ups.api.model.rate.request; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class Shipment { - - @JsonProperty("Shipper") - private Shipper shipper; - @JsonProperty("ShipTo") - private NameAndAddress shipTo; - @JsonProperty("ShipFrom") - private NameAndAddress shipFrom; - @JsonProperty("NumOfPieces") - private String numOfPieces; - @JsonProperty("Package") - private List packages; - @JsonProperty("ShipmentRatingOptions") - private ShipmentRatingOptions shipmentRatingOptions; - -} +package io.ljunggren.ups.api.model.rate.request; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import io.ljunggren.ups.api.model.CurrencyValue; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class Shipment { + + @JsonProperty("Service") + private CodeDescription service; + @JsonProperty("Shipper") + private Shipper shipper; + @JsonProperty("ShipTo") + private NameAndAddress shipTo; + @JsonProperty("ShipFrom") + private NameAndAddress shipFrom; + @JsonProperty("NumOfPieces") + private String numOfPieces; + @JsonProperty("Package") + private List packages; + @JsonProperty("ShipmentTotalWeight") + private PackageWeight shipmentTotalWeight; + @JsonProperty("ShipmentRatingOptions") + private ShipmentRatingOptions shipmentRatingOptions; + @JsonProperty("DeliveryTimeInformation") + private DeliveryTimeInformation deliveryTimeInformation; + @JsonProperty("InvoiceLineTotal") + private CurrencyValue invoiceLineTotal; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/Charge.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/Charge.java deleted file mode 100644 index c72bbf2..0000000 --- a/src/main/java/io/ljunggren/ups/api/model/rate/response/Charge.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.ljunggren.ups.api.model.rate.response; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Data; - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class Charge { - - @JsonProperty("CurrencyCode") - private String currencyCode; - @JsonProperty("MonetaryValue") - private String monetaryValue; - -} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/EstimatedArrival.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/EstimatedArrival.java new file mode 100644 index 0000000..11dd1fd --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/response/EstimatedArrival.java @@ -0,0 +1,25 @@ +package io.ljunggren.ups.api.model.rate.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.ljunggren.ups.api.model.rate.request.DateTime; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class EstimatedArrival { + + @JsonProperty("Arrival") + private DateTime arrival; + @JsonProperty("BusinessDaysInTransit") + private String businessDaysInTransit; + @JsonProperty("Pickup") + private DateTime pickup; + @JsonProperty("DayOfWeek") + private String dayOfWeek; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/GuaranteedDelivery.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/GuaranteedDelivery.java new file mode 100644 index 0000000..983640d --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/response/GuaranteedDelivery.java @@ -0,0 +1,20 @@ +package io.ljunggren.ups.api.model.rate.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class GuaranteedDelivery { + + @JsonProperty("BusinessDaysInTransit") + private String businessDaysInTransit; + @JsonProperty("DeliveryByTime") + private String deliveryByTime; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/NegotiatedRate.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/NegotiatedRate.java index 0a06555..27d6532 100644 --- a/src/main/java/io/ljunggren/ups/api/model/rate/response/NegotiatedRate.java +++ b/src/main/java/io/ljunggren/ups/api/model/rate/response/NegotiatedRate.java @@ -1,18 +1,30 @@ -package io.ljunggren.ups.api.model.rate.response; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class NegotiatedRate { - - @JsonProperty("TotalCharge") - private Charge totalCharge; - -} +package io.ljunggren.ups.api.model.rate.response; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.ljunggren.ups.api.model.CurrencyValue; +import io.ljunggren.ups.api.model.ItemizedCurrencyValue; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class NegotiatedRate { + + @JsonProperty("BaseServiceCharge") + private CurrencyValue baseServiceCharge; + @JsonProperty("TransportationCharges") + private CurrencyValue transportationCharges; + @JsonProperty("ServiceOptionsCharges") + private CurrencyValue serviceOptionsCharges; + @JsonProperty("TotalCharge") + private CurrencyValue totalCharges; + @JsonProperty("ItemizedCharges") + private List itemizedCharges; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/RatedPackage.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/RatedPackage.java new file mode 100644 index 0000000..bef3a17 --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/response/RatedPackage.java @@ -0,0 +1,32 @@ +package io.ljunggren.ups.api.model.rate.response; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.ljunggren.ups.api.model.CurrencyValue; +import io.ljunggren.ups.api.model.ItemizedCurrencyValue; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class RatedPackage { + + @JsonProperty("TransportationCharges") + private CurrencyValue transportationCharges; + @JsonProperty("BaseServiceCharge") + private CurrencyValue baseServiceCharge; + @JsonProperty("ServiceOptionsCharges") + private CurrencyValue serviceOptionsCharges; + @JsonProperty("TotalCharges") + private CurrencyValue totalCharges; + @JsonProperty("ItemizedCharges") + private List itemizedCharges; + @JsonProperty("NegotiatedCharges") + private NegotiatedRate negotiatedRate; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/RatedShipment.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/RatedShipment.java index 5fef09d..6fcf049 100644 --- a/src/main/java/io/ljunggren/ups/api/model/rate/response/RatedShipment.java +++ b/src/main/java/io/ljunggren/ups/api/model/rate/response/RatedShipment.java @@ -1,25 +1,41 @@ -package io.ljunggren.ups.api.model.rate.response; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.ljunggren.ups.api.model.rate.request.CodeDescription; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Data; - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class RatedShipment { - - @JsonProperty("Service") - private CodeDescription service; - @JsonProperty("TotalCharges") - private Charge totalCharges; - @JsonProperty("NegotiatedRateCharges") - private NegotiatedRate negotiatedRate; - -} +package io.ljunggren.ups.api.model.rate.response; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.ljunggren.ups.api.model.CurrencyValue; +import io.ljunggren.ups.api.model.ItemizedCurrencyValue; +import io.ljunggren.ups.api.model.rate.request.CodeDescription; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class RatedShipment { + + @JsonProperty("Service") + private CodeDescription service; + @JsonProperty("BaseServiceCharge") + private CurrencyValue baseServiceCharge; + @JsonProperty("TransportationCharges") + private CurrencyValue transportationCharges; + @JsonProperty("ServiceOptionsCharges") + private CurrencyValue serviceOptionsCharges; + @JsonProperty("TotalCharges") + private CurrencyValue totalCharges; + @JsonProperty("ItemizedCharges") + private List itemizedCharges; + @JsonProperty("NegotiatedRateCharges") + private NegotiatedRate negotiatedRate; + @JsonProperty("TimeInTransit") + private TimeInTransit timeInTransit; + @JsonProperty("GuaranteedDelivery") + private GuaranteedDelivery guaranteedDelivery; + @JsonProperty("RatedPackage") + private List ratedPackages; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/Service.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/Service.java new file mode 100644 index 0000000..29258a0 --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/response/Service.java @@ -0,0 +1,18 @@ +package io.ljunggren.ups.api.model.rate.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class Service { + + @JsonProperty("Description") + private String description; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/ServiceSummary.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/ServiceSummary.java new file mode 100644 index 0000000..a960bbf --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/response/ServiceSummary.java @@ -0,0 +1,22 @@ +package io.ljunggren.ups.api.model.rate.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class ServiceSummary { + + @JsonProperty("Service") + private Service service; + @JsonProperty("EstimatedArrival") + private EstimatedArrival estimatedArrival; + @JsonProperty("GuaranteedIndicator") + private String guaranteedIndicator; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/rate/response/TimeInTransit.java b/src/main/java/io/ljunggren/ups/api/model/rate/response/TimeInTransit.java new file mode 100644 index 0000000..bdd82a1 --- /dev/null +++ b/src/main/java/io/ljunggren/ups/api/model/rate/response/TimeInTransit.java @@ -0,0 +1,20 @@ +package io.ljunggren.ups.api.model.rate.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class TimeInTransit { + + @JsonProperty("PickupDate") + private String pickupDate; + @JsonProperty("ServiceSummary") + private ServiceSummary serviceSummary; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/validate/request/AddressKeyFormat.java b/src/main/java/io/ljunggren/ups/api/model/validate/request/AddressKeyFormat.java index c40d14c..a3b67c2 100644 --- a/src/main/java/io/ljunggren/ups/api/model/validate/request/AddressKeyFormat.java +++ b/src/main/java/io/ljunggren/ups/api/model/validate/request/AddressKeyFormat.java @@ -1,60 +1,60 @@ -package io.ljunggren.ups.api.model.validate.request; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.ljunggren.ups.api.model.Address; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class AddressKeyFormat { - - @JsonProperty("AddressLine") - private List addressLines; - @JsonProperty("PoliticalDivision2") - private String city; - @JsonProperty("PoliticalDivision1") - private String stateProvinceCode; - @JsonProperty("PostcodePrimaryLow") - private String postalCodePrimary; - @JsonProperty("PostcodeExtendedLow") - private String postalCodeExtended; - @JsonProperty("CountryCode") - private String countryCode; - - public AddressKeyFormat(Address address) { - this.addressLines = address.getAddressLines(); - this.city = address.getCity(); - this.stateProvinceCode = address.getStateProvinceCode(); - initPostalCode(address.getPostalCode()); - this.countryCode = address.getCountryCode(); - } - - private void initPostalCode(String postalCode) { - String[] split = postalCode.split("-"); - if (split.length == 2) { - this.postalCodePrimary = split[0]; - this.postalCodeExtended = split[1]; - return; - } - this.postalCodePrimary = postalCode; - } - - public String getPostalCode() { - return postalCodeExtended == null ? postalCodePrimary : - String.format("%s-%s", postalCodePrimary, postalCodeExtended); - } - -} +package io.ljunggren.ups.api.model.validate.request; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.ljunggren.ups.api.model.Address; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class AddressKeyFormat { + + @JsonProperty("AddressLine") + private List addressLines; + @JsonProperty("PoliticalDivision2") + private String city; + @JsonProperty("PoliticalDivision1") + private String stateProvinceCode; + @JsonProperty("PostcodePrimaryLow") + private String postalCodePrimary; + @JsonProperty("PostcodeExtendedLow") + private String postalCodeExtended; + @JsonProperty("CountryCode") + private String countryCode; + + public AddressKeyFormat(Address address) { + this.addressLines = address.getAddressLines(); + this.city = address.getCity(); + this.stateProvinceCode = address.getStateProvinceCode(); + initPostalCode(address.getPostalCode()); + this.countryCode = address.getCountryCode(); + } + + private void initPostalCode(String postalCode) { + String[] split = postalCode.split("-"); + if (split.length == 2) { + this.postalCodePrimary = split[0]; + this.postalCodeExtended = split[1]; + return; + } + this.postalCodePrimary = postalCode; + } + + public String getPostalCode() { + return postalCodeExtended == null ? postalCodePrimary : + String.format("%s-%s", postalCodePrimary, postalCodeExtended); + } + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/validate/request/XAVRequest.java b/src/main/java/io/ljunggren/ups/api/model/validate/request/XAVRequest.java index c5dc810..b5eafb1 100644 --- a/src/main/java/io/ljunggren/ups/api/model/validate/request/XAVRequest.java +++ b/src/main/java/io/ljunggren/ups/api/model/validate/request/XAVRequest.java @@ -1,18 +1,18 @@ -package io.ljunggren.ups.api.model.validate.request; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class XAVRequest { - - @JsonProperty("AddressKeyFormat") - private AddressKeyFormat addressKeyFormat; - -} +package io.ljunggren.ups.api.model.validate.request; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class XAVRequest { + + @JsonProperty("AddressKeyFormat") + private AddressKeyFormat addressKeyFormat; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/validate/response/Candidate.java b/src/main/java/io/ljunggren/ups/api/model/validate/response/Candidate.java index d839d20..c25d69f 100644 --- a/src/main/java/io/ljunggren/ups/api/model/validate/response/Candidate.java +++ b/src/main/java/io/ljunggren/ups/api/model/validate/response/Candidate.java @@ -1,19 +1,19 @@ -package io.ljunggren.ups.api.model.validate.response; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.ljunggren.ups.api.model.validate.request.AddressKeyFormat; -import lombok.Data; - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class Candidate { - - @JsonProperty("AddressKeyFormat") - private AddressKeyFormat addressKeyFormat; - -} +package io.ljunggren.ups.api.model.validate.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.ljunggren.ups.api.model.validate.request.AddressKeyFormat; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class Candidate { + + @JsonProperty("AddressKeyFormat") + private AddressKeyFormat addressKeyFormat; + +} diff --git a/src/main/java/io/ljunggren/ups/api/model/validate/response/XAVResponse.java b/src/main/java/io/ljunggren/ups/api/model/validate/response/XAVResponse.java index b8230bf..99a94f4 100644 --- a/src/main/java/io/ljunggren/ups/api/model/validate/response/XAVResponse.java +++ b/src/main/java/io/ljunggren/ups/api/model/validate/response/XAVResponse.java @@ -1,20 +1,20 @@ -package io.ljunggren.ups.api.model.validate.response; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Data; - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class XAVResponse { - - @JsonProperty("Candidate") - private List candidates; - -} +package io.ljunggren.ups.api.model.validate.response; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(Include.NON_NULL) +public class XAVResponse { + + @JsonProperty("Candidate") + private List candidates; + +} diff --git a/src/main/java/io/ljunggren/ups/api/service/AddressService.java b/src/main/java/io/ljunggren/ups/api/service/AddressService.java index 7c0344c..5e1613e 100644 --- a/src/main/java/io/ljunggren/ups/api/service/AddressService.java +++ b/src/main/java/io/ljunggren/ups/api/service/AddressService.java @@ -1,53 +1,53 @@ -package io.ljunggren.ups.api.service; - -import java.io.UnsupportedEncodingException; - -import org.apache.http.Header; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.message.BasicHeader; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.ljunggren.ups.api.model.Address; -import io.ljunggren.ups.api.model.UpsResponse; -import io.ljunggren.ups.api.model.validate.request.AddressKeyFormat; -import io.ljunggren.ups.api.model.validate.request.XAVRequest; -import lombok.AllArgsConstructor; -import lombok.Data; - -public class AddressService extends BaseService { - - public AddressService(String domain) { - super(domain); - } - - private final String URI = domain + "/api/addressvalidation/v2/1"; - - public UpsResponse validate(Address address, String accessToken) throws Exception { - return validate(address, accessToken, getHttpClient()); - } - - public UpsResponse validate(Address address, String accessToken, CloseableHttpClient httpClient) throws Exception { - HttpPost post = new HttpPost(URI); - Header[] headers = generateHeaders(accessToken); - AddressKeyFormat addressKeyFormat = new AddressKeyFormat(address); - XAVRequest xavRequest = new XAVRequest(); - xavRequest.setAddressKeyFormat(addressKeyFormat); - return post(post, headers, new Request(xavRequest), httpClient); - } - - private Header[] generateHeaders(String accessToken) throws UnsupportedEncodingException { - return new Header[] { - new BasicHeader("Authorization", "Bearer " + accessToken) - }; - } - - @Data - @AllArgsConstructor - private class Request { - @JsonProperty("XAVRequest") - private XAVRequest xavRequest; - } - -} +package io.ljunggren.ups.api.service; + +import java.io.UnsupportedEncodingException; + +import org.apache.http.Header; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.message.BasicHeader; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.ljunggren.ups.api.model.Address; +import io.ljunggren.ups.api.model.UpsResponse; +import io.ljunggren.ups.api.model.validate.request.AddressKeyFormat; +import io.ljunggren.ups.api.model.validate.request.XAVRequest; +import lombok.AllArgsConstructor; +import lombok.Data; + +public class AddressService extends BaseService { + + public AddressService(String domain) { + super(domain); + } + + private final String URI = domain + "/api/addressvalidation/v2/1"; + + public UpsResponse validate(Address address, String accessToken) throws Exception { + return validate(address, accessToken, getHttpClient()); + } + + public UpsResponse validate(Address address, String accessToken, CloseableHttpClient httpClient) throws Exception { + HttpPost post = new HttpPost(URI); + Header[] headers = generateHeaders(accessToken); + AddressKeyFormat addressKeyFormat = new AddressKeyFormat(address); + XAVRequest xavRequest = new XAVRequest(); + xavRequest.setAddressKeyFormat(addressKeyFormat); + return post(post, headers, new Request(xavRequest), httpClient); + } + + private Header[] generateHeaders(String accessToken) throws UnsupportedEncodingException { + return new Header[] { + new BasicHeader("Authorization", "Bearer " + accessToken) + }; + } + + @Data + @AllArgsConstructor + private class Request { + @JsonProperty("XAVRequest") + private XAVRequest xavRequest; + } + +} diff --git a/src/main/java/io/ljunggren/ups/api/service/BaseService.java b/src/main/java/io/ljunggren/ups/api/service/BaseService.java index f6c44bc..03e87d0 100644 --- a/src/main/java/io/ljunggren/ups/api/service/BaseService.java +++ b/src/main/java/io/ljunggren/ups/api/service/BaseService.java @@ -1,98 +1,98 @@ -package io.ljunggren.ups.api.service; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; - -import org.apache.http.Header; -import org.apache.http.HttpResponse; -import org.apache.http.client.config.CookieSpecs; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; - -import io.ljunggren.json.utils.JsonUtils; -import io.ljunggren.ups.api.model.Error; -import io.ljunggren.ups.api.model.ErrorResponse; -import io.ljunggren.ups.api.model.UpsResponse; - -public class BaseService { - - protected String domain; - - protected BaseService(String domain) { - this.domain = domain; - } - - protected static final List KNOWN_RESPONSE_CODES = Arrays.asList(new Integer[] { - 200, 400, 403, 404, 500, 503 - }); - protected static final int THROTTLING_CODE = 429; - - protected CloseableHttpClient getHttpClient() { - return HttpClients.custom() - .setDefaultRequestConfig(RequestConfig.custom() - .setCookieSpec(CookieSpecs.STANDARD).build()) - .build(); - } - - protected static UpsResponse get(HttpGet get, Header[] headers, CloseableHttpClient httpClient) throws IOException { - get.setHeaders(headers); - return execute(get, httpClient); - } - - protected static UpsResponse post(HttpPost post, Header[] headers, Object request, CloseableHttpClient httpClient) throws IOException { - post.setHeaders(headers); - post.setEntity(new StringEntity(JsonUtils.objectToJson(request))); - return execute(post, httpClient); - } - - protected static UpsResponse execute(HttpRequestBase httpRequest, CloseableHttpClient httpClient) throws IOException { - try { - CloseableHttpResponse response = httpClient.execute(httpRequest); - int responseCode = response.getStatusLine().getStatusCode(); - String json = getResult(response); - if (KNOWN_RESPONSE_CODES.contains(responseCode)) { - return JsonUtils.jsonToObject(json, UpsResponse.class); - } - UpsResponse upsResponse = new UpsResponse(); - if (THROTTLING_CODE == responseCode) { - ErrorResponse errorResponse = new ErrorResponse().addError( - new Error("Throttled", "Too many requests")); - upsResponse.setErrorResponse(errorResponse); - return upsResponse; - } - ErrorResponse errorResponse = new ErrorResponse().addError( - new Error("Error", String.format("Unknown response code %d", responseCode))); - upsResponse.setErrorResponse(errorResponse); - return upsResponse; - } catch(Exception e) { - UpsResponse trackingResponse = new UpsResponse(); - ErrorResponse errorResponse = new ErrorResponse().addError( - new Error("Error", e.getMessage())); - trackingResponse.setErrorResponse(errorResponse); - return trackingResponse; - } finally { - httpClient.close(); - } - } - - protected static String getResult(HttpResponse response) throws UnsupportedOperationException, IOException { - BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8)); - StringBuilder result = new StringBuilder(); - String line = new String(); - while ((line = rd.readLine()) != null) { - result.append(line); - } - return result.toString(); - } - -} +package io.ljunggren.ups.api.service; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.List; + +import org.apache.http.Header; +import org.apache.http.HttpResponse; +import org.apache.http.client.config.CookieSpecs; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; + +import io.ljunggren.json.utils.JsonUtils; +import io.ljunggren.ups.api.model.Error; +import io.ljunggren.ups.api.model.ErrorResponse; +import io.ljunggren.ups.api.model.UpsResponse; + +public class BaseService { + + protected String domain; + + protected BaseService(String domain) { + this.domain = domain; + } + + protected static final List KNOWN_RESPONSE_CODES = Arrays.asList(new Integer[] { + 200, 400, 403, 404, 500, 503 + }); + protected static final int THROTTLING_CODE = 429; + + protected CloseableHttpClient getHttpClient() { + return HttpClients.custom() + .setDefaultRequestConfig(RequestConfig.custom() + .setCookieSpec(CookieSpecs.STANDARD).build()) + .build(); + } + + protected static UpsResponse get(HttpGet get, Header[] headers, CloseableHttpClient httpClient) throws IOException { + get.setHeaders(headers); + return execute(get, httpClient); + } + + protected static UpsResponse post(HttpPost post, Header[] headers, Object request, CloseableHttpClient httpClient) throws IOException { + post.setHeaders(headers); + post.setEntity(new StringEntity(JsonUtils.objectToJson(request))); + return execute(post, httpClient); + } + + protected static UpsResponse execute(HttpRequestBase httpRequest, CloseableHttpClient httpClient) throws IOException { + try { + CloseableHttpResponse response = httpClient.execute(httpRequest); + int responseCode = response.getStatusLine().getStatusCode(); + String json = getResult(response); + if (KNOWN_RESPONSE_CODES.contains(responseCode)) { + return JsonUtils.jsonToObject(json, UpsResponse.class); + } + UpsResponse upsResponse = new UpsResponse(); + if (THROTTLING_CODE == responseCode) { + ErrorResponse errorResponse = new ErrorResponse().addError( + new Error("Throttled", "Too many requests")); + upsResponse.setErrorResponse(errorResponse); + return upsResponse; + } + ErrorResponse errorResponse = new ErrorResponse().addError( + new Error("Error", String.format("Unknown response code %d", responseCode))); + upsResponse.setErrorResponse(errorResponse); + return upsResponse; + } catch(Exception e) { + UpsResponse trackingResponse = new UpsResponse(); + ErrorResponse errorResponse = new ErrorResponse().addError( + new Error("Error", e.getMessage())); + trackingResponse.setErrorResponse(errorResponse); + return trackingResponse; + } finally { + httpClient.close(); + } + } + + protected static String getResult(HttpResponse response) throws UnsupportedOperationException, IOException { + BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8)); + StringBuilder result = new StringBuilder(); + String line = new String(); + while ((line = rd.readLine()) != null) { + result.append(line); + } + return result.toString(); + } + +} diff --git a/src/main/java/io/ljunggren/ups/api/service/OauthService.java b/src/main/java/io/ljunggren/ups/api/service/OauthService.java index c381560..69c2a63 100644 --- a/src/main/java/io/ljunggren/ups/api/service/OauthService.java +++ b/src/main/java/io/ljunggren/ups/api/service/OauthService.java @@ -1,61 +1,61 @@ -package io.ljunggren.ups.api.service; - -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.Base64; -import java.util.List; - -import org.apache.http.Header; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.message.BasicHeader; -import org.apache.http.message.BasicNameValuePair; - -import io.ljunggren.json.utils.JsonUtils; -import io.ljunggren.ups.api.model.AuthToken; - -public class OauthService extends BaseService { - - public OauthService(String domain) { - super(domain); - } - private final String URI = domain + "/security/v1/oauth/token"; - - public AuthToken getAuthToken(String clientId, String clientSecret, String accountNumber) throws Exception { - return getAuthToken(clientId, clientSecret, accountNumber, getHttpClient()); - } - - public AuthToken getAuthToken(String clientId, String clientSecret, String accountNumber, CloseableHttpClient httpClient) throws Exception { - HttpPost post = new HttpPost(URI); - Header[] headers = generateHeaders(clientId, clientSecret, accountNumber); - try { - post.setHeaders(headers); - post.setEntity(generateAuthEntity()); - CloseableHttpResponse response = httpClient.execute(post); - String json = getResult(response); - return JsonUtils.jsonToObject(json, AuthToken.class); - } finally { - httpClient.close(); - } - } - - private Header[] generateHeaders(String clientId, String clientSecret, String accountNumber) throws UnsupportedEncodingException { - String base64String = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes("UTF-8")); - return new Header[] { - new BasicHeader("x-merchant-id", accountNumber), - new BasicHeader("content-type", "application/x-www-form-urlencoded"), - new BasicHeader("authorization", "Basic " + base64String) - }; - } - - private StringEntity generateAuthEntity() throws UnsupportedEncodingException { - List urlParameters = Arrays.asList( - new BasicNameValuePair("grant_type", "client_credentials") - ); - return new UrlEncodedFormEntity(urlParameters); - } - -} +package io.ljunggren.ups.api.service; + +import java.io.UnsupportedEncodingException; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; + +import org.apache.http.Header; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.message.BasicHeader; +import org.apache.http.message.BasicNameValuePair; + +import io.ljunggren.json.utils.JsonUtils; +import io.ljunggren.ups.api.model.AuthToken; + +public class OauthService extends BaseService { + + public OauthService(String domain) { + super(domain); + } + private final String URI = domain + "/security/v1/oauth/token"; + + public AuthToken getAuthToken(String clientId, String clientSecret, String accountNumber) throws Exception { + return getAuthToken(clientId, clientSecret, accountNumber, getHttpClient()); + } + + public AuthToken getAuthToken(String clientId, String clientSecret, String accountNumber, CloseableHttpClient httpClient) throws Exception { + HttpPost post = new HttpPost(URI); + Header[] headers = generateHeaders(clientId, clientSecret, accountNumber); + try { + post.setHeaders(headers); + post.setEntity(generateAuthEntity()); + CloseableHttpResponse response = httpClient.execute(post); + String json = getResult(response); + return JsonUtils.jsonToObject(json, AuthToken.class); + } finally { + httpClient.close(); + } + } + + private Header[] generateHeaders(String clientId, String clientSecret, String accountNumber) throws UnsupportedEncodingException { + String base64String = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes("UTF-8")); + return new Header[] { + new BasicHeader("x-merchant-id", accountNumber), + new BasicHeader("content-type", "application/x-www-form-urlencoded"), + new BasicHeader("authorization", "Basic " + base64String) + }; + } + + private StringEntity generateAuthEntity() throws UnsupportedEncodingException { + List urlParameters = Arrays.asList( + new BasicNameValuePair("grant_type", "client_credentials") + ); + return new UrlEncodedFormEntity(urlParameters); + } + +} diff --git a/src/main/java/io/ljunggren/ups/api/service/RateService.java b/src/main/java/io/ljunggren/ups/api/service/RateService.java index 0777f1f..62ec395 100644 --- a/src/main/java/io/ljunggren/ups/api/service/RateService.java +++ b/src/main/java/io/ljunggren/ups/api/service/RateService.java @@ -1,51 +1,51 @@ -package io.ljunggren.ups.api.service; - -import java.io.UnsupportedEncodingException; -import java.util.UUID; - -import org.apache.http.Header; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.message.BasicHeader; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.ljunggren.ups.api.model.UpsResponse; -import io.ljunggren.ups.api.model.rate.request.RateRequest; -import lombok.AllArgsConstructor; -import lombok.Data; - -public class RateService extends BaseService { - - public RateService(String domain) { - super(domain); - } - - private final String URI = domain + "/api/rating/v2409/Shop"; - - public UpsResponse request(RateRequest rateRequest, String accessToken) throws Exception { - return request(rateRequest, accessToken, getHttpClient()); - } - - public UpsResponse request(RateRequest rateRequest, String accessToken, CloseableHttpClient httpClient) throws Exception { - HttpPost post = new HttpPost(URI); - Header[] headers = generateHeaders(accessToken); - return post(post, headers, new Request(rateRequest), httpClient); - } - - private Header[] generateHeaders(String accessToken) throws UnsupportedEncodingException { - return new Header[] { - new BasicHeader("transId", UUID.randomUUID().toString()), - new BasicHeader("transactionSrc", domain), - new BasicHeader("Authorization", "Bearer " + accessToken) - }; - } - - @Data - @AllArgsConstructor - private class Request { - @JsonProperty("RateRequest") - private RateRequest rateRequest; - } - -} +package io.ljunggren.ups.api.service; + +import java.io.UnsupportedEncodingException; +import java.util.UUID; + +import org.apache.http.Header; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.message.BasicHeader; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.ljunggren.ups.api.model.UpsResponse; +import io.ljunggren.ups.api.model.rate.request.RateRequest; +import lombok.AllArgsConstructor; +import lombok.Data; + +public class RateService extends BaseService { + + public RateService(String domain) { + super(domain); + } + + private final String shopTimeInTransitURI = domain + "/api/rating/v2409/Shoptimeintransit"; + + public UpsResponse request(RateRequest rateRequest, String accessToken) throws Exception { + return request(rateRequest, accessToken, getHttpClient()); + } + + public UpsResponse request(RateRequest rateRequest, String accessToken, CloseableHttpClient httpClient) throws Exception { + HttpPost post = new HttpPost(shopTimeInTransitURI); + Header[] headers = generateHeaders(accessToken); + return post(post, headers, new Request(rateRequest), httpClient); + } + + private Header[] generateHeaders(String accessToken) throws UnsupportedEncodingException { + return new Header[] { + new BasicHeader("transId", UUID.randomUUID().toString()), + new BasicHeader("transactionSrc", domain), + new BasicHeader("Authorization", "Bearer " + accessToken) + }; + } + + @Data + @AllArgsConstructor + private class Request { + @JsonProperty("RateRequest") + private RateRequest rateRequest; + } + +} diff --git a/src/main/java/io/ljunggren/ups/api/service/TrackingService.java b/src/main/java/io/ljunggren/ups/api/service/TrackingService.java index 43f721e..2521943 100644 --- a/src/main/java/io/ljunggren/ups/api/service/TrackingService.java +++ b/src/main/java/io/ljunggren/ups/api/service/TrackingService.java @@ -1,39 +1,39 @@ -package io.ljunggren.ups.api.service; - -import java.io.UnsupportedEncodingException; -import java.util.UUID; - -import org.apache.http.Header; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.message.BasicHeader; - -import io.ljunggren.ups.api.model.UpsResponse; - -public class TrackingService extends BaseService { - - public TrackingService(String domain) { - super(domain); - } - - private final String URI = domain + "/api/track/v1/details/"; - - public UpsResponse track(String trackingNumber, String accessToken) throws Exception { - return track(trackingNumber, accessToken, getHttpClient()); - } - - public UpsResponse track(String trackingNumber, String accessToken, CloseableHttpClient httpClient) throws Exception { - HttpGet get = new HttpGet(URI + trackingNumber); - Header[] headers = generateHeaders(accessToken); - return get(get, headers, httpClient); - } - - private Header[] generateHeaders(String accessToken) throws UnsupportedEncodingException { - return new Header[] { - new BasicHeader("transId", UUID.randomUUID().toString()), - new BasicHeader("transactionSrc", domain), - new BasicHeader("Authorization", "Bearer " + accessToken) - }; - } - -} +package io.ljunggren.ups.api.service; + +import java.io.UnsupportedEncodingException; +import java.util.UUID; + +import org.apache.http.Header; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.message.BasicHeader; + +import io.ljunggren.ups.api.model.UpsResponse; + +public class TrackingService extends BaseService { + + public TrackingService(String domain) { + super(domain); + } + + private final String URI = domain + "/api/track/v1/details/"; + + public UpsResponse track(String trackingNumber, String accessToken) throws Exception { + return track(trackingNumber, accessToken, getHttpClient()); + } + + public UpsResponse track(String trackingNumber, String accessToken, CloseableHttpClient httpClient) throws Exception { + HttpGet get = new HttpGet(URI + trackingNumber); + Header[] headers = generateHeaders(accessToken); + return get(get, headers, httpClient); + } + + private Header[] generateHeaders(String accessToken) throws UnsupportedEncodingException { + return new Header[] { + new BasicHeader("transId", UUID.randomUUID().toString()), + new BasicHeader("transactionSrc", domain), + new BasicHeader("Authorization", "Bearer " + accessToken) + }; + } + +} diff --git a/src/main/java/io/ljunggren/ups/api/service/util/CodeUtils.java b/src/main/java/io/ljunggren/ups/api/service/util/CodeUtils.java index 66467d2..8442501 100644 --- a/src/main/java/io/ljunggren/ups/api/service/util/CodeUtils.java +++ b/src/main/java/io/ljunggren/ups/api/service/util/CodeUtils.java @@ -1,27 +1,27 @@ -package io.ljunggren.ups.api.service.util; - -public class CodeUtils { - - public static String shippingServiceCodeToString(String code) { - switch (code) { - case "01": return "UPS Next Day Air"; - case "02": return "UPS 2nd Day Air"; - case "03": return "UPS Ground"; - case "07": return "UPS Worldwide Express"; - case "08": return "UPS Worldwide Expedited"; - case "11": return "UPS Standard"; - case "12": return "UPS 3 Day Select"; - case "13": return "UPS Next Day Air Saver"; - case "14": return "UPS Next Day Air Early A.M."; - case "54": return "UPS Worldwide Express Plus"; - case "59": return "UPS 2nd Day Air A.M."; - case "65": return "UPS Saver"; - case "82": return "UPS Today Standard"; - case "83": return "UPS Today Dedicated Courier"; - case "85": return "UPS Today Express"; - case "86": return "UPS Today Express Saver"; - default: return "Unknown"; - } - } - -} +package io.ljunggren.ups.api.service.util; + +public class CodeUtils { + + public static String shippingServiceCodeToString(String code) { + switch (code) { + case "01": return "UPS Next Day Air"; + case "02": return "UPS 2nd Day Air"; + case "03": return "UPS Ground"; + case "07": return "UPS Worldwide Express"; + case "08": return "UPS Worldwide Expedited"; + case "11": return "UPS Standard"; + case "12": return "UPS 3 Day Select"; + case "13": return "UPS Next Day Air Saver"; + case "14": return "UPS Next Day Air Early A.M."; + case "54": return "UPS Worldwide Express Plus"; + case "59": return "UPS 2nd Day Air A.M."; + case "65": return "UPS Saver"; + case "82": return "UPS Today Standard"; + case "83": return "UPS Today Dedicated Courier"; + case "85": return "UPS Today Express"; + case "86": return "UPS Today Express Saver"; + default: return "Unknown"; + } + } + +} diff --git a/src/test/java/io/ljunggren/ups/api/UpsResponseTest.java b/src/test/java/io/ljunggren/ups/api/UpsResponseTest.java index 2767dca..822d0a7 100644 --- a/src/test/java/io/ljunggren/ups/api/UpsResponseTest.java +++ b/src/test/java/io/ljunggren/ups/api/UpsResponseTest.java @@ -1,35 +1,35 @@ -package io.ljunggren.ups.api; - -import static org.junit.Assert.assertTrue; - -import java.io.IOException; - -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -import io.ljunggren.json.utils.JsonUtils; -import io.ljunggren.ups.api.model.UpsResponse; - -public class UpsResponseTest { - - private String readFromResources(String file) throws IOException { - return IOUtils.toString(this.getClass().getResourceAsStream(file), "UTF-8"); - } - - @Test - public void serializeTrackingNotFoundResponseTest() throws IOException { - String json = readFromResources("/trackingNotFoundResponse.json"); - UpsResponse response = JsonUtils.jsonToObject(json, UpsResponse.class); - String serializedResponse = JsonUtils.objectToJson(response); - assertTrue(JsonUtils.areEqual(json, serializedResponse)); - } - - @Test - public void serializeInvalidAuthenticationResponseTest() throws IOException { - String json = readFromResources("/invalidAuthentication.json"); - UpsResponse response = JsonUtils.jsonToObject(json, UpsResponse.class); - String serializedResponse = JsonUtils.objectToJson(response); - assertTrue(JsonUtils.areEqual(json, serializedResponse)); - } - -} +package io.ljunggren.ups.api; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +import io.ljunggren.json.utils.JsonUtils; +import io.ljunggren.ups.api.model.UpsResponse; + +public class UpsResponseTest { + + private String readFromResources(String file) throws IOException { + return IOUtils.toString(this.getClass().getResourceAsStream(file), "UTF-8"); + } + + @Test + public void serializeTrackingNotFoundResponseTest() throws IOException { + String json = readFromResources("/trackingNotFoundResponse.json"); + UpsResponse response = JsonUtils.jsonToObject(json, UpsResponse.class); + String serializedResponse = JsonUtils.objectToJson(response); + assertTrue(JsonUtils.areEqual(json, serializedResponse)); + } + + @Test + public void serializeInvalidAuthenticationResponseTest() throws IOException { + String json = readFromResources("/invalidAuthentication.json"); + UpsResponse response = JsonUtils.jsonToObject(json, UpsResponse.class); + String serializedResponse = JsonUtils.objectToJson(response); + assertTrue(JsonUtils.areEqual(json, serializedResponse)); + } + +} diff --git a/src/test/java/io/ljunggren/ups/api/model/rate/request/RateRequestTest.java b/src/test/java/io/ljunggren/ups/api/model/rate/request/RateRequestTest.java deleted file mode 100644 index 0da09dd..0000000 --- a/src/test/java/io/ljunggren/ups/api/model/rate/request/RateRequestTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.ljunggren.ups.api.model.rate.request; - -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; - -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -import io.ljunggren.json.utils.JsonUtils; - -public class RateRequestTest { - - private String readFromResources(String file) throws IOException { - return IOUtils.toString(this.getClass().getResourceAsStream(file), "UTF-8"); - } - - @Test - public void parseTest() throws IOException { - String json = readFromResources("/io/ljunggren/ups/api/model/rate/request/rate-request.json"); - RateRequest response = JsonUtils.jsonToObject(json, RateRequest.class); - System.out.println(response); - } - -} diff --git a/src/test/java/io/ljunggren/ups/api/model/rate/response/RateResponseTest.java b/src/test/java/io/ljunggren/ups/api/model/rate/response/RateResponseTest.java new file mode 100644 index 0000000..503fa12 --- /dev/null +++ b/src/test/java/io/ljunggren/ups/api/model/rate/response/RateResponseTest.java @@ -0,0 +1,26 @@ +package io.ljunggren.ups.api.model.rate.response; + +import static org.junit.Assert.*; + +import java.io.IOException; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +import io.ljunggren.json.utils.JsonUtils; +import io.ljunggren.ups.api.model.UpsResponse; + +public class RateResponseTest { + + private String readFromResources(String file) throws IOException { + return IOUtils.toString(this.getClass().getResourceAsStream(file), "UTF-8"); + } + + @Test + public void deserializeTest() throws IOException { + String json = readFromResources("/rateResponse.json"); + UpsResponse response = JsonUtils.jsonToObject(json, UpsResponse.class); + assertNotNull(response.getRateResponse()); + } + +} diff --git a/src/test/resources/invalidAuthentication.json b/src/test/resources/invalidAuthentication.json index 06be424..651102f 100644 --- a/src/test/resources/invalidAuthentication.json +++ b/src/test/resources/invalidAuthentication.json @@ -1,10 +1,10 @@ -{ - "response": { - "errors": [ - { - "code": "250002", - "message": "Invalid Authentication Information." - } - ] - } -} +{ + "response": { + "errors": [ + { + "code": "250002", + "message": "Invalid Authentication Information." + } + ] + } +} diff --git a/src/test/resources/io/ljunggren/ups/api/model/rate/request/rate-request.json b/src/test/resources/io/ljunggren/ups/api/model/rate/request/rate-request.json index f4d1ca3..15dd8f8 100644 --- a/src/test/resources/io/ljunggren/ups/api/model/rate/request/rate-request.json +++ b/src/test/resources/io/ljunggren/ups/api/model/rate/request/rate-request.json @@ -1,60 +1,60 @@ -{ - "Request": { - "TransactionReference": { - "CustomerContext": "CustomerContext" - } - }, - "Shipment": { - "ShipTo": { - "Name": "James", - "Address": { - "AddressLine": [ - "9904 State Run Dr" - ], - "City": "Alpharetta", - "StateProvinceCode": "GA", - "PostalCode": "30005", - "CountryCode": "US" - } - }, - "ShipFrom": { - "Name": "ShipFromName", - "Address": { - "AddressLine": [ - "12 Main ST", - "Apt 24" - ], - "City": "TIMONIUM", - "StateProvinceCode": "MD", - "PostalCode": "21093", - "CountryCode": "US" - } - }, - "Package": [{ - "SimpleRate": { - "Description": "SimpleRateDescription", - "Code": "XS" - }, - "PackagingType": { - "Code": "02", - "Description": "Packaging" - }, - "Dimensions": { - "UnitOfMeasurement": { - "Code": "IN", - "Description": "Inches" - }, - "Length": "5", - "Width": "5", - "Height": "5" - }, - "PackageWeight": { - "UnitOfMeasurement": { - "Code": "LBS", - "Description": "Pounds" - }, - "Weight": "1" - } - }] - } +{ + "Request": { + "TransactionReference": { + "CustomerContext": "CustomerContext" + } + }, + "Shipment": { + "ShipTo": { + "Name": "James", + "Address": { + "AddressLine": [ + "9904 State Run Dr" + ], + "City": "Alpharetta", + "StateProvinceCode": "GA", + "PostalCode": "30005", + "CountryCode": "US" + } + }, + "ShipFrom": { + "Name": "ShipFromName", + "Address": { + "AddressLine": [ + "12 Main ST", + "Apt 24" + ], + "City": "TIMONIUM", + "StateProvinceCode": "MD", + "PostalCode": "21093", + "CountryCode": "US" + } + }, + "Package": [{ + "SimpleRate": { + "Description": "SimpleRateDescription", + "Code": "XS" + }, + "PackagingType": { + "Code": "02", + "Description": "Packaging" + }, + "Dimensions": { + "UnitOfMeasurement": { + "Code": "IN", + "Description": "Inches" + }, + "Length": "5", + "Width": "5", + "Height": "5" + }, + "PackageWeight": { + "UnitOfMeasurement": { + "Code": "LBS", + "Description": "Pounds" + }, + "Weight": "1" + } + }] + } } \ No newline at end of file diff --git a/src/test/resources/rateResponse.json b/src/test/resources/rateResponse.json new file mode 100644 index 0000000..50a731d --- /dev/null +++ b/src/test/resources/rateResponse.json @@ -0,0 +1,652 @@ +{ + "RateResponse" : { + "Response" : { + "ResponseStatus" : { + "Code" : "1", + "Description" : "Success" + }, + "Alert" : [ { + "Code" : "110971", + "Description" : "Your invoice may vary from the displayed reference rates" + } ], + "TransactionReference" : { + "CustomerContext" : "https://onlinetools.ups.com", + "TransactionIdentifier" : "000xwssoa9k9ZHgVbnn450" + } + }, + "RatedShipment" : [ { + "Service" : { + "Code" : "14", + "Description" : "" + }, + "Zone" : "104", + "RatedShipmentAlert" : [ { + "Code" : "110971", + "Description" : "Your invoice may vary from the displayed reference rates" + } ], + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "153.14" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "153.14" + }, + "NegotiatedRateCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "144.58" + } + }, + "GuaranteedDelivery" : { + "BusinessDaysInTransit" : "1", + "DeliveryByTime" : "8:00 A.M." + }, + "RatedPackage" : [ { + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "153.14" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "128.69" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "24.45" + } ], + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "153.14" + }, + "NegotiatedCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "128.69" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "144.58" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "144.58" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "15.89" + } ] + }, + "Weight" : "3.0", + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + } + } ], + "TimeInTransit" : { + "PickupDate" : "20250917", + "PackageBillType" : "03", + "Disclaimer" : "Services listed as guaranteed are backed by a money-back guarantee for transportation charges only. UPS guarantees the day of delivery for every ground package you ship to any address within all 50 states and Puerto Rico. See Terms and Conditions in the Service Guide for details.", + "ServiceSummary" : { + "Service" : { + "Description" : "UPS Next Day Air Early" + }, + "EstimatedArrival" : { + "Arrival" : { + "Date" : "20250918", + "Time" : "080000" + }, + "BusinessDaysInTransit" : "1", + "Pickup" : { + "Date" : "20250917", + "Time" : "181500" + }, + "DayOfWeek" : "THU", + "CustomerCenterCutoff" : "161500" + }, + "GuaranteedIndicator" : "", + "SaturdayDelivery" : "0", + "SundayDelivery" : "0" + } + } + }, { + "Service" : { + "Code" : "01", + "Description" : "" + }, + "Zone" : "104", + "RatedShipmentAlert" : [ { + "Code" : "110971", + "Description" : "Your invoice may vary from the displayed reference rates" + } ], + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "117.44" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "117.44" + }, + "NegotiatedRateCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "38.97" + } + }, + "GuaranteedDelivery" : { + "BusinessDaysInTransit" : "1", + "DeliveryByTime" : "10:30 A.M." + }, + "RatedPackage" : [ { + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "117.44" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "98.69" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "18.75" + } ], + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "117.44" + }, + "NegotiatedCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "34.69" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "38.97" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "38.97" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "4.28" + } ] + }, + "Weight" : "3.0", + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + } + } ], + "TimeInTransit" : { + "PickupDate" : "20250917", + "PackageBillType" : "03", + "Disclaimer" : "Services listed as guaranteed are backed by a money-back guarantee for transportation charges only. UPS guarantees the day of delivery for every ground package you ship to any address within all 50 states and Puerto Rico. See Terms and Conditions in the Service Guide for details.", + "ServiceSummary" : { + "Service" : { + "Description" : "UPS Next Day Air" + }, + "EstimatedArrival" : { + "Arrival" : { + "Date" : "20250918", + "Time" : "103000" + }, + "BusinessDaysInTransit" : "1", + "Pickup" : { + "Date" : "20250917", + "Time" : "181500" + }, + "DayOfWeek" : "THU", + "CustomerCenterCutoff" : "161500" + }, + "GuaranteedIndicator" : "", + "SaturdayDelivery" : "0", + "SundayDelivery" : "0" + } + } + }, { + "Service" : { + "Code" : "13", + "Description" : "" + }, + "Zone" : "134", + "RatedShipmentAlert" : [ { + "Code" : "110971", + "Description" : "Your invoice may vary from the displayed reference rates" + } ], + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "107.68" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "107.68" + }, + "NegotiatedRateCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "35.74" + } + }, + "GuaranteedDelivery" : { + "BusinessDaysInTransit" : "1", + "DeliveryByTime" : "3:00 P.M." + }, + "RatedPackage" : [ { + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "107.68" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "90.49" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "17.19" + } ], + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "107.68" + }, + "NegotiatedCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "31.81" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "35.74" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "35.74" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "3.93" + } ] + }, + "Weight" : "3.0", + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + } + } ], + "TimeInTransit" : { + "PickupDate" : "20250917", + "PackageBillType" : "03", + "Disclaimer" : "Services listed as guaranteed are backed by a money-back guarantee for transportation charges only. UPS guarantees the day of delivery for every ground package you ship to any address within all 50 states and Puerto Rico. See Terms and Conditions in the Service Guide for details.", + "ServiceSummary" : { + "Service" : { + "Description" : "UPS Next Day Air Saver" + }, + "EstimatedArrival" : { + "Arrival" : { + "Date" : "20250918", + "Time" : "230000" + }, + "BusinessDaysInTransit" : "1", + "Pickup" : { + "Date" : "20250917", + "Time" : "181500" + }, + "DayOfWeek" : "THU", + "CustomerCenterCutoff" : "161500" + }, + "GuaranteedIndicator" : "", + "SaturdayDelivery" : "0", + "SundayDelivery" : "0" + } + } + }, { + "Service" : { + "Code" : "59", + "Description" : "" + }, + "Zone" : "244", + "RatedShipmentAlert" : [ { + "Code" : "110971", + "Description" : "Your invoice may vary from the displayed reference rates" + } ], + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "42.19" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "42.19" + }, + "NegotiatedRateCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "19.76" + } + }, + "GuaranteedDelivery" : { + "BusinessDaysInTransit" : "2", + "DeliveryByTime" : "10:30 A.M." + }, + "RatedPackage" : [ { + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "42.19" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "35.45" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "6.74" + } ], + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "42.19" + }, + "NegotiatedCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "17.59" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "19.76" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "19.76" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "2.17" + } ] + }, + "Weight" : "3.0", + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + } + } ], + "TimeInTransit" : { + "PickupDate" : "20250917", + "PackageBillType" : "03", + "Disclaimer" : "Services listed as guaranteed are backed by a money-back guarantee for transportation charges only. UPS guarantees the day of delivery for every ground package you ship to any address within all 50 states and Puerto Rico. See Terms and Conditions in the Service Guide for details.", + "ServiceSummary" : { + "Service" : { + "Description" : "UPS 2nd Day Air Early" + }, + "EstimatedArrival" : { + "Arrival" : { + "Date" : "20250919", + "Time" : "103000" + }, + "BusinessDaysInTransit" : "2", + "Pickup" : { + "Date" : "20250917", + "Time" : "181500" + }, + "DayOfWeek" : "FRI", + "CustomerCenterCutoff" : "161500" + }, + "GuaranteedIndicator" : "", + "SaturdayDelivery" : "0", + "SundayDelivery" : "0" + } + } + }, { + "Service" : { + "Code" : "02", + "Description" : "" + }, + "Zone" : "204", + "RatedShipmentAlert" : [ { + "Code" : "110971", + "Description" : "Your invoice may vary from the displayed reference rates" + } ], + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "36.07" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "36.07" + }, + "NegotiatedRateCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "16.29" + } + }, + "GuaranteedDelivery" : { + "BusinessDaysInTransit" : "2" + }, + "RatedPackage" : [ { + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "36.07" + }, + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "30.31" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "5.76" + } ], + "TotalCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "36.07" + }, + "NegotiatedCharges" : { + "BaseServiceCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "14.50" + }, + "TransportationCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "16.29" + }, + "ServiceOptionsCharges" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "0.00" + }, + "TotalCharge" : { + "CurrencyCode" : "USD", + "MonetaryValue" : "16.29" + }, + "ItemizedCharges" : [ { + "Code" : "375", + "CurrencyCode" : "USD", + "MonetaryValue" : "1.79" + } ] + }, + "Weight" : "3.0", + "BillingWeight" : { + "UnitOfMeasurement" : { + "Code" : "LBS", + "Description" : "Pounds" + }, + "Weight" : "3.0" + } + } ], + "TimeInTransit" : { + "PickupDate" : "20250917", + "PackageBillType" : "03", + "Disclaimer" : "Services listed as guaranteed are backed by a money-back guarantee for transportation charges only. UPS guarantees the day of delivery for every ground package you ship to any address within all 50 states and Puerto Rico. See Terms and Conditions in the Service Guide for details.", + "ServiceSummary" : { + "Service" : { + "Description" : "UPS 2nd Day Air" + }, + "EstimatedArrival" : { + "Arrival" : { + "Date" : "20250919", + "Time" : "230000" + }, + "BusinessDaysInTransit" : "2", + "Pickup" : { + "Date" : "20250917", + "Time" : "181500" + }, + "DayOfWeek" : "FRI", + "CustomerCenterCutoff" : "161500" + }, + "SaturdayDelivery" : "0", + "SundayDelivery" : "0" + } + } + } ] + } +} \ No newline at end of file diff --git a/src/test/resources/trackingNotFoundResponse.json b/src/test/resources/trackingNotFoundResponse.json index 1cc2ec5..bfde05e 100644 --- a/src/test/resources/trackingNotFoundResponse.json +++ b/src/test/resources/trackingNotFoundResponse.json @@ -1,14 +1,14 @@ -{ - "trackResponse": { - "shipment": [ - { - "warnings": [ - { - "code": "TW0001", - "message": "Tracking Information Not Found" - } - ] - } - ] - } -} +{ + "trackResponse": { + "shipment": [ + { + "warnings": [ + { + "code": "TW0001", + "message": "Tracking Information Not Found" + } + ] + } + ] + } +}