imgurz 0.0.5 → 0.0.6
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/imgurz/client.rb +13 -3
- data/lib/imgurz.rb +1 -1
- data/tests/test.rb +7 -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: c03333d542173eaf1a8024475689e102f3989234
|
4
|
+
data.tar.gz: 0265d56c9077663a94801572565d8a6ca54d4240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 806dc308e8cc6c02da1104c66211429d497a26a447f33413422d284546ebbeb054a363c82830e0b0ea60b2c4874409d2f5008c40a38b218a7f50116705a4fdc6
|
7
|
+
data.tar.gz: 09fd87926402eec8b29c3813e8264c4dbafe1e4748e86147e4709d047a5b1577a4af3487d12263abcf5dbc14814bedd94ae8b78e5e4d0ff8fb24b5344f2bd8bf
|
data/lib/imgurz/client.rb
CHANGED
@@ -42,7 +42,7 @@ module Imgurz
|
|
42
42
|
|
43
43
|
def upload_image_content(file_content)
|
44
44
|
return false unless file_content.kind_of?(String)
|
45
|
-
uri = URI.parse Imgurz::
|
45
|
+
uri = URI.parse Imgurz::IMAGE_ENDPOINT
|
46
46
|
http = Net::HTTP.new(uri.host, uri.port)
|
47
47
|
http.use_ssl = true
|
48
48
|
request = Net::HTTP::Post.new uri.path
|
@@ -55,6 +55,16 @@ module Imgurz
|
|
55
55
|
response = http.request(request)
|
56
56
|
JSON.parse response.body
|
57
57
|
end
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
def delete(deletehash)
|
60
|
+
uri = URI.parse [Imgurz::IMAGE_ENDPOINT,deletehash].join('/')
|
61
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
62
|
+
http.use_ssl = true
|
63
|
+
request = Net::HTTP::Delete.new uri.path
|
64
|
+
request['Authorization'] = "Bearer #{key}" if @method=='registered'
|
65
|
+
response = http.request(request)
|
66
|
+
JSON.parse response.body
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
60
70
|
end
|
data/lib/imgurz.rb
CHANGED
data/tests/test.rb
CHANGED
@@ -11,6 +11,8 @@ YOUR_REFRESH_TOKEN = ''
|
|
11
11
|
YOUR_ALBUM_ID = nil
|
12
12
|
YOUR_TEST_IMAGE = 'tests/lama.gif'
|
13
13
|
|
14
|
+
DELETE_HASH = ''
|
15
|
+
|
14
16
|
# Upload using a path, as an anononymous user
|
15
17
|
client = Imgurz::Client.new YOUR_CLIENT_ID
|
16
18
|
puts client.anonymous.upload(YOUR_TEST_IMAGE)
|
@@ -25,4 +27,8 @@ puts client.as_regsitered.into(YOUR_ALBUM_ID).upload(YOUR_TEST_IMAGE)
|
|
25
27
|
|
26
28
|
# # Refresh token
|
27
29
|
token = Imgurz::Token.new(YOUR_CLIENT_ID, YOUR_CLIENT_SECRET)
|
28
|
-
puts token.refresh(YOUR_REFRESH_TOKEN)
|
30
|
+
puts token.refresh(YOUR_REFRESH_TOKEN)
|
31
|
+
|
32
|
+
# Delete an image as a registered user, using a deletehash
|
33
|
+
client = Imgurz::Client.new YOUR_TOKEN
|
34
|
+
puts client.as_regsitered.delete(DELETE_HASH)
|