feedbin 0.0.2 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzAwODFmMzhiYTAwZDFmMmM4M2I4MGIyZGVkZTlhYjAyMDA3YmY2OQ==
4
+ OWY0YWMzMGNlYjY0OTBjMDA1OTJmMzhlMGNkYzU0ZmU3Y2YyMWFiMQ==
5
5
  data.tar.gz: !binary |-
6
- NzQ2ZjYzNmQ3ZTlhMmI0OGNmOGIxY2QzM2NmZDU2NTM0YWU5MzI2Mg==
6
+ NDUzY2FmNjY1NDVhMzI1MGRlNDg5MmIxZGYzYzhlYTE5YzZlYmU2ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YmZmYmMwMjA3ZWM5ZWRiOTUzZDJkNDgzMzI2YmY4NDkwMWEwMWY0MjM5ZDI1
10
- YjRkNDdlYzI0ODBjMGQ2NGM1ZWRjYzk4NGVmNDAwMmI0NzcxMWM1MjFkOTk1
11
- NWJlMjYxNGRmZjE3MGE5OGMxMjdlYjk5NTQ3NzVhZGRmMjM5Y2U=
9
+ N2QyMzQwNTBiNTFkMTU4ZWQ3NmE2YWZkYWRiNTA2MjcyZDkyOTMzYmI4ODM5
10
+ MjM5ZTdjZjIyN2U3Y2U2MWMxYWIyNzUxMjFkMzNiYTYxZjk1NjgwNWRiYzg4
11
+ YjIyMTQ5MzA3YjJlOWEzOGRkMDRkNjIwNWMwNmE5MDc4YjhkOGE=
12
12
  data.tar.gz: !binary |-
13
- NGZiYjhjYTNiZTRjMDg2ZmFhYzY2ZjgzZmRkOTA0ZTRiMmQxYWVkMDRkNTA4
14
- YjgxZTNlNTNkNzQ5MWIyMTVlMTZiMDJjODVmMDM0Zjk4N2QxZTc4YmE0ODZl
15
- ZjIxZjNmMDNiMjEzN2M4ZDY5OTM5MzA4YjQ0ZGY1M2E5NzczZjA=
13
+ MmQ5NmI0Mzg1ZDM0Yzk3NGM4ZmRkOGU1YmE1YjNkZGYxZjA0Y2MyN2VkMTUy
14
+ YzA5OTYxMWU2YTk2MDI5MDNiOGZiNjlhNjIyM2E0M2EwNGNkMzM5MmVlZDkw
15
+ Yjc4ZWE3NjAyMjgwZmYxZWE4MTIxY2RlNzcwODM2MTQ5ZDBmYmU=
data/README.md CHANGED
@@ -27,6 +27,9 @@ Or install it yourself as:
27
27
  @feedbin.entries
28
28
  # => (array of entry hashes)
29
29
 
30
+ #feedbin.entries(read: false)
31
+ # => (an array of unread entries as hashes)
32
+
30
33
  @feedbin.unread_entries
31
34
  # => (array of unread entry IDs)
32
35
 
@@ -8,8 +8,10 @@ class FeedbinAPI
8
8
  @email, @password = email, password
9
9
  end
10
10
 
11
- def entries
12
- HTTParty.get("https://api.feedbin.me/v2/entries.json", basic_auth: { username: @email, password: @password })
11
+ # Entries
12
+
13
+ def entries(options = {})
14
+ HTTParty.get("https://api.feedbin.me/v2/entries.json", query: options, basic_auth: { username: @email, password: @password })
13
15
  end
14
16
 
15
17
  def entry(id)
@@ -20,28 +22,59 @@ class FeedbinAPI
20
22
  HTTParty.get("https://api.feedbin.me/v2/unread_entries.json", basic_auth: { username: @email, password: @password })
21
23
  end
22
24
 
25
+ def star(id)
26
+ HTTParty.post("https://api.feedbin.me/v2/starred_entries.json",
27
+ body: { 'starred_entries' => id }.to_json,
28
+ headers: { 'Content-Type' => 'application/json' },
29
+ basic_auth: { username: @email, password: @password }).code
30
+ end
31
+
32
+ def unstar(id)
33
+ HTTParty.post("https://api.feedbin.me/v2/starred_entries/delete.json",
34
+ body: { 'starred_entries' => id }.to_json,
35
+ headers: { 'Content-Type' => 'application/json' },
36
+ basic_auth: { username: @email, password: @password }).code
37
+ end
38
+
23
39
  def mark_as_read(id)
24
- HTTParty.post("https://api.feedbin.me/v2/unread_entries/delete.json",
25
- body: { 'unread_entries' => id }.to_json,
26
- headers: { 'Content-Type' => 'application/json' },
27
- basic_auth: { username: @email, password: @password })
40
+ HTTParty.post("https://api.feedbin.me/v2/unread_entries/delete.json",
41
+ body: { 'unread_entries' => id }.to_json,
42
+ headers: { 'Content-Type' => 'application/json' },
43
+ basic_auth: { username: @email, password: @password }).code
28
44
  end
29
45
 
30
46
  def mark_as_unread(id)
31
- HTTParty.post("https://api.feedbin.me/v2/unread_entries.json",
32
- body: { 'unread_entries' => id }.to_json,
33
- headers: { 'Content-Type' => 'application/json' },
34
- basic_auth: { username: @email, password: @password })
47
+ HTTParty.post("https://api.feedbin.me/v2/unread_entries.json",
48
+ body: { 'unread_entries' => id }.to_json,
49
+ headers: { 'Content-Type' => 'application/json' },
50
+ basic_auth: { username: @email, password: @password }).code
51
+ end
52
+
53
+ # Feeds
54
+
55
+ def feed(id)
56
+ HTTParty.get("https://api.feedbin.me/v2/feeds/#{id}.json", basic_auth: { username: @email, password: @password })
35
57
  end
36
58
 
59
+ # Subscriptions
60
+
37
61
  def subscribe(url)
38
62
  HTTParty.post("https://api.feedbin.me/v2/subscriptions.json",
39
63
  body: { 'feed_url' => url }.to_json,
40
64
  headers: { 'Content-Type' => 'application/json' },
41
- basic_auth: { username: @email, password: @password })
65
+ basic_auth: { username: @email, password: @password }).code
66
+ end
67
+
68
+ def unsubscribe(id)
69
+ HTTParty.delete("https://api.feedbin.me/v2/subscriptions/#{id}.json", basic_auth: { username: @email, password: @password }).code
42
70
  end
43
71
 
44
- def subscriptions
45
- HTTParty.get("https://api.feedbin.me/v2/subscriptions.json", basic_auth: { username: @email, password: @password })
72
+ def subscriptions(options = {})
73
+ if options[:since]
74
+ resp = HTTParty.get("https://api.feedbin.me/v2/subscriptions.json", query: { since: options[:since] }, basic_auth: { username: @email, password: @password })
75
+ return resp == [] ? resp : 'There have been no subscriptions since this date.'.to_json unless resp.code != 200
76
+ else
77
+ HTTParty.get("https://api.feedbin.me/v2/subscriptions.json", basic_auth: { username: @email, password: @password })
78
+ end
46
79
  end
47
- end
80
+ end
@@ -1,3 +1,3 @@
1
1
  module Feedbin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -3,20 +3,51 @@ require 'spec_helper'
3
3
  describe FeedbinAPI do
4
4
 
5
5
  before do
6
- @feedbin = FeedbinAPI.new(ENV["EMAIL"], ENV["PASSWORD"])
6
+ @feedbin = FeedbinAPI.new('email', 'password')
7
7
  end
8
8
 
9
9
  describe '.entries' do
10
- it 'should return a 200' do
11
- stub_request(:get, "https://#{ENV["EMAIL"]}:#{ENV["PASSWORD"]}@api.feedbin.me/v2/entries.json").to_return(status: 200)
10
+ it 'should get entries and return a 200' do
11
+ stub_request(:get, "https://email:password@api.feedbin.me/v2/entries.json?").to_return(status: 200)
12
12
  @feedbin.entries.code.should == 200
13
13
  end
14
+
15
+ it 'should return a 200 when parameter is passed' do
16
+ stub_request(:get, "https://email:password@api.feedbin.me/v2/entries.json?read=false").to_return(status: 200)
17
+ @feedbin.entries(read: false).code.should == 200
18
+ end
14
19
  end
15
20
 
16
21
  describe '.subscriptions' do
17
- it 'should return 201' do
18
- stub_request(:get, "https://#{ENV["EMAIL"]}:#{ENV["PASSWORD"]}@api.feedbin.me/v2/subscriptions.json").to_return(status: 200)
22
+ it 'should get subscriptions and return a 200' do
23
+ stub_request(:get, "https://email:password@api.feedbin.me/v2/subscriptions.json").to_return(status: 200)
19
24
  @feedbin.subscriptions.code.should == 200
20
25
  end
21
26
  end
27
+
28
+ describe '.unsubscribe' do
29
+ it 'should unsubscribe and return a 204' do
30
+ stub_request(:delete, "https://email:password@api.feedbin.me/v2/subscriptions/260815.json").to_return(status: 204)
31
+ @feedbin.unsubscribe(260815).should == 204
32
+ end
33
+ end
34
+
35
+ describe '.feed' do
36
+ it 'should get feed and return a 200' do
37
+ stub_request(:get, "https://email:password@api.feedbin.me/v2/feeds/1.json").to_return(status: 200)
38
+ @feedbin.feed(1).code.should == 200
39
+ end
40
+ end
41
+
42
+ describe '.star' do
43
+ it 'should star a post and return a 200' do
44
+ stub_request(:post, "https://email:password@api.feedbin.me/v2/starred_entries.json").to_return(status: 200)
45
+ @feedbin.star(33).should == 200
46
+ end
47
+
48
+ it 'should star an array of posts and return a 200' do
49
+ stub_request(:post, "https://email:password@api.feedbin.me/v2/starred_entries.json").to_return(status: 200)
50
+ @feedbin.star([33,44,55,66,77]).should == 200
51
+ end
52
+ end
22
53
  end
@@ -4,9 +4,6 @@ require 'webmock/rspec'
4
4
 
5
5
  require 'feedbin'
6
6
 
7
- ENV['EMAIL'] ||= 'email@email.com'
8
- ENV['PASSWORD'] ||= 'pa$$word'
9
-
10
7
  RSpec.configure do |c|
11
8
  c.include(WebMock::API)
12
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedbin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colby Aley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-13 00:00:00.000000000 Z
11
+ date: 2013-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler