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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e081cfb22b562214c3e2600734e643337a097bd
4
- data.tar.gz: f158b61f632a01e77a2d3c4ad541597545c270ee
3
+ metadata.gz: c03333d542173eaf1a8024475689e102f3989234
4
+ data.tar.gz: 0265d56c9077663a94801572565d8a6ca54d4240
5
5
  SHA512:
6
- metadata.gz: dcc1402a678a457fe1e8ebe2b43bb87e4d5d8c398f86fb6ff10d59b4f1b400e78ff09aee8b3577879e533652e0c63cb086a98306944452a4cf941dfef268d78b
7
- data.tar.gz: 96afce5580597df87bd5393572dd53e1ff4a218ce6c45cb7b08bed684925b174be99f38de744948ba71ebbda2e46cd4106ce4f850e77c6291be42017b777907a
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::UPLOAD_ENDPOINT
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
- end
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
@@ -2,7 +2,7 @@ IMGURZ_BASE_PATH = File.dirname(__FILE__)
2
2
 
3
3
  module Imgurz
4
4
 
5
- UPLOAD_ENDPOINT = 'https://api.imgur.com/3/image'
5
+ IMAGE_ENDPOINT = 'https://api.imgur.com/3/image'
6
6
  TOKEN_ENDPOINT = 'https://api.imgur.com/oauth2/token'
7
7
 
8
8
  end
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgurz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Zielony