Sha256: ca305bd4a943ffb1d87a63cdb5bdf97b390eb12aa927fa5d33d958795c22a49b
Contents?: true
Size: 1.07 KB
Versions: 11
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module MyApiClient module Request # Provides basic HTTP request method. module Basic HTTP_METHODS = %i[get post put patch delete].freeze HTTP_METHODS.each do |http_method| class_eval <<~METHOD, __FILE__, __LINE__ + 1 # Executes HTTP request with #{http_method.upcase} method # # @param pathname [String] # Pathname of the request target URL. # It's joined with the defined by `endpoint`. # @param headers [Hash, nil] # Request headers. # @param query [Hash, nil] # Query string. # @param body [Hash, nil] # Request body. You should not specify it when use GET method. # @return [Sawyer::Resource] # Response body instance. def #{http_method}(pathname, headers: nil, query: nil, body: nil) response = call(:_request_with_relative_uri, :#{http_method}, pathname, headers, query, body) response.data end METHOD end end end end
Version data entries
11 entries across 11 versions & 1 rubygems