class SBF::Client::KidEndpoint
Public Instance Methods
find_random(filter = [], limit = 20, with = {})
click to toggle source
# File lib/stbaldricks/endpoints/kid.rb, line 7 def find_random(filter = [], limit = 20, with = {}) filter = filter.to_json unless filter.is_a? String with = normalize_with(with) response = SBF::Client::Api::Request.get_request("#{base_uri}/find_random", filter: filter, limit: limit, with: with) parsed_response_body = JSON.parse(response.body).symbolize! if ok?(response) parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data) } SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count]) else parsed_response_body = JSON.parse(response.body).symbolize! error = SBF::Client::ErrorEntity.new(parsed_response_body) collection = SBF::Client::EntityCollection.new collection.add_errors(error) collection.errors_http_code = response.code collection end end