Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per page param #36

Merged
merged 3 commits into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/unsplash/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def find(id, curated = false)

# Get a list of all collections.
# @param page [Integer] Which page of search results to return.
# @param per_page [Integer] The number of search results per page.
# @param per_page [Integer] The number of search results per page. (default: 10, maximum: 30)
# @return [Array] A single page of the +Unsplash::Collection+ list.
def all(page = 1, per_page = 10)
params = {
Expand All @@ -28,7 +28,7 @@ def all(page = 1, per_page = 10)

# Get a list of all curated collections.
# @param page [Integer] Which page of search results to return.
# @param per_page [Integer] The number of search results per page.
# @param per_page [Integer] The number of search results per page. (default: 10, maximum: 30)
# @return [Array] A single page of the +Unsplash::Collection+ list.
def curated(page = 1, per_page = 10)
params = {
Expand All @@ -55,11 +55,13 @@ def create(title: "", description: "", private: false)
# Get a single page of collection results for a query.
# @param query [String] Keywords to search for.
# @param page [Integer] Which page of search results to return.
# @param per_page [Integer] The number of collections search result per page. (default: 10, maximum: 30)
# @return [Array] a list of +Unsplash::Collection+ objects.
def search(query, page = 1)
def search(query, page = 1, per_page = 10)
params = {
query: query,
page: page
page: page,
per_page: per_page
}
Unsplash::Search.search("/search/collections", self, params)
end
Expand Down Expand Up @@ -96,6 +98,8 @@ def destroy
end

# Get a list of the photos contained in this collection.
# @param page [Integer] Which page of photos collection to return.
# @param per_page [Integer] The number of photos per page. (default: 10, maximum: 30)
# @return [Array] The list of +Unsplash::Photo+s in the collection.
def photos(page = 1, per_page = 10)
params = {
Expand Down
13 changes: 8 additions & 5 deletions lib/unsplash/photo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def random(count: nil,categories: nil, collections: nil, featured: nil, user: ni
if count
params[:count] = count
photos = parse_list connection.get("/photos/random/", params).body
photos.map { |photo|
photos.map { |photo|
photo.user = Unsplash::User.new photo[:user]
photo
}
Expand All @@ -76,17 +76,20 @@ def random(count: nil,categories: nil, collections: nil, featured: nil, user: ni
# Search for photos by keyword.
# @param query [String] Keywords to search for.
# @param page [Integer] Which page of search results to return.
def search(query, page = 1)
# @param per_page [Integer] The number of users search result per page. (default: 10, maximum: 30)
# @return [Array] a list of +Unsplash::Photo+ objects.
def search(query, page = 1, per_page = 10)
params = {
query: query,
page: page
page: page,
per_page: per_page
}
Unsplash::Search.search("/search/photos", self, params)
end

# Get a list of all photos.
# @param page [Integer] Which page of search results to return.
# @param per_page [Integer] The number of search results per page.
# @param per_page [Integer] The number of search results per page. (default: 10, maximum: 30)
# @return [Array] A single page of +Unsplash::Photo+ search results.
def all(page = 1, per_page = 10)
params = {
Expand All @@ -98,7 +101,7 @@ def all(page = 1, per_page = 10)

# Get a single page from the list of the curated photos (front-page’s photos).
# @param page [Integer] Which page of search results to return.
# @param per_page [Integer] The number of search results per page.
# @param per_page [Integer] The number of search results per page. (default: 10, maximum: 30)
# @param order_by [String] How to sort the photos.
# @return [Array] A single page of +Unsplash::Photo+ search results.
def curated(page = 1, per_page = 10, order_by = "popular")
Expand Down
11 changes: 6 additions & 5 deletions lib/unsplash/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ def update_current(params)
# Get a single page of user results for a query.
# @param query [String] Keywords to search for.
# @param page [Integer] Which page of search results to return.
# @param per_page [Integer] The number of users search result per page. (default: 10, maximum: 30)
# @return [Array] a list of +Unsplash::User+ objects.
def search(query, page = 1)
def search(query, page = 1, per_page = 10)
params = {
query: query,
page: page
page: page,
per_page: per_page
}
Unsplash::Search.search("/search/users", self, params)
end
Expand All @@ -57,7 +59,7 @@ def photos(page = 1, per_page = 10)

# Get a list of photos liked by the user.
# @param page [Integer] Which page of results to return.
# @param per_page [Integer] The number of results per page.
# @param per_page [Integer] The number of results per page. (default: 10, maximum: 30)
# @return [Array] a list of +Unsplash::Photo+ objects.
def likes(page = 1, per_page = 10)
params = {
Expand All @@ -73,7 +75,7 @@ def likes(page = 1, per_page = 10)

# Get a list of collections created by the user.
# @param page [Integer] Which page of results to return.
# @param per_page [Integer] The number of results per page.
# @param per_page [Integer] The number of results per page. (default: 10, maximum: 30)
# @return [Array] a list of +Unsplash::Collection+ objects.
def collections(page = 1, per_page = 10)
params = {
Expand All @@ -88,5 +90,4 @@ def collections(page = 1, per_page = 10)
end

end

end
58 changes: 56 additions & 2 deletions spec/cassettes/collections.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading