Sha256: 52da43c67c256c9797bee81e718b92017003d75366eab336b4e85ed98f92d0c2
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
require 'rest_in_peace/template_sanitizer' require 'rest_in_peace/response_converter' module RESTinPeace class ApiCall def initialize(api, url_template, klass, params) @api = api @url_template = url_template @klass = klass @params = params end def get response = api.get(url, params) convert_response(response) end def post response = api.post(url, params) convert_response(response) end def patch response = api.patch(url, params) convert_response(response) end def delete response = api.delete(url, params) convert_response(response) end def url sanitizer.url end def params sanitizer.leftover_params end def sanitizer @sanitizer ||= RESTinPeace::TemplateSanitizer.new(@url_template, @params) end def convert_response(response) RESTinPeace::ResponseConverter.new(response, @klass).result end def api @api.respond_to?(:call) ? @api.call : @api end end end
Version data entries
5 entries across 5 versions & 1 rubygems