Standardize API integration patterns

Establish consistent patterns for API integrations by following these guidelines: 1. Document API endpoint usage specifically: - Clearly specify which components use each endpoint

copy reviewer prompt

Prompt

Reviewer Prompt

Establish consistent patterns for API integrations by following these guidelines:

  1. Document API endpoint usage specifically:
    • Clearly specify which components use each endpoint
    • Include expected request/response formats
    • Document any authentication requirements
  2. Standardize request handling: ```ruby

    Good - Clear request configuration

    def api_request(url_options) type = if (data = url_options[:data].presence) :data elsif (data = url_options[:json].presence) :json end

case data when Hash if type == :json [”–#{type}”, JSON.generate(data)] else [”–#{type}”, URI.encode_www_form(data)] end end end ```

  1. Handle API response evolution:
    • Document field deprecations clearly
    • Consider backwards compatibility needs
    • Provide migration paths for breaking changes
  2. Implement consistent error handling:
    • Handle API-specific errors explicitly
    • Provide meaningful error messages
    • Include fallback behaviors where appropriate

This standardization ensures maintainable and reliable API integrations while promoting clear documentation and consistent implementation patterns across the codebase.

Source discussions