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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08d6d07c0f9c75193191f9c558faacfb3b4c3cdf29c32b7ec9683d9aafa86480'
4
- data.tar.gz: f58005f169eceb608b22b53fbd59c8187aed3a6cb0443181761fb421f5c4c505
3
+ metadata.gz: ef081672991028b4ccfb6741b83e27af28bba15c6a2eb95a6a888b2239483b98
4
+ data.tar.gz: 30402448c7387e0267848e2e7c197fe11796f82b0ff90a84d42460458de19d23
5
5
  SHA512:
6
- metadata.gz: beefedd3fad4533944b0ae179be71c3240b394c571970166c4b8293531f6a50526dc12f58baef474c6547bc61ad21a0de59052117cb7391d8b2d7a76dfde0a49
7
- data.tar.gz: f6c9e98f847f7d17e912f89f3fbf3a368cde50fc6142dc01a5de6cdf292553104cd293e356924ce54ea2b806199c1303eb4509d7d720c57b4e8a3e9db09a2ca1
6
+ metadata.gz: 24fa242d38745f913aa73af7dcd44f4100cca660ddb6ddc05b7131e0aff0f9cb5ef1473245de38ea529d64e21d0414c943ca3b66909d027d3d1613059ed93f2c
7
+ data.tar.gz: 1800d1018d5a7e8f126bb140f1a52db64915a5188b0289df5648d747afaefbfa652253f6abe66118e8321b5cf4a957f885b07e43eb93c3eccae4690506a4bb91
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- met_museum (1.1.1)
4
+ met_museum (1.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- return Oj.load(response.body) if response_successful?(response)
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
- return Oj.load(response.body)if response_successful?(response)
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(q)
75
+ def search(query)
79
76
  conn = Faraday.new(:url => API_ENDPOINT)
80
- response = conn.get SEARCH_URI, {:q => q}
81
- return Oj.load(response.body)if response_successful?(response)
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
@@ -1,3 +1,3 @@
1
1
  module MetMuseum
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
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.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-02-18 00:00:00.000000000 Z
11
+ date: 2019-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler