met_museum 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +22 -1
- data/lib/met_museum/collection.rb +24 -11
- data/lib/met_museum/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef081672991028b4ccfb6741b83e27af28bba15c6a2eb95a6a888b2239483b98
|
4
|
+
data.tar.gz: 30402448c7387e0267848e2e7c197fe11796f82b0ff90a84d42460458de19d23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24fa242d38745f913aa73af7dcd44f4100cca660ddb6ddc05b7131e0aff0f9cb5ef1473245de38ea529d64e21d0414c943ca3b66909d027d3d1613059ed93f2c
|
7
|
+
data.tar.gz: 1800d1018d5a7e8f126bb140f1a52db64915a5188b0289df5648d747afaefbfa652253f6abe66118e8321b5cf4a957f885b07e43eb93c3eccae4690506a4bb91
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,7 +29,6 @@ require 'met_museum'
|
|
29
29
|
```
|
30
30
|
The description of the method is as follows
|
31
31
|
|
32
|
-
|
33
32
|
MetMuseum::Collection.objects
|
34
33
|
```
|
35
34
|
collection = MetMuseum::Collection.new()
|
@@ -44,6 +43,28 @@ collection.objects
|
|
44
43
|
820613]}
|
45
44
|
|
46
45
|
collection.objects('2018-10-10')
|
46
|
+
=>{"total"=>88232,
|
47
|
+
"objectIDs"=>
|
48
|
+
[33,
|
49
|
+
35,
|
50
|
+
36,
|
51
|
+
74,
|
52
|
+
75,
|
53
|
+
--< omit >--
|
54
|
+
820613]}
|
55
|
+
|
56
|
+
collection.objects(Date.new(2018,10,10))
|
57
|
+
=>{"total"=>88232,
|
58
|
+
"objectIDs"=>
|
59
|
+
[33,
|
60
|
+
35,
|
61
|
+
36,
|
62
|
+
74,
|
63
|
+
75,
|
64
|
+
--< omit >--
|
65
|
+
820613]}
|
66
|
+
|
67
|
+
collection.objects(DateTime.new(2018,10,10))
|
47
68
|
=>{"total"=>88232,
|
48
69
|
"objectIDs"=>
|
49
70
|
[33,
|
@@ -5,11 +5,10 @@ module MetMuseum
|
|
5
5
|
# @return [Hash<total, Integer>] The total number of publicly-available objects
|
6
6
|
# @return [Hash<objectIDs, Array<Integer>>] An array containing the object ID of publicly-available object
|
7
7
|
def objects(metadataDate = nil)
|
8
|
+
metadataDate = check_date_args(metadataDate) unless metadataDate.nil?
|
8
9
|
conn = Faraday.new(:url => API_ENDPOINT)
|
9
10
|
response = conn.get PUBLIC_URI, {:metadataDate => metadataDate}
|
10
|
-
|
11
|
-
|
12
|
-
raise error_class(response), "Code: #{response.status}, response: #{response.body}"
|
11
|
+
return_response(response)
|
13
12
|
end
|
14
13
|
|
15
14
|
# 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)
|
@@ -66,21 +65,17 @@ module MetMuseum
|
|
66
65
|
# @return [Hash<tags, Array<String>>] An array of subject keyword tags associated with the object
|
67
66
|
def object(objectID)
|
68
67
|
response = Faraday.get "#{API_ENDPOINT}#{PUBLIC_URI}/#{objectID}"
|
69
|
-
|
70
|
-
|
71
|
-
raise error_class(response), "Code: #{response.status}, response: #{response.body}"
|
68
|
+
return_response(response)
|
72
69
|
end
|
73
70
|
|
74
71
|
# returns a listing of all Object IDs for objects that contain the search query within the object’s data
|
75
72
|
# @param [String] q Returns a listing of all Object IDs for objects that contain the search query within the object’s data
|
76
73
|
# @return [Integer] total The total number of publicly-available objects
|
77
74
|
# @return [Array<Integer>] objectIDs An array containing the object ID of publicly-available object
|
78
|
-
def search(
|
75
|
+
def search(query)
|
79
76
|
conn = Faraday.new(:url => API_ENDPOINT)
|
80
|
-
response = conn.get SEARCH_URI, {:q =>
|
81
|
-
|
82
|
-
|
83
|
-
raise error_class(response), "Code: #{response.status}, response: #{response.body}"
|
77
|
+
response = conn.get SEARCH_URI, {:q => query}
|
78
|
+
return_response(response)
|
84
79
|
end
|
85
80
|
|
86
81
|
private
|
@@ -106,5 +101,23 @@ module MetMuseum
|
|
106
101
|
def response_successful?(response)
|
107
102
|
response.status == HTTP_OK_CODE
|
108
103
|
end
|
104
|
+
|
105
|
+
def check_date_args(date = nil)
|
106
|
+
case date.class.to_s
|
107
|
+
when "Date"
|
108
|
+
date = date.to_s
|
109
|
+
when "DateTime"
|
110
|
+
date = date.to_date.to_s
|
111
|
+
when "String"
|
112
|
+
date
|
113
|
+
end
|
114
|
+
date
|
115
|
+
end
|
116
|
+
|
117
|
+
def return_response(response)
|
118
|
+
return Oj.load(response.body)if response_successful?(response)
|
119
|
+
|
120
|
+
raise error_class(response), "Code: #{response.status}, response: #{response.body}"
|
121
|
+
end
|
109
122
|
end
|
110
123
|
end
|
data/lib/met_museum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: met_museum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hyuraku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|