unsplash 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/unsplash/connection.rb +8 -1
- data/lib/unsplash/photo.rb +14 -0
- data/lib/unsplash/user.rb +8 -0
- data/lib/unsplash/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9d24b19deadf36bcfaff6bef4ce2be59cfca562
|
4
|
+
data.tar.gz: d539fcc855d59becbc8596fc55d638625ab3ba6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ae19462d1ee0461d1a9720c2341080acedd823e0a17a015521164dc029f774cb4886648ff1ea7551ca9e433fd0c36a3e66f70da2341ee1a9022ab9ad1d5cc77
|
7
|
+
data.tar.gz: 0c37e257be23c7e9178e375acf26e3579355e079e32f3f837668ad504ce6ac977eb981a2f869945247e6238bdabeba7c7d49cb546e6569292bbf4a0c5e29e462
|
data/lib/unsplash/connection.rb
CHANGED
@@ -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
|
data/lib/unsplash/photo.rb
CHANGED
@@ -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
|
data/lib/unsplash/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|