unsplash 1.1.0 → 1.2.0

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
  SHA1:
3
- metadata.gz: 225c7f132cc0a217b99815db374ffc07623930cb
4
- data.tar.gz: bf58f236014eff003ba68afc41889856d7dbc866
3
+ metadata.gz: a9d24b19deadf36bcfaff6bef4ce2be59cfca562
4
+ data.tar.gz: d539fcc855d59becbc8596fc55d638625ab3ba6e
5
5
  SHA512:
6
- metadata.gz: ecd2faeada759be7f8413f5e27c6b6b6c69790b675de3f59846bce26d291cbb2514e3cf58104850564f4bbb1da32f05267309a0d19110e2d14cead608b27620f
7
- data.tar.gz: 91ebafb974c916f86f96dbc4e105c4e06bb713dc62176b28f865433cb4f46a11452ee3f38462d0f1158d79d8b72fda72098341231779650bb952d5a666636fdb
6
+ metadata.gz: 0ae19462d1ee0461d1a9720c2341080acedd823e0a17a015521164dc029f774cb4886648ff1ea7551ca9e433fd0c36a3e66f70da2341ee1a9022ab9ad1d5cc77
7
+ data.tar.gz: 0c37e257be23c7e9178e375acf26e3579355e079e32f3f837668ad504ce6ac977eb981a2f869945247e6238bdabeba7c7d49cb546e6569292bbf4a0c5e29e462
@@ -70,10 +70,17 @@ module Unsplash #:nodoc:
70
70
  request :post, path, params
71
71
  end
72
72
 
73
+ # Perform a DELETE request.
74
+ # @param path [String] The path at which to make ther request.
75
+ # @param params [Hash] A hash of request parameters.
76
+ def delete(path, params = {})
77
+ request :delete, path, params
78
+ end
79
+
73
80
  private
74
81
 
75
82
  def request(verb, path, params = {})
76
- raise ArgumentError.new "Invalid http verb #{verb}" if ![:get, :post, :put].include?(verb)
83
+ raise ArgumentError.new "Invalid http verb #{verb}" if ![:get, :post, :put, :delete].include?(verb)
77
84
 
78
85
  headers = {
79
86
  "Accept-Version" => @api_version
@@ -3,6 +3,20 @@ module Unsplash # :nodoc:
3
3
  # Unsplash Photo operations.
4
4
  class Photo < Client
5
5
 
6
+ # Like a photo for the current user.
7
+ # @return [Boolean] True if successful. Will raise on error.
8
+ def like!
9
+ connection.post("/photos/#{id}/like")
10
+ true
11
+ end
12
+
13
+ # Unlike a photo for the current user.
14
+ # @return [Boolean] True if successful. Will raise on error.
15
+ def unlike!
16
+ connection.delete("/photos/#{id}/like")
17
+ true
18
+ end
19
+
6
20
  class << self
7
21
 
8
22
  # Get a photo. Can be cropped or resized using the optional parameters.
data/lib/unsplash/user.rb CHANGED
@@ -36,6 +36,14 @@ module Unsplash # nodoc:
36
36
  end
37
37
  end
38
38
 
39
+ # Get a list of photos liked by the user.
40
+ # @return [Array] a list of +Unsplash::Photo+ objects.
41
+ def likes
42
+ list = JSON.parse(connection.get("/users/#{username}/likes").body)
43
+ list.map do |photo|
44
+ Unsplash::Photo.new photo.to_hash
45
+ end
46
+ end
39
47
  end
40
48
 
41
49
  end
@@ -1,4 +1,4 @@
1
1
  module Unsplash # :nodoc:
2
2
  # :nodoc:
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unsplash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Klaassen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-17 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty