@@ -39,15 +39,10 @@ export default (easypostClient) =>
39
39
* @returns {CarrierAccount } - The updated carrier account.
40
40
*/
41
41
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 } ;
48
43
49
44
try {
50
- const response = await easypostClient . _patch ( endpoint , wrappedParams ) ;
45
+ const response = await easypostClient . _patch ( `carrier_accounts/ ${ id } ` , wrappedParams ) ;
51
46
52
47
return this . _convertToEasyPostObject ( response . body , wrappedParams ) ;
53
48
} catch ( e ) {
@@ -82,29 +77,13 @@ export default (easypostClient) =>
82
77
static _selectCarrierAccountCreationEndpoint ( carrierAccountType ) {
83
78
if ( Constants . CARRIER_ACCOUNTS_WITH_CUSTOM_CREATE_WORKFLOWS . includes ( carrierAccountType ) ) {
84
79
return 'carrier_accounts/register' ;
85
- } else if ( Constants . UPS_OAUTH_CARRIER_TYPES . includes ( carrierAccountType ) ) {
86
- return 'ups_oauth_registrations' ;
87
80
} else if ( Constants . CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH . includes ( carrierAccountType ) ) {
88
81
return 'carrier_accounts/register_oauth' ;
89
82
}
90
83
91
84
return 'carrier_accounts' ;
92
85
}
93
86
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
-
108
87
/**
109
88
* Wraps the carrier account parameters in the correct format based on the type.
110
89
* @private
@@ -113,9 +92,7 @@ export default (easypostClient) =>
113
92
* @returns {Object } - The wrapped carrier account parameters.
114
93
*/
115
94
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 ) ) {
119
96
return { carrier_account_oauth_registrations : params } ;
120
97
}
121
98
0 commit comments