boxcar_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Boxcar
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ Manifest
3
+ README.rdoc
4
+ Rakefile
5
+ examples/send_as_provider.rb
6
+ examples/send_to_yourself.rb
7
+ init.rb
8
+ lib/boxcar_api.rb
data/README.rdoc ADDED
@@ -0,0 +1,12 @@
1
+ = Boxcar API
2
+
3
+ The Boxcar API gem allows Ruby developers to programmatically deliver notifications either to themselves, or as a provider.
4
+
5
+ To send yourself notifications, visit http://boxcar.io/help/api/users
6
+
7
+ To send other people notifications, visit http://boxcar.io/help/api/providers
8
+
9
+
10
+ == Copyright
11
+
12
+ Copyright (c) 2010 Boxcar. MIT Licensed.
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('boxcar_api', '1.0.0') do |p|
6
+ p.description = "A simple way to send notifications to yourself, or your users through Boxcar."
7
+ p.url = "http://github.com/boxcar/boxcar_api"
8
+ p.author = "Jonathan George"
9
+ p.email = "help@boxcar.io"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = ["httparty"]
12
+ p.runtime_dependencies = ["httparty"]
13
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{boxcar_api}
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Jonathan George"]
9
+ s.cert_chain = ["/Users/jonathan/.ssh/gem-public_cert.pem"]
10
+ s.date = %q{2010-04-13}
11
+ s.description = %q{A simple way to send notifications to yourself, or your users through Boxcar.}
12
+ s.email = %q{help@boxcar.io}
13
+ s.extra_rdoc_files = ["LICENSE", "README.rdoc", "lib/boxcar_api.rb"]
14
+ s.files = ["LICENSE", "Manifest", "README.rdoc", "Rakefile", "examples/send_as_provider.rb", "examples/send_to_yourself.rb", "init.rb", "lib/boxcar_api.rb", "boxcar_api.gemspec"]
15
+ s.homepage = %q{http://github.com/boxcar/boxcar_api}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxcar_api", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{boxcar_api}
19
+ s.rubygems_version = %q{1.3.5}
20
+ s.signing_key = %q{/Users/jonathan/.ssh/gem-private_key.pem}
21
+ s.summary = %q{A simple way to send notifications to yourself, or your users through Boxcar.}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
29
+ s.add_development_dependency(%q<httparty>, [">= 0"])
30
+ else
31
+ s.add_dependency(%q<httparty>, [">= 0"])
32
+ s.add_dependency(%q<httparty>, [">= 0"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<httparty>, [">= 0"])
36
+ s.add_dependency(%q<httparty>, [">= 0"])
37
+ end
38
+ end
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ require 'boxcar_api'
3
+
4
+ provider_key = 'xyz'
5
+ provider_secret = 'xyz'
6
+
7
+ bp = Provider.new(provider_key, provider_secret)
8
+
9
+ #### Send an invitation to a user by their e-mail address, to add your service.
10
+ res = bp.subscribe('user@example.com')
11
+
12
+ if res.code == 200
13
+ puts "Success! You sent an invitation to user@example.com to add your service."
14
+ else
15
+ puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
16
+ end
17
+
18
+ #### Deliver a broadcast notification to everyone that has added your service.
19
+ res = bp.broadcast("This is an example message.", "from")
20
+
21
+ if res.code == 200
22
+ puts "Success! You sent a broadcast message to everyone using your service."
23
+ else
24
+ puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
25
+ end
26
+
27
+ #### Deliver a personalized notification to a subscriber by email.
28
+ res = bp.broadcast("user@example.com", "This is an example message.", "from")
29
+
30
+ if res.code == 200
31
+ puts "Success! You sent a broadcast message to everyone using your service."
32
+ else
33
+ puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
34
+ end
35
+
36
+ #### Deliver a personalized notification to a subscriber by their service token/secret.
37
+ res = bp.broadcast(token, secret, "This is an example message.", "from")
38
+
39
+ if res.code == 200
40
+ puts "Success! You sent a broadcast message to everyone using your service."
41
+ else
42
+ puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
43
+ end
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'boxcar_api'
3
+
4
+ email = 'your email'
5
+ password = 'your password'
6
+
7
+ bu = BoxcarAPI::User.new(email, password)
8
+ res = bu.notify("message")
9
+
10
+ if res.code == 200
11
+ puts "Success!"
12
+ else
13
+ puts "There was a problem delivering the notification, HTTP status code: #{res.code}"
14
+ end
15
+
16
+ # This time include a 'from screen name' - e.g., an application name, or a person.
17
+ res = bu.notify("message", "from")
18
+
19
+ # This time include a unique identifier, and if you send it more than once
20
+ # additional notifications will be dropped as duplicates.
21
+ res = bu.notify("message", "from", "unique")
22
+
23
+ # This one won't be delivered, because you've already gotten it.
24
+ res = bu.notify("message", "from", "unique")
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), "lib", "boxcar_api")
data/lib/boxcar_api.rb ADDED
@@ -0,0 +1,91 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'digest/md5'
4
+
5
+ module BoxcarAPI
6
+
7
+ ################### For Providers - http://boxcar.io/help/api/providers
8
+ class Provider
9
+ include HTTParty
10
+ attr_accessor :provider_key, :provider_secret
11
+
12
+ def initialize(provider_key, provider_secret)
13
+ @provider_key = provider_key
14
+ @provider_secret = provider_secret
15
+
16
+ self.class.base_uri "https://boxcar.io/devices/providers/#{@provider_key}/notifications"
17
+ end
18
+
19
+ def subscribe(email)
20
+ options = { :body => { :email => hashed_email(email) } }
21
+ self.class.post("/subscribe", options)
22
+ end
23
+
24
+ def broadcast(message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil)
25
+ options = { :body => { :secret => provider_secret,
26
+ :notification => {
27
+ :message => message,
28
+ :from_screen_name => from_screen_name,
29
+ :from_remote_service_id => from_remote_service_id,
30
+ :redirect_payload => redirect_payload
31
+ }
32
+ }}
33
+
34
+ self.class.post("/broadcast", options)
35
+ end
36
+
37
+ def notify(email, message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil)
38
+ options = { :body => { :email => hashed_email(email),
39
+ :notification => {
40
+ :message => message,
41
+ :from_screen_name => from_screen_name,
42
+ :from_remote_service_id => from_remote_service_id,
43
+ :redirect_payload => redirect_payload
44
+ }
45
+ }}
46
+
47
+ self.class.post("/", options)
48
+ end
49
+
50
+ def notify_service(token, secret, message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil)
51
+ options = { :body => { :token => token, :secret => secret,
52
+ :notification => {
53
+ :message => message,
54
+ :from_screen_name => from_screen_name,
55
+ :from_remote_service_id => from_remote_service_id,
56
+ :redirect_payload => redirect_payload
57
+ }
58
+ }}
59
+
60
+ self.class.post("/", options)
61
+ end
62
+
63
+ private
64
+ def hashed_email(email)
65
+ email =~ /@/ ? Digest::MD5.hexdigest(email) : email
66
+ end
67
+ end
68
+
69
+ ################### For Users - http://boxcar.io/help/api/users
70
+ class User
71
+ include HTTParty
72
+ attr_accessor :auth
73
+ base_uri "https://boxcar.io/notifications"
74
+
75
+ def initialize(email, password)
76
+ @auth = { :username => email, :password => password }
77
+ end
78
+
79
+ def notify(message, from_screen_name = nil, from_remote_service_id = nil)
80
+ options = { :basic_auth => @auth, :body => {
81
+ :notification => {
82
+ :message => message,
83
+ :from_screen_name => from_screen_name,
84
+ :from_remote_service_id => from_remote_service_id
85
+ }
86
+ }}
87
+
88
+ self.class.post("/", options)
89
+ end
90
+ end
91
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boxcar_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan George
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MREwDwYDVQQDDAhqb25h
14
+ dGhhbjETMBEGCgmSJomT8ixkARkWA2pkZzETMBEGCgmSJomT8ixkARkWA25ldDAe
15
+ Fw0xMDA0MTQwNDM2MDNaFw0xMTA0MTQwNDM2MDNaMD0xETAPBgNVBAMMCGpvbmF0
16
+ aGFuMRMwEQYKCZImiZPyLGQBGRYDamRnMRMwEQYKCZImiZPyLGQBGRYDbmV0MIIB
17
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1k3X9E577+SaAuYby0S3Jk58
18
+ iEY0E3Y4XGtQap1FqaxVChvfwW1DmQrIZlVOWZY8CEX1227BaoMGDUt65LSYHY3r
19
+ uNHfp5AwPkmStBMgf/7lNIskwow57J3px/VnlRQSXFlmVXulEl7XVnGOzvRuKerf
20
+ BbA97J2ncCZXXSluTfAHwANSLqbsXuDAd8wZ8XoU/LTpZR5rJSE6XQxAmy64xcyY
21
+ S2TU630bUMjV2h6GmwiA5S4iXlK27+j2VUulMIx5PtA8jvLHOtHzXg0nvzwYZ5Tf
22
+ +rm+yoUf71swsntg9YZrlTVVHXaFMCa0+4jZQkCdSJu4yB3NsB7fE4tatOyPaQID
23
+ AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUZpPgZYDc
24
+ kuj7cbIholL8FIkEk5QwDQYJKoZIhvcNAQEFBQADggEBAJ6X/CMiC6OBR48ZOPzb
25
+ DUivkSXHbFfIIH2HatdI03ZaMVpdK1HHviqcuE38ArqefdjecSCse2eBn/KqACpL
26
+ h0oHYw095vgyP5qUca3+rYAxiNML0abqe6zrMqgGIqMpaeVl6+eoGP48rXbuXeK+
27
+ mFI6zYmFhj/Zjjp05UMRLP6eDFoMDyKHkYYKWCE8Hi8wqLih4qIgAKW3bmX8hkmb
28
+ zBuVRvW+f9iO8M5+m0J+DeR64biLxt8IV7gLj5oLXVYQXz2ran0xkqOrOMTsLf79
29
+ JYYCM1LV3QwoYfI9CRoIscg+7eLsLuQyDIVMLHvnoxJXIFjCkqWoIaeqvuOxA6Gy
30
+ YhU=
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2010-04-13 00:00:00 -05:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: httparty
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ - !ruby/object:Gem::Dependency
47
+ name: httparty
48
+ type: :development
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ description: A simple way to send notifications to yourself, or your users through Boxcar.
57
+ email: help@boxcar.io
58
+ executables: []
59
+
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - LICENSE
64
+ - README.rdoc
65
+ - lib/boxcar_api.rb
66
+ files:
67
+ - LICENSE
68
+ - Manifest
69
+ - README.rdoc
70
+ - Rakefile
71
+ - examples/send_as_provider.rb
72
+ - examples/send_to_yourself.rb
73
+ - init.rb
74
+ - lib/boxcar_api.rb
75
+ - boxcar_api.gemspec
76
+ has_rdoc: true
77
+ homepage: http://github.com/boxcar/boxcar_api
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options:
82
+ - --line-numbers
83
+ - --inline-source
84
+ - --title
85
+ - Boxcar_api
86
+ - --main
87
+ - README.rdoc
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "1.2"
101
+ version:
102
+ requirements: []
103
+
104
+ rubyforge_project: boxcar_api
105
+ rubygems_version: 1.3.5
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: A simple way to send notifications to yourself, or your users through Boxcar.
109
+ test_files: []
110
+
metadata.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ զ�>�^������YvHS�cFɝ�����{s�?���9
2
+ �Ե�xXp�_�gC@��&!��3�t�ѯ�MDƕ'�i )� 0�diJB�]��(o�������9>�"�|�B�[�u*k��>}�ױ3vH���������S���1
3
+ =��pdam{T5꼗��sW��-~�����JNƴq�mýw��gU�/� � �rV=զң�[�D��Y�W����*���g
4
+ }��ҭ%[�-F�}y��<�����֘