Class: MetMuseum::Collection
- Inherits:
-
Object
- Object
- MetMuseum::Collection
- Defined in:
- lib/met_museum/collection.rb
Instance Method Summary collapse
-
#department ⇒ Array, ...
returns a listing of all departments.
-
#object(object_id) ⇒ Hash<objectID, Integer>, ...
returns a record for an object, containing all open access data about that object, including its image (if the image is available under Open Access).
-
#objects(**args) ⇒ Hash<total, Integer>, Hash<objectIDs, Array<Integer>>
Return a listing of all valid Object IDs available to use.
-
#search(query, **args) ⇒ Integer, ...
returns a listing of all Object IDs for objects that contain the search query within the object’s data.
Instance Method Details
#department ⇒ Array, ...
returns a listing of all departments
91 92 93 94 |
# File 'lib/met_museum/collection.rb', line 91 def department response = create_request(API_ENDPOINT, DEPARTMENTS_URI) arrange_response(response) end |
#object(object_id) ⇒ Hash<objectID, Integer>, ...
returns a record for an object, containing all open access data about that object, including its image (if the image is available under Open Access)
82 83 84 85 |
# File 'lib/met_museum/collection.rb', line 82 def object(object_id) response = create_request(API_ENDPOINT, "#{PUBLIC_URI}/#{object_id}") arrange_response(response) end |
#objects(**args) ⇒ Hash<total, Integer>, Hash<objectIDs, Array<Integer>>
Return a listing of all valid Object IDs available to use
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/met_museum/collection.rb', line 12 def objects(**args) = { metadataDate: nil, departmentIds: nil }.merge(args) [:metadataDate] = check_date([:metadataDate]) query = { metadataDate: [:metadataDate], departmentIds: [:departmentIds] } response = create_request(API_ENDPOINT, PUBLIC_URI, query) arrange_response(response) end |
#search(query, **args) ⇒ Integer, ...
returns a listing of all Object IDs for objects that contain the search query within the object’s data
103 104 105 106 107 108 109 110 111 |
# File 'lib/met_museum/collection.rb', line 103 def search(query, **args) args.merge!({q: query}) response = create_request(API_ENDPOINT, SEARCH_URI, args) origin_response = arrange_response(response) limit = args[:limit].to_i return origin_response if limit <= 0 origin_response["objectIDs"].lazy.map { |id| MetMuseum::Collection.new.object(id) }.first(limit) end |