@@ -65,13 +65,15 @@ export const getAuthToken = async (context: HerculesFunctionContext) => {
6565 client_secret : context . matchedConfig . findConfig ( "client_secret" ) as string ,
6666 grant_type : "client_credentials"
6767 }
68+ const url = context . matchedConfig . findConfig ( "auth_url" ) as string
69+
6870 if ( cachedToken . expiresAt > Date . now ( ) ) {
6971 console . log ( "Using cached access token" )
7072 return cachedToken . token
7173 }
7274
7375
74- const authValue = await axios . post ( "https://api-sandbox.gls-group.net/oauth2/v2/token" , AuthenticationRequestDataSchema . parse ( data ) , {
76+ const authValue = await axios . post ( url , AuthenticationRequestDataSchema . parse ( data ) , {
7577 headers : {
7678 "Content-Type" : "application/x-www-form-urlencoded"
7779 }
@@ -87,7 +89,7 @@ export const getAuthToken = async (context: HerculesFunctionContext) => {
8789}
8890
8991export const validateShipment = async ( data : ValidateShipmentRequestData , context : HerculesFunctionContext ) : Promise < ValidateShipmentResponseData > => {
90- const url = context ?. matchedConfig . findConfig ( "api_url " ) as string ;
92+ const url = context ?. matchedConfig . findConfig ( "ship_it_api_url " ) as string ;
9193 const contactID = context ?. matchedConfig . findConfig ( "contact_id" ) as string || ""
9294
9395 try {
@@ -104,7 +106,7 @@ export const validateShipment = async (data: ValidateShipmentRequestData, contex
104106
105107}
106108export const reprintParcel = async ( data : ReprintParcelRequestData , context : HerculesFunctionContext ) : Promise < ReprintParcelResponseData > => {
107- const url = context . matchedConfig . findConfig ( "api_url " ) as string ;
109+ const url = context . matchedConfig . findConfig ( "ship_it_api_url " ) as string ;
108110
109111 try {
110112 const result = await axios . post ( `${ url } /rs/shipments/reprintparcel` , data , {
@@ -121,7 +123,7 @@ export const reprintParcel = async (data: ReprintParcelRequestData, context: Her
121123}
122124
123125export const updateParcelWeight = async ( data : UpdateParcelWeightRequestData , context : HerculesFunctionContext ) : Promise < UpdateParcelWeightResponseData > => {
124- const url = context . matchedConfig . findConfig ( "api_url " ) as string ;
126+ const url = context . matchedConfig . findConfig ( "ship_it_api_url " ) as string ;
125127
126128 try {
127129 const result = await axios . post ( `${ url } /rs/shipments/updateparcelweight` , data , {
@@ -139,7 +141,7 @@ export const updateParcelWeight = async (data: UpdateParcelWeightRequestData, co
139141}
140142
141143export const getEndOfDayInfo = async ( data : EndOfDayRequestData , context : HerculesFunctionContext ) : Promise < EndOfDayResponseData > => {
142- const url = context . matchedConfig . findConfig ( "api_url " ) as string ;
144+ const url = context . matchedConfig . findConfig ( "ship_it_api_url " ) as string ;
143145
144146 try {
145147 const result = await axios . post ( `${ url } /rs/shipments/endofday?date=${ data . date } ` , { } , {
@@ -156,7 +158,7 @@ export const getEndOfDayInfo = async (data: EndOfDayRequestData, context: Hercul
156158}
157159
158160export const getAllowedServices = async ( data : AllowedServicesRequestData , context : HerculesFunctionContext ) : Promise < AllowedServicesResponseData > => {
159- const url = context . matchedConfig . findConfig ( "api_url " ) as string ;
161+ const url = context . matchedConfig . findConfig ( "ship_it_api_url " ) as string ;
160162
161163 try {
162164 const result = await axios . post ( `${ url } /rs/shipments/allowedservices` , data , {
@@ -184,7 +186,7 @@ export const getAllowedServices = async (data: AllowedServicesRequestData, conte
184186}
185187
186188export const cancelShipment = async ( data : CancelShipmentRequestData , context : HerculesFunctionContext ) : Promise < CancelShipmentResponseData > => {
187- const url = context . matchedConfig . findConfig ( "api_url " ) as string ;
189+ const url = context . matchedConfig . findConfig ( "ship_it_api_url " ) as string ;
188190
189191
190192 try {
@@ -208,7 +210,7 @@ export const cancelShipment = async (data: CancelShipmentRequestData, context: H
208210
209211const postShipments = async ( data : ShipmentRequestData , context : HerculesFunctionContext ) : Promise < CreateParcelsResponse > => {
210212 const contactID = context . matchedConfig . findConfig ( "contact_id" ) as string ;
211- const url = context . matchedConfig . findConfig ( "api_url " ) as string ;
213+ const url = context . matchedConfig . findConfig ( "ship_it_api_url " ) as string ;
212214
213215 const parsedData : InternalShipmentRequestData = transformShipmentRequestDataToInternalFormat ( ShipmentRequestDataSchema . parse ( data ) , context , contactID ) ;
214216
0 commit comments