lib/osm/api.rb in osm-0.1.11 vs lib/osm/api.rb in osm-0.1.12
- old
+ new
@@ -15,11 +15,11 @@
}
# Configure the API options used by all instances of the class
# @param [Hash] options
- # @option options [Symbol] :default_site wether to use OSM (if :osm) or OGM (if :ogm)
+ # @option options [Symbol] :default_site whether to use OSM (if :osm) or OGM (if :ogm)
# @option options [Hash] :osm (optional but :osm_api or :ogm_api must be present) the api data for OSM
# @option options[:osm] [String] :id the apiid given to you for using the OSM id
# @option options[:osm] [String] :token the token which goes with the above api
# @option options[:osm] [String] :name the name displayed in the External Access tab of OSM
# @option options [Hash] :ogm (optional but :osm_api or :ogm_api must be present) the api data for OGM
@@ -51,11 +51,11 @@
end
# Initialize a new API connection
# @param [String] user_id osm userid of the user to act as (get this by using the authorize method)
# @param [String] secret osm secret of the user to act as (get this by using the authorize method)
- # @param [Symbol] site wether to use OSM (:osm) or OGM (:ogm), defaults to the value set for the class
+ # @param [Symbol] site whether to use OSM (:osm) or OGM (:ogm), defaults to the value set for the class
# @return nil
def initialize(user_id, secret, site=@@site)
raise ArgumentError, 'You must pass a secret (get this by using the authorize method)' if secret.nil?
raise ArgumentError, 'You must pass a user_id (get this by using the authorize method)' if user_id.nil?
raise ArgumentError, 'site is invalid, if passed it should be either :osm or :ogm, if not passed then you forgot to run Api.configure' unless [:osm, :ogm].include?(site)
@@ -169,9 +169,10 @@
if @@debug
puts "Result from :#{site} request to #{url}"
puts result.response.body
end
+ return nil if result.response.body.empty?
raise Osm::Error, result.response.body unless looks_like_json?(result.response.body)
decoded = ActiveSupport::JSON.decode(result.response.body)
osm_error = get_osm_error(decoded)
raise Osm::Error, osm_error if osm_error
return decoded