rushover 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ 0.3.0 (February 19, 2013)
2
+ * Add receipt endpoint handling for checking alerts requiring acknowledgement
data/README.md CHANGED
@@ -26,6 +26,13 @@ client = Rushover::Client.new(your_app_token)
26
26
  resp = client.notify(user_key, "some message", :priority => 1, :title => "a title!")
27
27
  resp.ok? # => true
28
28
 
29
+ # You can also send emergency priority 2 messages
30
+ # Note you must provide expire and retry options for this to succeed
31
+ client.notify(user_key, "some message", :priority => 2, :expire => 180, :retry => 60)
32
+
33
+ # Check a receipt
34
+ client.reciept("S2sXbSL2IKfl6caouD8hJXVn4SoD36")
35
+
29
36
  # Validate that a user exists
30
37
  client.validate!(existing_user_key) # => true
31
38
  client.validate!(existing_user_key, existing_device) # => true
@@ -7,6 +7,7 @@ module Rushover
7
7
  BASE_URL = "https://api.pushover.net/1".freeze
8
8
  MESSAGES_ENDPOINT = "#{BASE_URL}/messages.json".freeze
9
9
  VALIDATE_ENDPOINT = "#{BASE_URL}/users/validate.json".freeze
10
+ RECEIPT_ENDPOINT = "#{BASE_URL}/receipts/%s.json".freeze
10
11
 
11
12
  attr_accessor :token
12
13
 
@@ -30,17 +31,35 @@ module Rushover
30
31
  validate(user_key, device).ok?
31
32
  end
32
33
 
34
+ def receipt(id)
35
+ data = { :token => token }
36
+ url = RECEIPT_ENDPOINT % id
37
+ get_json(url, data)
38
+ end
39
+
33
40
  private
34
41
 
35
- def post_json(url, data)
42
+ def parse_response
36
43
  raw_response = begin
37
- RestClient.post url, data
44
+ yield
38
45
  rescue RestClient::Exception => e
39
46
  e.response
40
47
  end
41
48
 
42
49
  Response.new JSON.parse(raw_response)
43
50
  end
51
+
52
+ def get_json(url, data)
53
+ parse_response do
54
+ RestClient.get url, { :params => data }
55
+ end
56
+ end
57
+
58
+ def post_json(url, data)
59
+ parse_response do
60
+ RestClient.post url, data
61
+ end
62
+ end
44
63
  end
45
64
 
46
65
  class User
@@ -1,3 +1,3 @@
1
1
  module Rushover
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -57,6 +57,24 @@ class RushoverClientTest < RushoverTest
57
57
  end
58
58
  end
59
59
 
60
+ context "looking up receipt data" do
61
+ test "when the receipt exists" do
62
+ FakeWeb.register_uri(:get, "https://api.pushover.net/1/receipts/123asdf.json?token=test_api_token",
63
+ :body => {"status"=>1, "acknowledged"=>1, "acknowledged_at"=>1361314981,
64
+ "last_delivered_at"=>1361314753, "expired"=>1,
65
+ "expires_at"=>1361314783, "called_back"=>0,
66
+ "called_back_at"=>0,
67
+ "request"=>"9a38ad590235bc07ea7ae2b5fd83f99f"}.to_json,
68
+ :content_type => "application/json")
69
+
70
+ resp = client.receipt("123asdf")
71
+ assert_equal 1, resp[:expired]
72
+ assert_equal 1, resp[:acknowledged]
73
+ assert_equal 1361314981, resp[:acknowledged_at]
74
+ assert_equal "9a38ad590235bc07ea7ae2b5fd83f99f", resp[:request]
75
+ end
76
+ end
77
+
60
78
  context "user validation" do
61
79
  test "determining a user exists" do
62
80
  FakeWeb.register_uri(:post, "https://api.pushover.net/1/users/validate.json",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rushover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-06 00:00:00.000000000 Z
12
+ date: 2013-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &2161834960 !ruby/object:Gem::Requirement
16
+ requirement: &2156352600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2161834960
24
+ version_requirements: *2156352600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &2161834540 !ruby/object:Gem::Requirement
27
+ requirement: &2156352180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2161834540
35
+ version_requirements: *2156352180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2161834120 !ruby/object:Gem::Requirement
38
+ requirement: &2156351760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2161834120
46
+ version_requirements: *2156351760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: contest
49
- requirement: &2161833700 !ruby/object:Gem::Requirement
49
+ requirement: &2156351340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2161833700
57
+ version_requirements: *2156351340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: fakeweb
60
- requirement: &2161833280 !ruby/object:Gem::Requirement
60
+ requirement: &2156350920 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2161833280
68
+ version_requirements: *2156350920
69
69
  description: A simple ruby Pushover client
70
70
  email:
71
71
  - xternal1+github@gmail.com
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - .gitignore
77
+ - CHANGELOG.md
77
78
  - Gemfile
78
79
  - LICENSE
79
80
  - README.md
@@ -99,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
100
  version: '0'
100
101
  segments:
101
102
  - 0
102
- hash: -2604947186383905221
103
+ hash: 539245759226172416
103
104
  required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  none: false
105
106
  requirements:
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  version: '0'
109
110
  segments:
110
111
  - 0
111
- hash: -2604947186383905221
112
+ hash: 539245759226172416
112
113
  requirements: []
113
114
  rubyforge_project:
114
115
  rubygems_version: 1.8.15