require "httparty"

module ExternalApi
  class <%= pascalCaseName %>Service
    BASE_URL = "<%= baseUrl %>"
    ENDPOINT = "<%= endpoint %>"
    RAPIDAPI_HOST = "<%= apiHost %>"
    RAPIDAPI_KEY = "<%= apiKey %>"

    def self.<%= camelCaseName %>(query)
      query_params = {
        username: query["username"]
      }

      headers = {
        'x-rapidapi-host': RAPIDAPI_HOST,
        'x-rapidapi-key': RAPIDAPI_KEY
      }

      response = HTTParty.get(
        "#{BASE_URL}#{ENDPOINT}",
        query: query_params,
        headers: headers
      )

      if response.success?
        response.parsed_response
      else
        raise ExternalApi::Error, "<%= pascalCaseName %> API request failed: #{response.code}"
      end
    end
  end
end 