Sha256: 6e3854116ec5891e8f0e05a377c9a30c66567f37f740be2fa4b37e09ac3f85af
Contents?: true
Size: 1.31 KB
Versions: 25
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true require 'eac_rest/api' require 'eac_ruby_utils/core_ext' require 'ehbrs_ruby_utils/web_utils/request_error' require 'avm/instances/base' module EhbrsRubyUtils module WebUtils class Instance < ::Avm::Instances::Base class HttpRequest enable_method_class enable_simple_cache common_constructor :instance, :resource_url_suffix, :source_options, default: [{}] # @return [EacRest::Response] def result r = request.response ::EhbrsRubyUtils::WebUtils::RequestError.raise_if_error(r) ::Struct.new(:status, :body).new(r.status, ::JSON.parse(r.body_str)) end private # @return [::Struct.new(:verb, :body_data, :headers)] def options_uncached options = source_options.to_options_consumer verb = options.consume(:method, :get).to_sym body_data = options.consume(:body) headers = options.consume(:header) options.validate ::Struct.new(:verb, :body_data, :headers).new(verb, body_data, headers) end # @return [EacRest::Request] def request instance.api.request(resource_url_suffix).verb(options.verb).headers(options.headers) .body_data(options.body_data) end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems