preview.rb 595 B

12345678910111213141516171819
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::ExternalDataSource::Preview < Service::Base
  3. def execute(data_option:, render_context:, term:, limit: 10)
  4. result = ExternalDataSource.new(options: data_option, render_context:, term:, limit:).process
  5. {
  6. success: true,
  7. data: result
  8. }
  9. rescue ExternalDataSource::Errors::BaseError => e
  10. {
  11. success: false,
  12. error: e.message,
  13. response_body: e.external_data_source.json,
  14. parsed_items: e.external_data_source.parsed_items,
  15. }
  16. end
  17. end