Sha256: 91de7d3a6a0d50ea3dcf4f26e631a20c8c61ee149c45331d194447fe45ecfc25

Contents?: true

Size: 632 Bytes

Versions: 4

Compression:

Stored size: 632 Bytes

Contents

# frozen_string_literal: true

require "core"

module Pennyworth
  module Integrations
    module StandardGems
      # Provides low-level API access to the Standard Gems API.
      class Client
        include Import[:configuration, :http]

        def get endpoint
          http.get("#{configuration.standard_gems_api_url}/#{endpoint}")
              .then do |response|
                response.status.success? ? records(response.body.to_s) : Core::EMPTY_HASH
              end
        end

        private

        def records(body) = JSON(body, symbolize_names: true).fetch :gems, Core::EMPTY_ARRAY
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pennyworth-15.4.1 lib/pennyworth/integrations/standard_gems/client.rb
pennyworth-15.4.0 lib/pennyworth/integrations/standard_gems/client.rb
pennyworth-15.3.0 lib/pennyworth/integrations/standard_gems/client.rb
pennyworth-15.2.0 lib/pennyworth/integrations/standard_gems/client.rb