lib/qismo/client.rb in qismo-0.10.0 vs lib/qismo/client.rb in qismo-0.11.0
- old
+ new
@@ -26,13 +26,13 @@
attr_accessor(*DEFAULT_OPTIONS.keys)
# Initialize client
#
- # @param opt [Hash]
- def initialize(opt = {})
- DEFAULT_OPTIONS.merge(opt).each do |key, value|
+ # @param options [Hash]
+ def initialize(options = {})
+ DEFAULT_OPTIONS.merge(options).each do |key, value|
instance_variable_set("@#{key}", value)
end
end
# Send http request with post method
@@ -42,39 +42,51 @@
# @return [Qismo::SingleObject]
def post(path, body = {})
request(:post, path, json: body)
end
- # Http request with post method to upload file
+ # Send HTTP request with post method to upload file
#
# @param path [String]
# @param body [Hash]
# @return [Qismo::SingleObject]
def post_upload(path, body = {})
request(:post, form: body)
end
- # Send http request with get method
+ # Send HTTP request with get method
#
# @param path [String]
# @param params [Hash]
# @return [Qismo::SingleObject]
- def get(path, **params)
+ def get(path, params = {})
request(:get, path, params: params)
end
- def delete(path)
- request(:delete, path)
+ # Send HTTP request with delete method
+ #
+ # @param path [String]
+ # @param params [Hash]
+ # @return [Qismo::SingleObject]
+ def delete(path, params = {})
+ request(:delete, path, params: params)
end
- # Send http request
+ # Send HTTP request
#
# @param method [Symbol, String]
# @param path [String]
- # @param body [Hash]
+ # @param headers [Hash]
+ # @param params [Hash]
+ # @param json [Hash]
# @return [Qismo::SingleObject]
- def request(method, path, opt = {})
- res = connection.request(method, @url + path, opt.compact)
+ def request(method, path, headers: {}, params: {}, json: {})
+ res = connection.request(method, @url + path, {
+ headers: headers,
+ params: params,
+ json: json,
+ })
+
if res.status.success?
return SingleObject.new(JSON.parse(res.to_s))
end
if res.status.server_error?