lib/deepl/requests/base.rb in deepl-rb-1.0.1 vs lib/deepl/requests/base.rb in deepl-rb-2.0.0

- old
+ new

@@ -14,16 +14,36 @@ raise NotImplementedError end private + def option?(name) + options.key?(name.to_s) || options.key?(name.to_sym) + end + def option(name) options[name.to_s] || options[name.to_sym] end + def set_option(name, value) + if options.key?(name.to_sym) + options[name.to_sym] = value + else + options[name.to_s] = value + end + end + def post(payload) request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(payload.reject { |_, v| v.nil? }) + response = http.request(request) + + validate_response!(request, response) + [request, response] + end + + def get + request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) validate_response!(request, response) [request, response] end