Class: SBF::Client::KidEndpoint
- Inherits:
-
EntityEndpoint
- Object
- EntityEndpoint
- SBF::Client::KidEndpoint
- Defined in:
- lib/stbaldricks/endpoints/kid.rb
Instance Attribute Summary
Attributes inherited from EntityEndpoint
Instance Method Summary collapse
Methods inherited from EntityEndpoint
#aggregate, #create, #delete, #find, #find_first, #get, #initialize, #save, #update
Constructor Details
This class inherits a constructor from SBF::Client::EntityEndpoint
Instance Method Details
#find_random(filter = [], limit = 20, with = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 |