Class: FluidCLI::Theme::Navigation::ResourceFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/fluid_cli/theme/navigation/resource_fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(ctx, theme_id) ⇒ ResourceFetcher

Returns a new instance of ResourceFetcher.



7
8
9
10
# File 'lib/fluid_cli/theme/navigation/resource_fetcher.rb', line 7

def initialize(ctx, theme_id)
  @ctx = ctx
  @theme_id = theme_id
end

Instance Method Details

#fetch(themeable_type) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/fluid_cli/theme/navigation/resource_fetcher.rb', line 12

def fetch(themeable_type)
  _status, body = FluidCLI::API.new(@ctx).get(
    path: "application_themes/#{@theme_id}/available_themeables",
    query: URI.encode_www_form(themeable: themeable_type, per_page: 50),
  )
  body["available_themeables"] || []
rescue FluidCLI::API::APIRequestError => e
  @ctx.debug("Failed to fetch #{themeable_type} themeables: #{e.message}")
  []
end