Sha256: 8f504c4d8d06383ce95260672d15896458d35fd05a91bb30aacaa9c154fe4cb4
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
module Unsplash # nodoc: # Unsplash User operations. class User < Client class << self # Get a user. # @param username [String] the username of the user to retrieve. # @return [Unsplash::User] the Unsplash User. def find(username) new JSON.parse(connection.get("/users/#{username}").body) end # Get the currently-logged in user. # @return [Unsplash::User] the current user. def current new JSON.parse(connection.get("/me").body) end # Update the current user. # @param params [Hash] the hash of attributes to update. # @return [Unsplash::User] the updated user. def update_current(params) Unsplash::User.new JSON.parse(connection.put("/me", params).body) end end # Get a list of photos uploaded by the user. # @return [Array] a list of +Unsplash::Photo+ objects. def photos list = JSON.parse(connection.get("/users/#{username}/photos").body) list.map do |photo| Unsplash::Photo.new photo.to_hash end end # Get a list of photos liked by the user. # @return [Array] a list of +Unsplash::Photo+ objects. def likes list = JSON.parse(connection.get("/users/#{username}/likes").body) list.map do |photo| Unsplash::Photo.new photo.to_hash end end # Get a list of photos liked by the user. # @return [Array] a list of +Unsplash::Collection+ objects. def collections list = JSON.parse(connection.get("/users/#{username}/collections").body) list.map do |collection| Unsplash::Collection.new collection.to_hash end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unsplash-1.3.1 | lib/unsplash/user.rb |
unsplash-1.3.0 | lib/unsplash/user.rb |