motion-prime/api_client.rb in motion-prime-0.5.4 vs motion-prime/api_client.rb in motion-prime-0.5.5
- old
+ new
@@ -36,12 +36,13 @@
client_id: config.client_id,
client_secret: config.client_secret
}
use_callback = block_given?
BW::HTTP.post("#{config.base}#{config.auth_path}", request_params(data)) do |response|
- auth_data = if response.ok?
- parse_json(response.body)
+ body = response.body.to_s
+ auth_data = if body.present?
+ parse_json(body)
else
false
end
self.access_token = auth_data[:access_token] if auth_data
block.call(auth_data, response.status_code) if use_callback
@@ -120,10 +121,10 @@
Prime::JSON.parse(text)
rescue
NSLog("Can't parse json: #{text}")
false
end
-
+
def user_defaults
@user_defaults ||= NSUserDefaults.standardUserDefaults
end
end
\ No newline at end of file