lib/ringcentral_sdk/rest/client.rb in ringcentral_sdk-1.1.0 vs lib/ringcentral_sdk/rest/client.rb in ringcentral_sdk-1.1.1
- old
+ new
@@ -165,28 +165,30 @@
api_key = (@app_config.key.is_a?(String) && @app_config.secret.is_a?(String)) \
? Base64.encode64("#{@app_config.key}:#{@app_config.secret}").gsub(/[\s\t\r\n]/,'') : ''
return api_key
end
- def send_request(request_sdk = nil)
- unless request_sdk.is_a?(RingCentralSdk::REST::Request::Base)
+ def send_request(request_sdk = {})
+ if request_sdk.is_a? Hash
+ request_sdk = RingCentralSdk::REST::Request::Simple.new(request_sdk)
+ elsif !request_sdk.is_a? RingCentralSdk::REST::Request::Base
fail 'Request is not a RingCentralSdk::REST::Request::Base'
end
res = nil
-
method = request_sdk.method.downcase
+
case method
when 'delete'
res = @http.delete { |req| req = inflate_request(req, request_sdk) }
when 'get'
res = @http.get { |req| req = inflate_request(req, request_sdk) }
when 'post'
res = @http.post { |req| req = inflate_request(req, request_sdk) }
when 'put'
res = @http.put { |req| req = inflate_request(req, request_sdk) }
else
- fail "#{method} not support"
+ fail "#{method} not supported"
end
return res
end
def inflate_request(req_faraday, req_sdk)