lib/coinsetter/net.rb in coinsetter-0.0.4 vs lib/coinsetter/net.rb in coinsetter-0.0.5
- old
+ new
@@ -25,14 +25,13 @@
body(res)
end
def self.put(path, args={}, headers={})
res = connection.put do |req|
- req.url path
- req.headers["Accept"] = "application/json"
+ req.url path, args
+ req.headers['Content-Type'] = 'application/json'
req.headers.merge!(headers)
- req.body = JSON.generate(args)
end
body(res)
end
@@ -45,13 +44,13 @@
body(res)
end
def self.body(res)
- if res.status == 403
- "403 - Forbidden: You don't have permission to access"
- else
+ if res.status == 200
res.body
+ else
+ JSON.generate({status: res.status, message: res.body})
end
end
def self.connection
@@connection ||= Faraday.new(url: uri) do |faraday|