discogs-wrapper 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +21 -1
  3. data/lib/wrapper/wrapper.rb +16 -7
  4. metadata +37 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4654ad8d85f69444831ce09b6c2960ba2e598fed
4
- data.tar.gz: fa37e9987c31c5763df41d822c0b3c08929b29e6
3
+ metadata.gz: 91031cf38db39dcbff5554e7640a13be2e4d5e63
4
+ data.tar.gz: 21a92fbc0118bbac04c4dbf101dc0e2763d1ec94
5
5
  SHA512:
6
- metadata.gz: 9b54ec185f2dcf2415721a7b88008f5a8a1c20860e8af6e456614ccb246855618cea55ca332744266bd14ccdb96cdd4c7aa5eadf9204d4c41bb8f8c979c12215
7
- data.tar.gz: b1d6c9e76a7f988429386fae10ae74ee7c8140555058c2c0c9c5beee4c734fbfff42dd03425cbb2493da7506e2c09bfa7f9816381ec297777f2bc273f34b3abe
6
+ metadata.gz: 27b9662b5746ec7f045adaf9d669b9dd948dd3d1c18eed9ef7e78e9e9dbecd0c9b5bed58df5f1706ab9974b31b551c1f073f20b74f275d12e867c6971d32641e
7
+ data.tar.gz: 73b068fbff4032a6543e1031aa3e2c000281de36548c9dc6e976dd2475c540f8738b09ed9f537390ae2039a0e8c2accf289c8ab7e91131992e77e74cb8e9b633
@@ -29,9 +29,12 @@ ABOUT
29
29
  * Pagination / Sorting
30
30
 
31
31
 
32
+ DOCUMENTATION
33
+ ------------
34
+ You can read the documentation at [this projects RDoc page](http://rdoc.info/github/buntine/discogs/master/frames).
35
+
32
36
  The Discogs API is [documented here](http://www.discogs.com/developers/index.html).
33
37
 
34
- You can see all implemented methods on [this projects RDoc page](http://rdoc.info/github/buntine/discogs/master/frames).
35
38
 
36
39
  INSTALLATION
37
40
  ------------
@@ -43,6 +46,7 @@ INSTALLATION
43
46
 
44
47
  gem "discogs-wrapper"
45
48
 
49
+
46
50
  USAGE
47
51
  -----
48
52
  To use this library, you must supply the name of your application. For example:
@@ -96,6 +100,19 @@ search.results.first.id # => 691078
96
100
 
97
101
  You can see all implemented methods on [this projects RDoc page](http://rdoc.info/github/buntine/discogs/master/frames).
98
102
 
103
+
104
+ SANITIZATION
105
+ ------------
106
+ The Discogs.com API uses the name "count" in several places, which is sanitized to "total" in this gem in order to prevent overriding the `count` attribute of `Hash`.
107
+
108
+ For example:
109
+
110
+ ```ruby
111
+ release.rating.count # => Returns number of keys in "rating" Hash.
112
+ release.rating.total # => Returns total number of ratings as per Discogs API response.
113
+ ```
114
+
115
+
99
116
  AUTHENTICATION
100
117
  --------------
101
118
  Many of the API endpoints require the user to be authenticated via oAuth. The library provides support for this.
@@ -145,6 +162,7 @@ def another_action
145
162
  end
146
163
  ```
147
164
 
165
+
148
166
  PAGINATION
149
167
  ----------
150
168
  All API endpoints that accept pagination, sorting or other parameters are supported.
@@ -161,10 +179,12 @@ wrapper.get_artist_releases(345211, :page => 2, :per_page => 10)
161
179
  wrapper.get_user_inventory("username", :page => 3, :sort => "price", :sort_order => "asc")
162
180
  ```
163
181
 
182
+
164
183
  LICENSE
165
184
  -----
166
185
  See the LICENCE file. Copyright (c) Andrew Buntine
167
186
 
187
+
168
188
  CONTRIBUTORS
169
189
  ------------
170
190
  [Thank you for the support](https://github.com/buntine/discogs/graphs/contributors)
@@ -746,7 +746,7 @@ class Discogs::Wrapper
746
746
  raise_unknown_resource(path) if response.code == "404"
747
747
  raise_authentication_error(path) if response.code == "401"
748
748
  raise_internal_server_error if response.code == "500"
749
-
749
+
750
750
  # Unzip the response data, or just read it in directly
751
751
  # if the API responds without gzipping.
752
752
  response_body = nil
@@ -764,21 +764,30 @@ class Discogs::Wrapper
764
764
  def make_request(path, params, method, body)
765
765
  full_params = params.merge(auth_params)
766
766
  uri = build_uri(path, full_params)
767
- formatted = "#{uri.path}?#{uri.query}"
767
+ formatted = "#{uri.path}?#{uri.query}"
768
768
  output_format = full_params.fetch(:f, "json")
769
769
  headers = {"Accept" => "application/#{output_format}",
770
770
  "Accept-Encoding" => "gzip,deflate",
771
771
  "User-Agent" => @app_name}
772
772
 
773
- if authenticated? and user_facing?
773
+ if any_authentication?
774
774
  if [:post, :put].include?(method)
775
- headers["Content-Type"] = "application/json"
776
- @access_token.send(method, formatted, JSON(body), headers)
775
+ headers["Content-Type"] = headers["Accept"]
776
+
777
+ if user_facing?
778
+ @access_token.send(method, formatted, JSON(body), headers)
779
+ else
780
+ HTTParty.send(method, uri, {headers: headers, body: JSON(body)})
781
+ end
777
782
  else
778
- @access_token.send(method, formatted, headers)
783
+ if user_facing?
784
+ @access_token.send(method, formatted, headers)
785
+ else
786
+ HTTParty.send(method, uri, headers: headers)
787
+ end
779
788
  end
780
789
  else
781
- # All non-authenticated endpoints are GET.
790
+ # All non-authenticated endpoints are GET.
782
791
  HTTParty.get(uri, headers: headers)
783
792
  end
784
793
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discogs-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Buntine
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-10 00:00:00.000000000 Z
12
+ date: 2017-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
@@ -176,56 +176,56 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.4.8
179
+ rubygems_version: 2.6.12
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Discogs::Wrapper is a full wrapper for the http://www.discogs.com API V2
183
183
  test_files:
184
- - spec/wrapper_spec.rb
185
- - spec/wrapper_methods/get_order_messages_spec.rb
186
- - spec/wrapper_methods/edit_user_spec.rb
184
+ - spec/spec_helper.rb
187
185
  - spec/wrapper_methods/get_identity_spec.rb
188
- - spec/wrapper_methods/get_user_wantlist_spec.rb
186
+ - spec/wrapper_methods/get_master_release_versions_spec.rb
189
187
  - spec/wrapper_methods/search_spec.rb
190
- - spec/wrapper_methods/get_order_spec.rb
191
- - spec/wrapper_methods/get_artist_spec.rb
192
- - spec/wrapper_methods/get_release_spec.rb
193
188
  - spec/wrapper_methods/get_user_folders_spec.rb
194
- - spec/wrapper_methods/get_master_release_spec.rb
195
- - spec/wrapper_methods/add_release_to_user_wantlist_spec.rb
196
- - spec/wrapper_methods/get_user_spec.rb
197
- - spec/wrapper_methods/get_master_release_versions_spec.rb
198
- - spec/wrapper_methods/get_price_suggestions_spec.rb
199
189
  - spec/wrapper_methods/get_user_inventory_spec.rb
200
190
  - spec/wrapper_methods/get_listing_spec.rb
201
- - spec/wrapper_methods/get_label_releases_spec.rb
191
+ - spec/wrapper_methods/get_user_folder_spec.rb
192
+ - spec/wrapper_methods/get_artist_spec.rb
193
+ - spec/wrapper_methods/get_user_spec.rb
194
+ - spec/wrapper_methods/edit_user_spec.rb
195
+ - spec/wrapper_methods/get_master_release_spec.rb
202
196
  - spec/wrapper_methods/edit_release_in_user_wantlist_spec.rb
203
- - spec/wrapper_methods/get_user_collection_spec.rb
204
- - spec/wrapper_methods/get_label_spec.rb
205
197
  - spec/wrapper_methods/get_artist_releases_spec.rb
206
- - spec/wrapper_methods/get_user_folder_spec.rb
207
- - spec/spec_helper.rb
198
+ - spec/wrapper_methods/get_order_spec.rb
199
+ - spec/wrapper_methods/get_label_spec.rb
200
+ - spec/wrapper_methods/get_user_wantlist_spec.rb
201
+ - spec/wrapper_methods/get_label_releases_spec.rb
202
+ - spec/wrapper_methods/add_release_to_user_wantlist_spec.rb
203
+ - spec/wrapper_methods/get_release_spec.rb
204
+ - spec/wrapper_methods/get_order_messages_spec.rb
205
+ - spec/wrapper_methods/get_user_collection_spec.rb
206
+ - spec/wrapper_methods/get_price_suggestions_spec.rb
207
+ - spec/samples/valid_user_profile.json
208
+ - spec/samples/valid_user_wantlist.json
209
+ - spec/samples/valid_master_release.json
208
210
  - spec/samples/valid_artist_releases.json
209
- - spec/samples/valid_master_release_versions.json
210
- - spec/samples/valid_user.json
211
+ - spec/samples/valid_artist.json
212
+ - spec/samples/valid_label.json
213
+ - spec/samples/valid_user_folder.json
211
214
  - spec/samples/valid_user_collection.json
212
- - spec/samples/valid_identity.json
213
- - spec/samples/valid_folder.json
214
- - spec/samples/valid_user_wantlist.json
215
- - spec/samples/valid_release.json
216
- - spec/samples/valid_search_results.json
217
- - spec/samples/valid_order.json
218
215
  - spec/samples/valid_wantlist_release.json
216
+ - spec/samples/valid_fields.json
219
217
  - spec/samples/valid_order_messages.json
218
+ - spec/samples/valid_user_inventory.json
220
219
  - spec/samples/valid_orders.json
220
+ - spec/samples/valid_listing.json
221
+ - spec/samples/valid_release.json
222
+ - spec/samples/valid_user_folders.json
223
+ - spec/samples/valid_master_release_versions.json
221
224
  - spec/samples/valid_price_suggestions.json
222
- - spec/samples/valid_artist.json
223
- - spec/samples/valid_label.json
224
- - spec/samples/valid_user_folder.json
225
+ - spec/samples/valid_order.json
226
+ - spec/samples/valid_user.json
227
+ - spec/samples/valid_search_results.json
228
+ - spec/samples/valid_folder.json
229
+ - spec/samples/valid_identity.json
225
230
  - spec/samples/valid_label_releases.json
226
- - spec/samples/valid_user_profile.json
227
- - spec/samples/valid_master_release.json
228
- - spec/samples/valid_user_folders.json
229
- - spec/samples/valid_user_inventory.json
230
- - spec/samples/valid_fields.json
231
- - spec/samples/valid_listing.json
231
+ - spec/wrapper_spec.rb