Skip to content

forcedotcom/sf-skills / plugins/builder/integration/skills/integration-connectivity-generate

integration-connectivity-generate

Verified

Salesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use integration-connectivity-connected-app-configure), Apex-only logic (use platform-apex-generate), data import/export (use platform-data-manage), or CDC channel-membership metadata such as PlatformEventChannel, PlatformEventChannelMember, or EnrichedField (use integration-eventing-cdc-configure).

FileKindSize
README.mdmarkdown3.5 KB
SKILL.mdskill md8.8 KB
assets/callouts/callout-retry-handler.clsother6.0 KB
assets/callouts/http-response-handler.clsother8.5 KB
assets/callouts/rest-queueable-callout.clsother8.8 KB
assets/callouts/rest-sync-callout.clsother7.4 KB
assets/cdc/cdc-handler.clsother8.4 KB
assets/cdc/cdc-subscriber-trigger.triggerother5.3 KB
assets/endpoint-security/example.cspTrustedSite-meta.xmlconfig1.8 KB
assets/endpoint-security/example.remoteSite-meta.xmlconfig1.3 KB
assets/external-credentials/jwt-external-credential.externalCredential-meta.xmlconfig3.2 KB
assets/external-credentials/oauth-external-credential.externalCredential-meta.xmlconfig3.0 KB
assets/external-services/external-service-operations.mdmarkdown5.5 KB
assets/external-services/openapi-registration.externalServiceRegistration-meta.xmlconfig4.8 KB
assets/named-credentials/certificate-auth.namedCredential-meta.xmlconfig2.2 KB
assets/named-credentials/custom-auth.namedCredential-meta.xmlconfig2.2 KB
assets/named-credentials/oauth-client-credentials.namedCredential-meta.xmlconfig1.8 KB
assets/named-credentials/oauth-jwt-bearer.namedCredential-meta.xmlconfig2.2 KB
assets/platform-events/event-publisher.clsother6.4 KB
assets/platform-events/event-subscriber-action.clsother9.5 KB
assets/platform-events/event-subscriber-trigger.triggerother3.9 KB
assets/platform-events/platform-event-definition.object-meta.xmlconfig3.7 KB
assets/soap/soap-callout-service.clsother6.4 KB
assets/soap/wsdl2apex-guide.mdmarkdown6.2 KB
references/callout-patterns.mdmarkdown21.8 KB
references/cdc-guide.mdmarkdown8.2 KB
references/cli-reference.mdmarkdown2.9 KB
references/event-driven-architecture-guide.mdmarkdown10.1 KB
references/event-patterns.mdmarkdown27.2 KB
references/external-services-guide.mdmarkdown8.4 KB
references/messaging-api-v2.mdmarkdown17.9 KB
references/named-credentials-automation.mdmarkdown6.2 KB
references/named-credentials-guide.mdmarkdown7.1 KB
references/platform-events-guide.mdmarkdown6.6 KB
references/rest-callout-patterns.mdmarkdown8.8 KB
references/scoring-rubric.mdmarkdown2.4 KB
references/security-best-practices.mdmarkdown5.9 KB
scripts/README.mdmarkdown2.9 KB
scripts/configure-named-credential.shexecutablescript9.2 KB
scripts/set-api-credential.shexecutablescript4.9 KB
scripts/suggest_credential_setup.pyscript9.3 KB
scripts/templates/setup-credentials-with-csp.shexecutablescript5.9 KB
scripts/validate_integration.pyscript13.4 KB

assets/callouts/http-response-handler.cls

View on GitHub
/**
 * @description HTTP Response Handler Utility
 *
 * Use Case: Standardized response parsing and error handling
 * - Parse JSON responses to typed objects
 * - Handle different content types
 * - Extract error messages from various API formats
 * - Logging for debugging
 *
 * @author {{Author}}
 * @date {{Date}}
 */
public with sharing class HttpResponseHandler {

    /**
     * @description Parse HTTP response to Map
     * @param response HttpResponse to parse
     * @return Parsed response as Map<String, Object>
     * @throws HttpResponseException for error status codes
     */
    public static Map<String, Object> parseJsonResponse(HttpResponse response) {
        validateSuccessResponse(response);

        String body = response.getBody();
        if (String.isBlank(body) || response.getStatusCode() == 204) {
            return new Map<String, Object>();
        }

        try {
            return (Map<String, Object>) JSON.deserializeUntyped(body);
        } catch (JSONException e) {
            throw new HttpResponseException(
                'Failed to parse JSON response: ' + e.getMessage() +
                '. Body: ' + body.left(500)
            );
        }
    }

    /**
     * @description Parse HTTP response to List
     * @param response HttpResponse to parse
     * @return Parsed response as List<Object>
     * @throws HttpResponseException for error status codes
     */
    public static List<Object> parseJsonArrayResponse(HttpResponse response) {
        validateSuccessResponse(response);

        String body = response.getBody();
        if (String.isBlank(body)) {
            return new List<Object>();
        }

        try {
            return (List<Object>) JSON.deserializeUntyped(body);
        } catch (JSONException e) {
            throw new HttpResponseException(
                'Failed to parse JSON array response: ' + e.getMessage()
            );
        }
    }

    /**
     * @description Parse HTTP response to specific type
     * @param response HttpResponse to parse
     * @param targetType Apex type to deserialize to
     * @return Deserialized object
     * @throws HttpResponseException for error status codes
     */
    public static Object parseTypedResponse(HttpResponse response, Type targetType) {
        validateSuccessResponse(response);

        String body = response.getBody();
        if (String.isBlank(body)) {
            return null;
        }

        try {
            return JSON.deserialize(body, targetType);
        } catch (JSONException e) {
            throw new HttpResponseException(
                'Failed to deserialize response to ' + targetType.getName() + ': ' + e.getMessage()
            );
        }
    }

    /**
     * @description Validate response is successful (2xx)
     * @param response HttpResponse to validate
     * @throws HttpResponseException for non-2xx status codes
     */
    public static void validateSuccessResponse(HttpResponse response) {
        Integer statusCode = response.getStatusCode();

        // Log response for debugging
        logResponse(response);

        if (statusCode >= 200 && statusCode < 300) {
            return; // Success
        }

        String errorMessage = extractErrorMessage(response);

        if (statusCode >= 400 && statusCode < 500) {
            throw new ClientErrorException(
                'HTTP ' + statusCode + ': ' + errorMessage
            );
        }

        if (statusCode >= 500) {
            throw new ServerErrorException(
                'HTTP ' + statusCode + ': ' + errorMessage
            );
        }

        throw new HttpResponseException(
            'Unexpected HTTP status ' + statusCode + ': ' + errorMessage
        );
    }

    /**
     * @description Extract error message from response body
     * @param response HttpResponse containing error
     * @return Error message string
     */
    public static String extractErrorMessage(HttpResponse response) {
        String body = response.getBody();

        if (String.isBlank(body)) {
            return 'No response body';
        }

        // Try to parse as JSON error
        try {
            Map<String, Object> errorObj = (Map<String, Object>) JSON.deserializeUntyped(body);

            // Common error formats
            // Format 1: { "error": "message" }
            if (errorObj.containsKey('error')) {
                Object error = errorObj.get('error');
                if (error instanceof String) {
                    return (String) error;
                }
                if (error instanceof Map<String, Object>) {
                    Map<String, Object> errorMap = (Map<String, Object>) error;
                    if (errorMap.containsKey('message')) {
                        return (String) errorMap.get('message');
                    }
                }
            }

            // Format 2: { "message": "error message" }
            if (errorObj.containsKey('message')) {
                return (String) errorObj.get('message');
            }

            // Format 3: { "errors": [{ "message": "..." }] }
            if (errorObj.containsKey('errors')) {
                Object errors = errorObj.get('errors');
                if (errors instanceof List<Object>) {
                    List<Object> errorList = (List<Object>) errors;
                    if (!errorList.isEmpty()) {
                        Object firstError = errorList[0];
                        if (firstError instanceof Map<String, Object>) {
                            Map<String, Object> errMap = (Map<String, Object>) firstError;
                            if (errMap.containsKey('message')) {
                                return (String) errMap.get('message');
                            }
                        }
                        if (firstError instanceof String) {
                            return (String) firstError;
                        }
                    }
                }
            }

            // Format 4: { "detail": "error detail" }
            if (errorObj.containsKey('detail')) {
                return (String) errorObj.get('detail');
            }

            // Fallback: return serialized error object
            return JSON.serialize(errorObj);

        } catch (Exception e) {
            // Not JSON - return raw body (truncated)
            return body.left(1000);
        }
    }

    /**
     * @description Log HTTP response for debugging
     * @param response HttpResponse to log
     */
    private static void logResponse(HttpResponse response) {
        System.debug(LoggingLevel.DEBUG, '=== HTTP Response ===');
        System.debug(LoggingLevel.DEBUG, 'Status: ' + response.getStatusCode() + ' ' + response.getStatus());

        // Log important headers
        String[] headerKeys = new String[]{ 'Content-Type', 'X-Request-Id', 'Retry-After', 'X-RateLimit-Remaining' };
        for (String key : headerKeys) {
            String value = response.getHeader(key);
            if (String.isNotBlank(value)) {
                System.debug(LoggingLevel.DEBUG, key + ': ' + value);
            }
        }

        // Log body (truncated for large responses)
        String body = response.getBody();
        if (String.isNotBlank(body)) {
            System.debug(LoggingLevel.DEBUG, 'Body: ' + body.left(5000));
        }
    }

    /**
     * @description Get response header value
     * @param response HttpResponse
     * @param headerName Header name to retrieve
     * @return Header value or null
     */
    public static String getHeader(HttpResponse response, String headerName) {
        return response.getHeader(headerName);
    }

    /**
     * @description Check if response indicates success
     * @param response HttpResponse to check
     * @return True if status code is 2xx
     */
    public static Boolean isSuccess(HttpResponse response) {
        Integer statusCode = response.getStatusCode();
        return statusCode >= 200 && statusCode < 300;
    }

    /**
     * @description Check if response indicates rate limiting
     * @param response HttpResponse to check
     * @return True if status code is 429
     */
    public static Boolean isRateLimited(HttpResponse response) {
        return response.getStatusCode() == 429;
    }

    /**
     * @description Base exception for HTTP response errors
     */
    public virtual class HttpResponseException extends Exception {}

    /**
     * @description Exception for 4xx client errors
     */
    public class ClientErrorException extends HttpResponseException {}

    /**
     * @description Exception for 5xx server errors
     */
    public class ServerErrorException extends HttpResponseException {}
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall