nytimes-bestsellers 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/nytimes_bestsellers/client.rb +5 -5
- data/lib/nytimes_bestsellers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 432218d26fbcf904836f7e7ae5104219db6f4c83
|
4
|
+
data.tar.gz: 2c8a6db6ebd3d8768ae4b13e5a6998569b8c2b65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5864550aba3422292fe826cf19047cf65f9e377d6f7814011e6a507f951c18578d74031c829be179d9c1a18429ad461a99efd06d0acf6a8fab2543eede95bfa
|
7
|
+
data.tar.gz: 1ffcae12805299a1d75c612d8b3e60816b20b46dcf17dd21ea4aa4d1f764a904f1ec266f8c275bcc5ea459fe0a501bafaa16861ddf0207aad86c6b6ea71f635e
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# New York Times Bestsellers
|
4
4
|
|
5
|
-
A Ruby gem for accessing the [New York Times
|
5
|
+
A Ruby gem for accessing the [New York Times Best Sellers API](http://developer.nytimes.com/docs/best_sellers_api) that gathers data from the [Best Sellers List](http://www.nytimes.com/best-sellers-books/).
|
6
6
|
|
7
7
|
## Install
|
8
8
|
|
@@ -31,7 +31,7 @@ Setup a new instance:
|
|
31
31
|
end
|
32
32
|
```
|
33
33
|
|
34
|
-
|
34
|
+
Heads up! If you're not using Rails, note that when requiring the gem in your files you'll need to use `require nytimes_bestsellers` with the underscore rather than a dash.
|
35
35
|
|
36
36
|
## Methods
|
37
37
|
|
@@ -39,17 +39,17 @@ Six requests are available: get a bestseller list, get an overview of all of the
|
|
39
39
|
|
40
40
|
### get_list(list_name, o = {})
|
41
41
|
|
42
|
-
This method has a required parameter of list name(see lists below or call the find_list_names method to find them for yourself) and takes
|
42
|
+
This method has a required parameter of list name(see lists below or call the find_list_names method to find them for yourself) and takes optional parameters of date(as a string in YYYY-MM-DD format), offset, sort_by, and sort_order.
|
43
43
|
|
44
44
|
with no optional parameters it gets the most recent list
|
45
45
|
`@client.get_list('hardcover-nonfiction')`
|
46
46
|
|
47
47
|
it can take optional parameters
|
48
|
-
`@client.get_list('hardcover-nonfiction', date: '2012-04-12',
|
48
|
+
`@client.get_list('hardcover-nonfiction', date: '2012-04-12', offset: 20)`
|
49
49
|
|
50
50
|
### bestseller_lists_overview()
|
51
51
|
|
52
|
-
Returns an overview of Times best-seller lists for a single week. Takes an optional parameter of date in YYYY-MM-DD format. If you do not specify a
|
52
|
+
Returns an overview of Times best-seller lists for a single week. Takes an optional parameter of date in YYYY-MM-DD format. If you do not specify a date the most recent week's best-seller list will be returned.
|
53
53
|
|
54
54
|
`@client.bestseller_lists_overview`
|
55
55
|
`@client.bestseller_lists_overview(date: '2012-04-12')`
|
@@ -57,13 +57,13 @@ Returns an overview of Times best-seller lists for a single week. Takes an optio
|
|
57
57
|
|
58
58
|
### search_list(list_name, o = {})
|
59
59
|
|
60
|
-
Allows for a filtered search of a specific list. Optional parameters are date, isbn, published_date, rank, rank_last_week, and weeks_on_list.
|
60
|
+
Allows for a filtered search of a specific list. Optional parameters are date, isbn, published_date, rank, rank_last_week, and weeks_on_list. Has additional parameters of offset, sort_by, and sort_order.
|
61
61
|
|
62
62
|
`@client.search_list('hardcover-nonfiction', published_date: "2013-04-12")`
|
63
63
|
|
64
64
|
### single_history()
|
65
65
|
|
66
|
-
Returns up to 20 weeks of history for a bestseller (its rank and number of weeks on the various Times best-seller lists). Takes one or more of the following parameters:
|
66
|
+
Returns up to 20 weeks of history for a bestseller (its rank and number of weeks on the various Times best-seller lists). Takes one or more of the following parameters: author, contributor, isbn, price, publisher, title, age_group(see below for age group options). Has additional parameters of sort_by and sort_order.
|
67
67
|
|
68
68
|
`@client.single_history(author: 'rachel maddow')`
|
69
69
|
|
@@ -18,7 +18,7 @@ module Bestsellers
|
|
18
18
|
|
19
19
|
def set_urlparam(url, name, options)
|
20
20
|
return unless options[name]
|
21
|
-
url << "&#{name.to_s.gsub('_','-')}=#{options[name]}"
|
21
|
+
url << "&#{name.to_s.gsub('_','-')}=#{options[name].gsub(/ /, '-')}"
|
22
22
|
end
|
23
23
|
|
24
24
|
def get_list(list_name, o = {})
|
@@ -29,7 +29,7 @@ module Bestsellers
|
|
29
29
|
url << "/#{date}"
|
30
30
|
end
|
31
31
|
|
32
|
-
url << "/#{list_name}?"
|
32
|
+
url << "/#{list_name.gsub(/ /, '-')}?"
|
33
33
|
|
34
34
|
[:offset, :sort_by, :sort_order].each do |thing|
|
35
35
|
set_urlparam(url, thing, o)
|
@@ -42,7 +42,7 @@ module Bestsellers
|
|
42
42
|
|
43
43
|
def search_list(list_name, o = {})
|
44
44
|
|
45
|
-
url = BOOKS_URL.clone + "?list-name=#{list_name}"
|
45
|
+
url = BOOKS_URL.clone + "?list-name=#{list_name.gsub(/ /, '-')}"
|
46
46
|
|
47
47
|
date = if o[:date]
|
48
48
|
Date.parse(o[:date])
|
@@ -51,7 +51,7 @@ module Bestsellers
|
|
51
51
|
end.strftime('%Y-%m-%e')
|
52
52
|
url << "&date=#{date}"
|
53
53
|
|
54
|
-
[:isbn, :published_date, :rank, :rank_last_week, :weeks_on_list].each do |thing|
|
54
|
+
[:isbn, :published_date, :rank, :rank_last_week, :weeks_on_list, :offset, :sort_by, :sort_order].each do |thing|
|
55
55
|
set_urlparam(url, thing, o)
|
56
56
|
end
|
57
57
|
|
@@ -72,7 +72,7 @@ module Bestsellers
|
|
72
72
|
|
73
73
|
url << "?"
|
74
74
|
|
75
|
-
[:author, :publisher, :title, :age_group, :contributor, :isbn, :price].each do |thing|
|
75
|
+
[:author, :publisher, :title, :age_group, :contributor, :isbn, :price, :sort_by, :sort_order].each do |thing|
|
76
76
|
set_urlparam(url, thing, o)
|
77
77
|
end
|
78
78
|
|