@shipengine/connect
Version:
The official developer tooling for building ShipEngine connect apps
22 lines (19 loc) • 1.06 kB
text/typescript
import { ValidateConnectionRequest } from "@shipengine/connect-order-source-api";
import { logger, NotImplementedError, UnAuthorizedError } from "@shipengine/connect-runtime";
const mapRequest = (request: any): any => { throw new NotImplementedError(); };
const callApi = async (request: any): Promise<any> => { throw new NotImplementedError(); };
/**
* @description Validate the connection settings for an order source
* @param request A basic request containing connection information to validate
*/
export const ValidateConnection = async (request: ValidateConnectionRequest): Promise<void> => {
logger.info('This is a log that I can find using the `connect logs` command after publishing.')
const thirdPartyRequest = mapRequest(request);
const response = await callApi(thirdPartyRequest);
if(response.status === 401) {
throw new UnAuthorizedError('Invalid API Key');
}
// Ex: if your connection form allows users to enter in
// store id's or other things, validate that those things
// belong to the account.
}