44import com .easypost .http .Requestor ;
55import com .easypost .http .Requestor .RequestMethod ;
66import com .easypost .model .FedExAccountValidationResponse ;
7- import com .easypost .model .FedexRegistration ;
7+ import com .easypost .model .FedExRequestPinResponse ;
88
99import java .util .HashMap ;
1010import java .util .Map ;
@@ -27,8 +27,9 @@ public class FedexRegistrationService {
2727 * Advanced method for custom parameter structures.
2828 *
2929 * @param fedexAccountNumber The FedEx account number.
30- * @param params Map of parameters.
31- * @return FedExAccountValidationResponse object with next steps (PIN or invoice validation).
30+ * @param params Map of parameters.
31+ * @return FedExAccountValidationResponse object with next steps (PIN or invoice
32+ * validation).
3233 * @throws EasyPostException when the request fails.
3334 */
3435 public FedExAccountValidationResponse registerAddress (final String fedexAccountNumber ,
@@ -44,26 +45,26 @@ public FedExAccountValidationResponse registerAddress(final String fedexAccountN
4445 * Request a PIN for FedEx account verification.
4546 *
4647 * @param fedexAccountNumber The FedEx account number.
47- * @param pinMethodOption The PIN delivery method: "SMS", "CALL", or "EMAIL".
48+ * @param pinMethodOption The PIN delivery method: "SMS", "CALL", or "EMAIL".
4849 * @return FedExRequestPinResponse object confirming PIN was sent.
4950 * @throws EasyPostException when the request fails.
5051 */
5152 public FedExRequestPinResponse requestPin (final String fedexAccountNumber , final String pinMethodOption )
5253 throws EasyPostException {
53- Map <String , Object > pinMethod = new HashMap <>();
54- pinMethod . put ( "option" , pinMethodOption );
55-
56- Map < String , Object > params = new HashMap <>( );
57- params . put ( "pin_method " , pinMethod );
54+ Map <String , Object > wrappedParams = new HashMap <>();
55+ Map < String , Object > pinMethodMap = new HashMap <>( );
56+ pinMethodMap . put ( "option" , pinMethodOption );
57+ wrappedParams . put ( "pin_method" , pinMethodMap );
58+ String endpoint = String . format ( "fedex_registrations/%s/pin " , fedexAccountNumber );
5859
59- return requestPin ( fedexAccountNumber , params );
60+ return Requestor . request ( RequestMethod . POST , endpoint , wrappedParams , FedExRequestPinResponse . class , client );
6061 }
6162
6263 /**
6364 * Validate the PIN entered by the user for FedEx account verification.
6465 *
6566 * @param fedexAccountNumber The FedEx account number.
66- * @param params Map of parameters.
67+ * @param params Map of parameters.
6768 * @return FedExAccountValidationResponse object.
6869 * @throws EasyPostException when the request fails.
6970 */
@@ -72,39 +73,43 @@ public FedExAccountValidationResponse validatePin(final String fedexAccountNumbe
7273 Map <String , Object > wrappedParams = wrapPinValidation (params );
7374 String endpoint = String .format ("fedex_registrations/%s/pin/validate" , fedexAccountNumber );
7475
75- return Requestor .request (RequestMethod .POST , endpoint , wrappedParams , FedexRegistration .class , client );
76+ return Requestor .request (RequestMethod .POST , endpoint , wrappedParams , FedExAccountValidationResponse .class ,
77+ client );
7678 }
7779
7880 /**
7981 * Submit invoice information to complete FedEx account registration.
8082 *
8183 * @param fedexAccountNumber The FedEx account number.
82- * @param params Map of parameters.
84+ * @param params Map of parameters.
8385 * @return FedExAccountValidationResponse object.
8486 * @throws EasyPostException when the request fails.
8587 */
86- public FedExAccountValidationResponse submitInvoice (final String fedexAccountNumber , final Map <String , Object > params )
88+ public FedExAccountValidationResponse submitInvoice (final String fedexAccountNumber ,
89+ final Map <String , Object > params )
8790 throws EasyPostException {
8891 Map <String , Object > wrappedParams = wrapInvoiceValidation (params );
8992 String endpoint = String .format ("fedex_registrations/%s/invoice" , fedexAccountNumber );
9093
91- return Requestor .request (RequestMethod .POST , endpoint , wrappedParams , FedexRegistration .class , client );
94+ return Requestor .request (RequestMethod .POST , endpoint , wrappedParams , FedExAccountValidationResponse .class ,
95+ client );
9296 }
9397
9498 /**
9599 * Wraps address validation parameters and ensures the "name" field exists.
96100 * If not present, generates a UUID (with hyphens removed) as the name.
97101 *
98102 * @param params The original parameters map.
99- * @return A new map with properly wrapped address_validation and easypost_details.
103+ * @return A new map with properly wrapped address_validation and
104+ * easypost_details.
100105 */
101106 @ SuppressWarnings ("unchecked" )
102107 private Map <String , Object > wrapAddressValidation (final Map <String , Object > params ) {
103108 Map <String , Object > wrappedParams = new HashMap <>();
104109
105110 if (params .containsKey ("address_validation" )) {
106111 Map <String , Object > addressValidation = new HashMap <>(
107- (Map <String , Object >) params .get ("address_validation" ));
112+ (Map <String , Object >) params .get ("address_validation" ));
108113 ensureNameField (addressValidation );
109114 wrappedParams .put ("address_validation" , addressValidation );
110115 }
@@ -129,7 +134,7 @@ private Map<String, Object> wrapPinValidation(final Map<String, Object> params)
129134
130135 if (params .containsKey ("pin_validation" )) {
131136 Map <String , Object > pinValidation = new HashMap <>(
132- (Map <String , Object >) params .get ("pin_validation" ));
137+ (Map <String , Object >) params .get ("pin_validation" ));
133138 ensureNameField (pinValidation );
134139 wrappedParams .put ("pin_validation" , pinValidation );
135140 }
@@ -146,15 +151,16 @@ private Map<String, Object> wrapPinValidation(final Map<String, Object> params)
146151 * If not present, generates a UUID (with hyphens removed) as the name.
147152 *
148153 * @param params The original parameters map.
149- * @return A new map with properly wrapped invoice_validation and easypost_details.
154+ * @return A new map with properly wrapped invoice_validation and
155+ * easypost_details.
150156 */
151157 @ SuppressWarnings ("unchecked" )
152158 private Map <String , Object > wrapInvoiceValidation (final Map <String , Object > params ) {
153159 Map <String , Object > wrappedParams = new HashMap <>();
154160
155161 if (params .containsKey ("invoice_validation" )) {
156162 Map <String , Object > invoiceValidation = new HashMap <>(
157- (Map <String , Object >) params .get ("invoice_validation" ));
163+ (Map <String , Object >) params .get ("invoice_validation" ));
158164 ensureNameField (invoiceValidation );
159165 wrappedParams .put ("invoice_validation" , invoiceValidation );
160166 }
0 commit comments