Sha256: 818f70d418dde4ae6796a4c6427fbd7da33f920b7b659877cd626aad726536d6

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

# frozen_string_literal: true

require_relative 'base'

module BddOpenai
  module Services
    module Files
      class List < Base
        # @return [Array<BddOpenai::Mapper::File>, BddOpenai::ErrorResponse]
        def list_files
          uri = URI.parse("#{@openai_api_domain}/files")
          response = @http_client.call_get(uri, default_headers)
          return BddOpenai::ErrorResponse.from_json(response.body) unless response.code == '200'

          JSON.parse(response.body)['data'].map do |file|
            BddOpenai::Mapper::File.from_json(file.to_json)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bdd_openai-1.1.0 lib/bdd_openai/services/files/list.rb