@@ -39,15 +39,10 @@ export default (easypostClient) =>
3939 * @returns {CarrierAccount } - The updated carrier account.
4040 */
4141 static async update ( id , params ) {
42- const carrierAccount = await this . retrieve ( id ) ;
43-
44- const carrierAccountType = carrierAccount . type ;
45-
46- const endpoint = this . _selectCarrierAccountUpdateEndpoint ( carrierAccountType , id ) ;
47- const wrappedParams = this . _wrapCarrierAccountParams ( carrierAccountType , params ) ;
42+ const wrappedParams = { carrier_account : params } ;
4843
4944 try {
50- const response = await easypostClient . _patch ( endpoint , wrappedParams ) ;
45+ const response = await easypostClient . _patch ( `carrier_accounts/ ${ id } ` , wrappedParams ) ;
5146
5247 return this . _convertToEasyPostObject ( response . body , wrappedParams ) ;
5348 } catch ( e ) {
@@ -82,29 +77,13 @@ export default (easypostClient) =>
8277 static _selectCarrierAccountCreationEndpoint ( carrierAccountType ) {
8378 if ( Constants . CARRIER_ACCOUNTS_WITH_CUSTOM_CREATE_WORKFLOWS . includes ( carrierAccountType ) ) {
8479 return 'carrier_accounts/register' ;
85- } else if ( Constants . UPS_OAUTH_CARRIER_TYPES . includes ( carrierAccountType ) ) {
86- return 'ups_oauth_registrations' ;
8780 } else if ( Constants . CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH . includes ( carrierAccountType ) ) {
8881 return 'carrier_accounts/register_oauth' ;
8982 }
9083
9184 return 'carrier_accounts' ;
9285 }
9386
94- /**
95- * Returns the correct carrier_account endpoint when updating a record based on the type.
96- * @private
97- * @param {string } carrierAccountType - The type of carrier account to be updated.
98- * @param {string } carrierAccountId - The ID of the carrier account to be updated.
99- * @returns {string } - The endpoint to be used for the carrier account update request.
100- */
101- static _selectCarrierAccountUpdateEndpoint ( carrierAccountType , carrierAccountId ) {
102- if ( Constants . UPS_OAUTH_CARRIER_TYPES . includes ( carrierAccountType ) ) {
103- return `ups_oauth_registrations/${ carrierAccountId } ` ;
104- }
105- return `carrier_accounts/${ carrierAccountId } ` ;
106- }
107-
10887 /**
10988 * Wraps the carrier account parameters in the correct format based on the type.
11089 * @private
@@ -113,9 +92,7 @@ export default (easypostClient) =>
11392 * @returns {Object } - The wrapped carrier account parameters.
11493 */
11594 static _wrapCarrierAccountParams ( carrierAccountType , params ) {
116- if ( Constants . UPS_OAUTH_CARRIER_TYPES . includes ( carrierAccountType ) ) {
117- return { ups_oauth_registrations : params } ;
118- } else if ( Constants . CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH . includes ( carrierAccountType ) ) {
95+ if ( Constants . CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH . includes ( carrierAccountType ) ) {
11996 return { carrier_account_oauth_registrations : params } ;
12097 }
12198
0 commit comments