Sha256: 3f5f846bd80f15d12de38dc8548eb80ae39574e749ff8dc58af97a641cdec12f
Contents?: true
Size: 1.15 KB
Versions: 14
Compression:
Stored size: 1.15 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 @attributes = {} 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 put response = api.put(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, @klass) 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
14 entries across 14 versions & 1 rubygems