lib/qismo/client.rb in qismo-0.9.0 vs lib/qismo/client.rb in qismo-0.10.0
- old
+ new
@@ -37,29 +37,29 @@
# Send http request with post method
#
# @param path [String]
# @param body [Hash]
- # @return [Qismo::DataObject]
+ # @return [Qismo::SingleObject]
def post(path, body = {})
request(:post, path, json: body)
end
# Http request with post method to upload file
#
# @param path [String]
# @param body [Hash]
- # @return [Qismo::DataObject]
+ # @return [Qismo::SingleObject]
def post_upload(path, body = {})
request(:post, form: body)
end
# Send http request with get method
#
# @param path [String]
# @param params [Hash]
- # @return [Qismo::DataObject]
+ # @return [Qismo::SingleObject]
def get(path, **params)
request(:get, path, params: params)
end
def delete(path)
@@ -69,25 +69,25 @@
# Send http request
#
# @param method [Symbol, String]
# @param path [String]
# @param body [Hash]
- # @return [Qismo::DataObject]
+ # @return [Qismo::SingleObject]
def request(method, path, opt = {})
res = connection.request(method, @url + path, opt.compact)
if res.status.success?
- return DataObject.new(JSON.parse(res.to_s))
+ return SingleObject.new(JSON.parse(res.to_s))
end
if res.status.server_error?
raise InternalServerError.new("Qiscus Omnichannel server error", status_code: res.code, response_body: res.to_s)
end
if res.status.client_error?
- body = DataObject.new(JSON.parse(res.to_s))
+ body = SingleObject.new(JSON.parse(res.to_s))
error = body.errors
- error = error.message if error.is_a?(DataObject)
+ error = error.message if error.is_a?(SingleObject)
error_klass_map = {
400 => BadRequestError,
401 => UnauthorizedError,
402 => PaymentRequiredError,