Sha256: 43733ea16117bd97dc31c62c51aebd62e8bc4641b8de168272c11a12d3634477

Contents?: true

Size: 489 Bytes

Versions: 1

Compression:

Stored size: 489 Bytes

Contents

# frozen_string_literal: true

require "uri"
require "net/http"
require "json"

module Icarus
  module Mod
    module Tools
      # Sync helper methods
      module SyncHelpers
        def retrieve_from_url(url)
          res = Net::HTTP.get_response(URI(url))

          raise Icarus::Mod::Tools::Error, "HTTP Request failed for #{url} (#{res.code}): #{res.message}" unless res&.code == "200"

          JSON.parse(res.body, symbolize_names: true)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Icarus-Mod-Tools-1.3.3 lib/icarus/mod/tools/sync_helpers.rb