Module: FsApi::Service::Searchable
Instance Method Summary collapse
Instance Method Details
#search(options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fs_api/service/searchable.rb', line 4 def search() if .is_a? String field = 'all' value = elsif .is_a? Hash field, value = .first end search_path = ["search#{path}", field, value].join('/') if response = api_client.get(search_path) if response.code.to_i == success_status_code JSON.parse(response.body).map do |attributes| collection_class.new(attributes.merge(from_api: true)) end end end end |