lib/razorpay/request.rb in razorpay-2.0.1 vs lib/razorpay/request.rb in razorpay-2.1.0.pre

- old
+ new

@@ -44,22 +44,24 @@ def put(id, data = {}) request :put, "/#{@entity_name}/#{id}", data end + def patch(id, data = {}) + request :patch, "/#{@entity_name}/#{id}", data + end + def create(data) request :post, "/#{@entity_name}", data end def request(method, url, data = {}) case method when :get @options[:query] = data - when :post + when :post, :put, :patch @options[:body] = data - when :put - @options[:body] = data end create_instance self.class.send(method, url, @options) end # Since we need to change the base route @@ -75,11 +77,12 @@ # if there was an error, throw it raise_error(response['error'], res.code) if response.key?('error') # There must be a top level entity # This is either one of payment, refund, or collection at present - class_name = response['entity'].capitalize begin + class_name = response['entity'].split('_').collect(&:capitalize).join + klass = Razorpay.const_get class_name rescue NameError # Use Entity class if we don't find any klass = Razorpay::Entity end