boxcar_api 1.0.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -1,8 +1,7 @@
1
1
  LICENSE
2
2
  Manifest
3
- README.rdoc
3
+ README.mdown
4
4
  Rakefile
5
5
  examples/send_as_provider.rb
6
- examples/send_to_yourself.rb
7
6
  init.rb
8
7
  lib/boxcar_api.rb
@@ -0,0 +1,46 @@
1
+ boxcar_api
2
+ =================
3
+
4
+
5
+ Release Notes
6
+ ----------
7
+ **Version 1.2**
8
+
9
+ Updated to support new API features.
10
+
11
+
12
+ The Boxcar API Gem
13
+ -----------------
14
+ boxcar_api is an easy way to add Boxcar notifications to your application.
15
+
16
+ Getting Started
17
+ -----------------
18
+ First, you'll need to create a provider [here](http://boxcar.io/site/providers). We'll give you a provider key and a provider secret. Once you have those, you can get started:
19
+
20
+ provider = BoxcarAPI::Provider.new('your_key', 'your_secret')
21
+
22
+ Subscribe a Boxcar user to your service:
23
+
24
+ provider.subscribe "user@example.com"
25
+
26
+ Then send that user a notification:
27
+
28
+ provider.notify("user@example.com", "Your product has shipped!")
29
+
30
+ You can also send a group of users a notification:
31
+
32
+ users = ["user1@example.com", "user2@example.com"]
33
+ provider.batch_notify(users, "Your account has been upgraded.")
34
+
35
+ Or reach all of your subscribers with a broadcast:
36
+
37
+ provider.broadcast "Maintenance has begun. We expect to be back up 15 minutes."
38
+
39
+ Want to know more? Check out our [API docs](http://boxcar.io/help/api/providers) and the [examples](https://github.com/boxcar/boxcar_api/blob/master/examples/send_as_provider.rb) for all the details.
40
+
41
+
42
+ Copyright
43
+ -----
44
+
45
+ Copyright (c) 2010 Boxcar. MIT Licensed.
46
+
data/Rakefile CHANGED
@@ -1,8 +1,13 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
+ require 'rspec/core/rake_task'
4
5
 
5
- Echoe.new('boxcar_api', '1.0.2') do |p|
6
+ RSpec::Core::RakeTask.new :spec do |t|
7
+ t.rspec_opts = %w(-fp --color)
8
+ end
9
+
10
+ Echoe.new('boxcar_api', '1.2.0') do |p|
6
11
  p.description = "A simple way to send notifications to yourself, or your users through Boxcar."
7
12
  p.url = "http://github.com/boxcar/boxcar_api"
8
13
  p.author = "Jonathan George"
@@ -10,4 +15,87 @@ Echoe.new('boxcar_api', '1.0.2') do |p|
10
15
  p.ignore_pattern = ["tmp/*", "script/*"]
11
16
  p.development_dependencies = ["httparty"]
12
17
  p.runtime_dependencies = ["httparty"]
13
- end
18
+ end
19
+
20
+
21
+ require "rubygems"
22
+ require "rubygems/package_task"
23
+ require "rdoc/task"
24
+
25
+ require "rspec"
26
+ require "rspec/core/rake_task"
27
+ RSpec::Core::RakeTask.new do |t|
28
+ t.rspec_opts = %w(--format documentation --colour)
29
+ end
30
+
31
+
32
+ task :default => ["spec"]
33
+
34
+ # This builds the actual gem. For details of what all these options
35
+ # mean, and other ones you can add, check the documentation here:
36
+ #
37
+ # http://rubygems.org/read/chapter/20
38
+ #
39
+ spec = Gem::Specification.new do |s|
40
+
41
+ # Change these as appropriate
42
+ s.name = "boxcar_api"
43
+ s.version = "1.2.0"
44
+ s.summary = "A simple way to send notifications to yourself or your users through Boxcar."
45
+ s.author = "Kevin Griffin"
46
+ s.email = "kevin@boxcar.io"
47
+ s.homepage = "http://boxcar.io"
48
+
49
+ s.has_rdoc = false
50
+ s.extra_rdoc_files = %w(README.mdown)
51
+ s.rdoc_options = %w(--main README.mdown)
52
+
53
+ # Add any extra files to include in the gem
54
+ s.files = %w(init.rb LICENSE Manifest Rakefile README.mdown) + Dir.glob("{spec,lib}/**/*")
55
+ s.require_paths = ["lib"]
56
+
57
+ # If you want to depend on other gems, add them here, along with any
58
+ # relevant versions
59
+ s.add_dependency("httparty", ">= 0.6.1")
60
+
61
+ # If your tests use any gems, include them here
62
+ s.add_development_dependency("rspec")
63
+ s.add_development_dependency("yaml")
64
+ s.add_development_dependency("ephemeral_response")
65
+ end
66
+
67
+ # This task actually builds the gem. We also regenerate a static
68
+ # .gemspec file, which is useful if something (i.e. GitHub) will
69
+ # be automatically building a gem for this project. If you're not
70
+ # using GitHub, edit as appropriate.
71
+ #
72
+ # To publish your gem online, install the 'gemcutter' gem; Read more
73
+ # about that here: http://gemcutter.org/pages/gem_docs
74
+ Gem::PackageTask.new(spec) do |pkg|
75
+ pkg.gem_spec = spec
76
+ end
77
+
78
+ desc "Build the gemspec file #{spec.name}.gemspec"
79
+ task :gemspec do
80
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
81
+ File.open(file, "w") {|f| f << spec.to_ruby }
82
+ end
83
+
84
+ # If you don't want to generate the .gemspec file, just remove this line. Reasons
85
+ # why you might want to generate a gemspec:
86
+ # - using bundler with a git source
87
+ # - building the gem without rake (i.e. gem build blah.gemspec)
88
+ # - maybe others?
89
+ task :package => :gemspec
90
+
91
+ # Generate documentation
92
+ RDoc::Task.new do |rd|
93
+ rd.main = "README.mdown"
94
+ rd.rdoc_files.include("README.mdown", "lib/**/*.rb")
95
+ rd.rdoc_dir = "rdoc"
96
+ end
97
+
98
+ desc 'Clear out RDoc and generated packages'
99
+ task :clean => [:clobber_rdoc, :clobber_package] do
100
+ rm "#{spec.name}.gemspec"
101
+ end
@@ -1,99 +1,74 @@
1
1
  require 'rubygems'
2
2
  require 'httparty'
3
- require 'digest/md5'
4
3
 
5
4
  module BoxcarAPI
6
5
 
7
- ################### For Providers - http://boxcar.io/help/api/providers
6
+ # For Providers - http://boxcar.io/help/api/providers
8
7
  class Provider
9
8
  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"
9
+ attr_accessor :provider_key, :provider_secret, :screen_name
10
+
11
+ def initialize(provider_key ={}, provider_secret = nil, screen_name = nil)
12
+ if provider_key.kind_of? Hash
13
+ url = provider_key[:url]
14
+ url.chop! if url.end_with? '/'
15
+
16
+ @provider_key = url.match(/https?:\/\/\S+\/(.*)$/)[1]
17
+ self.class.base_uri(url + "/notifications")
18
+ else
19
+ @provider_key = provider_key
20
+ @provider_secret = provider_secret
21
+ @screen_name = screen_name
22
+ self.class.base_uri "https://boxcar.io/devices/providers/#{@provider_key}/notifications"
23
+ end
17
24
  end
18
25
 
19
26
  def subscribe(email)
20
- options = { :body => { :email => hashed_email(email) } }
21
- self.class.post("/subscribe", options)
27
+ params = { :body => { :email => email } }
28
+ self.class.post("/subscribe", params)
22
29
  end
23
30
 
24
- def broadcast(message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil, source_url = nil, icon_url = nil)
25
- options = { :body => { :secret => provider_secret,
31
+ def broadcast(message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil})
32
+ params = { :body => { :secret => provider_secret,
26
33
  :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
- :source_url => source_url,
32
- :icon_url => icon_url
33
- }
34
+ :message => message,
35
+ :from_screen_name => options[:from_screen_name],
36
+ :from_remote_service_id => options[:from_remote_service_id],
37
+ :source_url => options[:source_url],
38
+ :icon_url => options[:icon_url]
39
+ }
34
40
  }}
35
41
 
36
- self.class.post("/broadcast", options)
42
+ self.class.post("/broadcast", params)
37
43
  end
38
44
 
39
- def notify(email, message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil, source_url = nil, icon_url = nil)
40
- options = { :body => { :email => hashed_email(email),
45
+ def notify(email, message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil})
46
+ params = { :body => { :email => email,
41
47
  :notification => {
42
- :message => message,
43
- :from_screen_name => from_screen_name,
44
- :from_remote_service_id => from_remote_service_id,
45
- :redirect_payload => redirect_payload,
46
- :source_url => source_url,
47
- :icon_url => icon_url
48
- }
48
+ :message => message,
49
+ :from_screen_name => options[:from_screen_name],
50
+ :from_remote_service_id => options[:from_remote_service_id],
51
+ :source_url => options[:source_url],
52
+ :icon_url => options[:icon_url]
53
+ }
49
54
  }}
50
55
 
51
- self.class.post("/", options)
56
+ self.class.post("/", params)
52
57
  end
53
-
54
- def notify_service(token, secret, message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil, source_url = nil, icon_url = nil)
55
- options = { :body => { :token => token, :secret => secret,
58
+
59
+ def batch_notify(emails, message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil})
60
+ params = { :body => { :emails => emails,
56
61
  :notification => {
57
- :message => message,
58
- :from_screen_name => from_screen_name,
59
- :from_remote_service_id => from_remote_service_id,
60
- :redirect_payload => redirect_payload,
61
- :source_url => source_url,
62
- :icon_url => icon_url
63
- }
62
+ :message => message,
63
+ :from_screen_name => options[:from_screen_name],
64
+ :from_remote_service_id => options[:from_remote_service_id],
65
+ :source_url => options[:source_url],
66
+ :icon_url => options[:icon_url]
67
+ }
64
68
  }}
65
69
 
66
- self.class.post("/", options)
67
- end
68
-
69
- private
70
- def hashed_email(email)
71
- email =~ /@/ ? Digest::MD5.hexdigest(email) : email
70
+ self.class.post("/", params)
72
71
  end
73
72
  end
73
+ end
74
74
 
75
- ################### For Users - http://boxcar.io/help/api/users
76
- class User
77
- include HTTParty
78
- attr_accessor :auth
79
- base_uri "https://boxcar.io/notifications"
80
-
81
- def initialize(email, password)
82
- @auth = { :username => email, :password => password }
83
- end
84
-
85
- def notify(message, from_screen_name = nil, from_remote_service_id = nil, source_url = nil, icon_url = nil)
86
- options = { :basic_auth => @auth, :body => {
87
- :notification => {
88
- :message => message,
89
- :from_screen_name => from_screen_name,
90
- :from_remote_service_id => from_remote_service_id,
91
- :icon_url => icon_url,
92
- :source_url => source_url
93
- }
94
- }}
95
-
96
- self.class.post("/", options)
97
- end
98
- end
99
- end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe BoxcarAPI do
4
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe BoxcarAPI::Provider do
4
+
5
+ before :each do
6
+ @config = YAML.load_file(File.join(File.dirname(__FILE__), 'settings.yml'))
7
+ @box = BoxcarAPI::Provider.new(@config['provider_key'], @config['provider_secret'])
8
+ end
9
+
10
+ describe "#subscribe" do
11
+ it "should sending an invitation to subscribe" do
12
+ box = BoxcarAPI::Provider.new(@config['provider_key'], @config['provider_secret'])
13
+ box.subscribe(@config['email']).code.should == 200
14
+ end
15
+ it "should return error when invalid parameters" do
16
+ box = BoxcarAPI::Provider.new("invalidkey", "invalidsecret")
17
+ box.subscribe("invalid@email.com").code.should == 401
18
+ end
19
+ end
20
+
21
+ describe "#broadcast" do
22
+ it "should broadcasting notifications to all services" do
23
+ @box.broadcast("This is an example message.", "from").code.should == 200
24
+ end
25
+ it "should accept from_screen_name" do
26
+ @box.broadcast("message with screen name", "jtadeulopes").code.should == 200
27
+ end
28
+ it "should accept from_remote_service_id" do
29
+ @box.broadcast("message with service id", "jtadeulopes", "unique").code.should == 200
30
+ end
31
+ it "should accept redirect_payload" do
32
+ @box.broadcast("message with redirect payload", "jtadeulopes", nil, "jdg").code.should == 200
33
+ end
34
+ it "should accept source_url" do
35
+ @box.broadcast("message with url", "jtadeulopes", nil, "jdg", "http://google.com").code.should == 200
36
+ end
37
+ it "should accept icon_url" do
38
+ @box.broadcast("message with icon", "jtadeulopes", nil, "jdg", "http://google.com", "http://graph.facebook.com/jtadeulopes/picture").code.should == 200
39
+ end
40
+ end
41
+
42
+ describe "#notify" do
43
+ it "should creating individual notifications" do
44
+ @box.notify(@config['email'], "This is an example message.", "from").code.should == 200
45
+ end
46
+ it "should accept from_screen_name" do
47
+ @box.notify(@config['email'], "message with screen name", "jtadeulopes").code.should == 200
48
+ end
49
+ it "should accept from_remote_service_id" do
50
+ @box.notify(@config['email'], "bla bla", "jtadeulopes", "12345").code.should == 200
51
+ end
52
+ it "should accept redirect_payload" do
53
+ @box.notify(@config['email'], "message with redirect payload", "jtadeulopes", nil, "jdg").code.should == 200
54
+ end
55
+ it "should accept source_url" do
56
+ @box.notify(@config['email'], "message with url", "jtadeulopes", nil, "jdg", "http://google.com").code.should == 200
57
+ end
58
+ it "should accept icon_url" do
59
+ @box.notify(@config['email'], "message with icon", "jtadeulopes", nil, "jdg", "http://google.com", "http://graph.facebook.com/jtadeulopes/picture").code.should == 200
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,7 @@
1
+ # Create a new provider for real testing
2
+ # http://boxcar.io/site/providers
3
+ #
4
+ provider_key: "xyz"
5
+ provider_secret: "xyz"
6
+ email: "user@example.com"
7
+ password: "myboxpassword"
@@ -0,0 +1,19 @@
1
+ require "rubygems"
2
+ require "rspec"
3
+ require 'yaml'
4
+ require 'ephemeral_response'
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+
9
+ require "boxcar_api"
10
+
11
+ Rspec.configure do |config|
12
+ config.before(:suite) do
13
+ EphemeralResponse.activate
14
+ end
15
+
16
+ config.after(:suite) do
17
+ EphemeralResponse.deactivate
18
+ end
19
+ end
metadata CHANGED
@@ -1,122 +1,132 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxcar_api
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 31
5
+ prerelease:
5
6
  segments:
6
7
  - 1
7
- - 0
8
8
  - 2
9
- version: 1.0.2
9
+ - 0
10
+ version: 1.2.0
10
11
  platform: ruby
11
12
  authors:
12
- - Jonathan George
13
+ - Kevin Griffin
13
14
  autorequire:
14
15
  bindir: bin
15
- cert_chain:
16
- - |
17
- -----BEGIN CERTIFICATE-----
18
- MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MREwDwYDVQQDDAhqb25h
19
- dGhhbjETMBEGCgmSJomT8ixkARkWA2pkZzETMBEGCgmSJomT8ixkARkWA25ldDAe
20
- Fw0xMDA0MTQwNDM2MDNaFw0xMTA0MTQwNDM2MDNaMD0xETAPBgNVBAMMCGpvbmF0
21
- aGFuMRMwEQYKCZImiZPyLGQBGRYDamRnMRMwEQYKCZImiZPyLGQBGRYDbmV0MIIB
22
- IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1k3X9E577+SaAuYby0S3Jk58
23
- iEY0E3Y4XGtQap1FqaxVChvfwW1DmQrIZlVOWZY8CEX1227BaoMGDUt65LSYHY3r
24
- uNHfp5AwPkmStBMgf/7lNIskwow57J3px/VnlRQSXFlmVXulEl7XVnGOzvRuKerf
25
- BbA97J2ncCZXXSluTfAHwANSLqbsXuDAd8wZ8XoU/LTpZR5rJSE6XQxAmy64xcyY
26
- S2TU630bUMjV2h6GmwiA5S4iXlK27+j2VUulMIx5PtA8jvLHOtHzXg0nvzwYZ5Tf
27
- +rm+yoUf71swsntg9YZrlTVVHXaFMCa0+4jZQkCdSJu4yB3NsB7fE4tatOyPaQID
28
- AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUZpPgZYDc
29
- kuj7cbIholL8FIkEk5QwDQYJKoZIhvcNAQEFBQADggEBAJ6X/CMiC6OBR48ZOPzb
30
- DUivkSXHbFfIIH2HatdI03ZaMVpdK1HHviqcuE38ArqefdjecSCse2eBn/KqACpL
31
- h0oHYw095vgyP5qUca3+rYAxiNML0abqe6zrMqgGIqMpaeVl6+eoGP48rXbuXeK+
32
- mFI6zYmFhj/Zjjp05UMRLP6eDFoMDyKHkYYKWCE8Hi8wqLih4qIgAKW3bmX8hkmb
33
- zBuVRvW+f9iO8M5+m0J+DeR64biLxt8IV7gLj5oLXVYQXz2ran0xkqOrOMTsLf79
34
- JYYCM1LV3QwoYfI9CRoIscg+7eLsLuQyDIVMLHvnoxJXIFjCkqWoIaeqvuOxA6Gy
35
- YhU=
36
- -----END CERTIFICATE-----
16
+ cert_chain: []
37
17
 
38
- date: 2010-11-15 00:00:00 -06:00
39
- default_executable:
18
+ date: 2011-09-28 00:00:00 Z
40
19
  dependencies:
41
20
  - !ruby/object:Gem::Dependency
42
21
  name: httparty
43
22
  prerelease: false
44
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
45
25
  requirements:
46
26
  - - ">="
47
27
  - !ruby/object:Gem::Version
28
+ hash: 5
48
29
  segments:
49
30
  - 0
50
- version: "0"
31
+ - 6
32
+ - 1
33
+ version: 0.6.1
51
34
  type: :runtime
52
35
  version_requirements: *id001
53
36
  - !ruby/object:Gem::Dependency
54
- name: httparty
37
+ name: rspec
55
38
  prerelease: false
56
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
57
41
  requirements:
58
42
  - - ">="
59
43
  - !ruby/object:Gem::Version
44
+ hash: 3
60
45
  segments:
61
46
  - 0
62
47
  version: "0"
63
48
  type: :development
64
49
  version_requirements: *id002
65
- description: A simple way to send notifications to yourself, or your users through Boxcar.
66
- email: help@boxcar.io
50
+ - !ruby/object:Gem::Dependency
51
+ name: yaml
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :development
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: ephemeral_response
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ type: :development
77
+ version_requirements: *id004
78
+ description:
79
+ email: kevin@boxcar.io
67
80
  executables: []
68
81
 
69
82
  extensions: []
70
83
 
71
84
  extra_rdoc_files:
72
- - LICENSE
73
- - README.rdoc
74
- - lib/boxcar_api.rb
85
+ - README.mdown
75
86
  files:
87
+ - init.rb
76
88
  - LICENSE
77
89
  - Manifest
78
- - README.rdoc
79
90
  - Rakefile
80
- - examples/send_as_provider.rb
81
- - examples/send_to_yourself.rb
82
- - init.rb
91
+ - README.mdown
92
+ - spec/boxcar_api_spec.rb
93
+ - spec/provider_spec.rb
94
+ - spec/settings.yml.sample
95
+ - spec/spec_helper.rb
83
96
  - lib/boxcar_api.rb
84
- - boxcar_api.gemspec
85
- has_rdoc: true
86
- homepage: http://github.com/boxcar/boxcar_api
97
+ homepage: http://boxcar.io
87
98
  licenses: []
88
99
 
89
100
  post_install_message:
90
101
  rdoc_options:
91
- - --line-numbers
92
- - --inline-source
93
- - --title
94
- - Boxcar_api
95
102
  - --main
96
- - README.rdoc
103
+ - README.mdown
97
104
  require_paths:
98
105
  - lib
99
106
  required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
100
108
  requirements:
101
109
  - - ">="
102
110
  - !ruby/object:Gem::Version
111
+ hash: 3
103
112
  segments:
104
113
  - 0
105
114
  version: "0"
106
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
+ none: false
107
117
  requirements:
108
118
  - - ">="
109
119
  - !ruby/object:Gem::Version
120
+ hash: 3
110
121
  segments:
111
- - 1
112
- - 2
113
- version: "1.2"
122
+ - 0
123
+ version: "0"
114
124
  requirements: []
115
125
 
116
- rubyforge_project: boxcar_api
117
- rubygems_version: 1.3.6
126
+ rubyforge_project:
127
+ rubygems_version: 1.8.10
118
128
  signing_key:
119
129
  specification_version: 3
120
- summary: A simple way to send notifications to yourself, or your users through Boxcar.
130
+ summary: A simple way to send notifications to yourself or your users through Boxcar.
121
131
  test_files: []
122
132
 
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- -l!=>��*Y��ې\X���?�bk���7T��A�{ ��0� �־�� '��Y3�1��!��*�֕`� nh:��6��Bs�\���B��)X�Ż�^^Z
2
- � Ib�TI���=N�
@@ -1,12 +0,0 @@
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.
@@ -1,38 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{boxcar_api}
5
- s.version = "1.0.2"
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-11-15}
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.6}
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
@@ -1,81 +0,0 @@
1
- require 'rubygems'
2
- require 'boxcar_api'
3
-
4
- SETTINGS = {
5
- :provider_key => 'xyz',
6
- :provider_secret => 'xyz',
7
- :email => 'user@example.com'
8
- }
9
-
10
- bp = BoxcarAPI::Provider.new(SETTINGS[:provider_key], SETTINGS[:provider_key])
11
-
12
- #### Send an invitation to a user by their e-mail address, to add your service.
13
- res = bp.subscribe(SETTINGS[:email])
14
-
15
- if res.code == 200
16
- puts "Success! You sent an invitation to #{SETTINGS[:email]} to add your service."
17
- else
18
- puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
19
- end
20
-
21
- #### Deliver a broadcast notification to everyone that has added your service.
22
- res = bp.broadcast("This is an example message.", "from")
23
-
24
- if res.code == 200
25
- puts "Success! You sent a broadcast message to everyone using your service."
26
- else
27
- puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
28
- end
29
-
30
- #### Deliver a personalized notification to a subscriber by email.
31
- res = bp.notify(SETTINGS[:email], "This is an example message.", "from")
32
-
33
- if res.code == 200
34
- puts "Success! You sent a personalized message to #{SETTINGS[:email]}."
35
- else
36
- puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
37
- end
38
-
39
- #### Deliver a personalized notification to a subscriber by email, but only deliver it once!
40
- # This includes the from_remote_service_id for the user, which will ensure it's only delivered one time.
41
- res = bp.notify(SETTINGS[:email], "This is an example message.", "from", "123")
42
-
43
- if res.code == 200
44
- puts "Success! You sent a personalized message to #{SETTINGS[:email]}."
45
- else
46
- puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
47
- end
48
-
49
- #### Deliver a personalized notification to a subscriber by email, including a redirect payload
50
- # Redirect payloads are what replaces "::user::" in your Boxcar redirect URL.
51
-
52
- res = bp.notify(SETTINGS[:email], "This is an example message.", "from", nil, "jdg")
53
- if res.code == 200
54
- puts "Success! You sent a personalized message with a redirect payload to #{SETTINGS[:email]}."
55
- else
56
- puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
57
- end
58
-
59
- #### Deliver a personalized notification to a subscriber by email, including a redirect payload
60
- # Redirect payloads are what replaces "::user::" in your Boxcar redirect URL.
61
- # Also include a source_url and an icon_url
62
-
63
- res = bp.notify(SETTINGS[:email], "This is an example message.", "from", nil, "jdg", "http://google.com",
64
- "http://graph.facebook.com/jonathan.george/picture")
65
- if res.code == 200
66
- puts "Success! You sent a personalized message with a redirect payload, source_url and icon_url to #{SETTINGS[:email]}."
67
- else
68
- puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
69
- end
70
-
71
-
72
- #### Deliver a personalized notification to a subscriber by their service token/secret.
73
- #### This works, just commented out because it's much easier to use e-mail addresses.
74
- #
75
- #res = bp.notify_service(token, secret, "This is an example message.", "from")
76
-
77
- #if res.code == 200
78
- # puts "Success! You sent a broadcast message to everyone using your service."
79
- #else
80
- # puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
81
- #end
@@ -1,28 +0,0 @@
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 an 'icon url' - a link to an icon hosted online.
20
- # Also include a 'source url', a link that we'll take you to when you chose to View Original for the notification.
21
- res = bu.notify("message", "from", nil, "http://facebook.com", "http://graph.facebook.com/jonathan.george/picture")
22
-
23
- # This time include a unique identifier, and if you send it more than once
24
- # additional notifications will be dropped as duplicates.
25
- res = bu.notify("message", "from", "unique")
26
-
27
- # This one won't be delivered, because you've already gotten it.
28
- res = bu.notify("message", "from", "unique")
metadata.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- f���g�}%���'�Lm2�[�%
2
- �>lM+{P-g\���g���r������f���ӯ��2zp�J�������y^���KI Z`�ߠ����QI2����]�M�ܸ'�7��@����