boxcar_api 1.0.0 → 1.0.1

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.
data/Manifest CHANGED
@@ -2,6 +2,7 @@ LICENSE
2
2
  Manifest
3
3
  README.rdoc
4
4
  Rakefile
5
+ boxcar_api.gemspec
5
6
  examples/send_as_provider.rb
6
7
  examples/send_to_yourself.rb
7
8
  init.rb
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('boxcar_api', '1.0.0') do |p|
5
+ Echoe.new('boxcar_api', '1.0.1') do |p|
6
6
  p.description = "A simple way to send notifications to yourself, or your users through Boxcar."
7
7
  p.url = "http://github.com/boxcar/boxcar_api"
8
8
  p.author = "Jonathan George"
data/boxcar_api.gemspec CHANGED
@@ -2,21 +2,21 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{boxcar_api}
5
- s.version = "1.0.0"
5
+ s.version = "1.0.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jonathan George"]
9
9
  s.cert_chain = ["/Users/jonathan/.ssh/gem-public_cert.pem"]
10
- s.date = %q{2010-04-13}
10
+ s.date = %q{2010-11-06}
11
11
  s.description = %q{A simple way to send notifications to yourself, or your users through Boxcar.}
12
12
  s.email = %q{help@boxcar.io}
13
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"]
14
+ s.files = ["LICENSE", "Manifest", "README.rdoc", "Rakefile", "boxcar_api.gemspec", "examples/send_as_provider.rb", "examples/send_to_yourself.rb", "init.rb", "lib/boxcar_api.rb"]
15
15
  s.homepage = %q{http://github.com/boxcar/boxcar_api}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxcar_api", "--main", "README.rdoc"]
17
17
  s.require_paths = ["lib"]
18
18
  s.rubyforge_project = %q{boxcar_api}
19
- s.rubygems_version = %q{1.3.5}
19
+ s.rubygems_version = %q{1.3.6}
20
20
  s.signing_key = %q{/Users/jonathan/.ssh/gem-private_key.pem}
21
21
  s.summary = %q{A simple way to send notifications to yourself, or your users through Boxcar.}
22
22
 
@@ -1,16 +1,19 @@
1
1
  require 'rubygems'
2
2
  require 'boxcar_api'
3
3
 
4
- provider_key = 'xyz'
5
- provider_secret = 'xyz'
4
+ SETTINGS = {
5
+ :provider_key => 'xyz',
6
+ :provider_secret => 'xyz',
7
+ :email => 'user@example.com'
8
+ }
6
9
 
7
- bp = Provider.new(provider_key, provider_secret)
10
+ bp = BoxcarAPI::Provider.new(SETTINGS[:provider_key], SETTINGS[:provider_key])
8
11
 
9
12
  #### Send an invitation to a user by their e-mail address, to add your service.
10
- res = bp.subscribe('user@example.com')
13
+ res = bp.subscribe(SETTINGS[:email])
11
14
 
12
15
  if res.code == 200
13
- puts "Success! You sent an invitation to user@example.com to add your service."
16
+ puts "Success! You sent an invitation to #{SETTINGS[:email]} to add your service."
14
17
  else
15
18
  puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
16
19
  end
@@ -25,19 +28,54 @@ else
25
28
  end
26
29
 
27
30
  #### Deliver a personalized notification to a subscriber by email.
28
- res = bp.broadcast("user@example.com", "This is an example message.", "from")
31
+ res = bp.notify(SETTINGS[:email], "This is an example message.", "from")
29
32
 
30
33
  if res.code == 200
31
- puts "Success! You sent a broadcast message to everyone using your service."
34
+ puts "Success! You sent a personalized message to #{SETTINGS[:email]}."
32
35
  else
33
36
  puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
34
37
  end
35
38
 
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")
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")
38
42
 
39
43
  if res.code == 200
40
- puts "Success! You sent a broadcast message to everyone using your service."
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]}."
41
67
  else
42
68
  puts "Problem! HTTP status code: #{res.code}. Check the API docs!"
43
- end
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
@@ -16,6 +16,10 @@ end
16
16
  # This time include a 'from screen name' - e.g., an application name, or a person.
17
17
  res = bu.notify("message", "from")
18
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
+
19
23
  # This time include a unique identifier, and if you send it more than once
20
24
  # additional notifications will be dropped as duplicates.
21
25
  res = bu.notify("message", "from", "unique")
data/lib/boxcar_api.rb CHANGED
@@ -21,40 +21,46 @@ module BoxcarAPI
21
21
  self.class.post("/subscribe", options)
22
22
  end
23
23
 
24
- def broadcast(message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil)
24
+ def broadcast(message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil, source_url = nil, icon_url = nil)
25
25
  options = { :body => { :secret => provider_secret,
26
26
  :notification => {
27
27
  :message => message,
28
28
  :from_screen_name => from_screen_name,
29
29
  :from_remote_service_id => from_remote_service_id,
30
- :redirect_payload => redirect_payload
30
+ :redirect_payload => redirect_payload,
31
+ :source_url => source_url,
32
+ :icon_url => icon_url
31
33
  }
32
34
  }}
33
35
 
34
36
  self.class.post("/broadcast", options)
35
37
  end
36
38
 
37
- def notify(email, message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil)
39
+ def notify(email, message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil, source_url = nil, icon_url = nil)
38
40
  options = { :body => { :email => hashed_email(email),
39
41
  :notification => {
40
42
  :message => message,
41
43
  :from_screen_name => from_screen_name,
42
44
  :from_remote_service_id => from_remote_service_id,
43
45
  :redirect_payload => redirect_payload
46
+ :source_url => source_url,
47
+ :icon_url => icon_url
44
48
  }
45
49
  }}
46
50
 
47
51
  self.class.post("/", options)
48
52
  end
49
53
 
50
- def notify_service(token, secret, message, from_screen_name = nil, from_remote_service_id = nil, redirect_payload = nil)
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)
51
55
  options = { :body => { :token => token, :secret => secret,
52
56
  :notification => {
53
57
  :message => message,
54
58
  :from_screen_name => from_screen_name,
55
59
  :from_remote_service_id => from_remote_service_id,
56
60
  :redirect_payload => redirect_payload
57
- }
61
+ :source_url => source_url,
62
+ :icon_url => icon_url
63
+ }
58
64
  }}
59
65
 
60
66
  self.class.post("/", options)
@@ -76,13 +82,15 @@ module BoxcarAPI
76
82
  @auth = { :username => email, :password => password }
77
83
  end
78
84
 
79
- def notify(message, from_screen_name = nil, from_remote_service_id = nil)
85
+ def notify(message, from_screen_name = nil, from_remote_service_id = nil, source_url = nil, icon_url = nil)
80
86
  options = { :basic_auth => @auth, :body => {
81
87
  :notification => {
82
88
  :message => message,
83
89
  :from_screen_name => from_screen_name,
84
- :from_remote_service_id => from_remote_service_id
85
- }
90
+ :from_remote_service_id => from_remote_service_id,
91
+ :icon_url => icon_url,
92
+ :source_url => source_url
93
+ }
86
94
  }}
87
95
 
88
96
  self.class.post("/", options)
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxcar_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 1
9
+ version: 1.0.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jonathan George
@@ -30,29 +35,33 @@ cert_chain:
30
35
  YhU=
31
36
  -----END CERTIFICATE-----
32
37
 
33
- date: 2010-04-13 00:00:00 -05:00
38
+ date: 2010-11-06 00:00:00 -05:00
34
39
  default_executable:
35
40
  dependencies:
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: httparty
38
- type: :runtime
39
- version_requirement:
40
- version_requirements: !ruby/object:Gem::Requirement
43
+ prerelease: false
44
+ requirement: &id001 !ruby/object:Gem::Requirement
41
45
  requirements:
42
46
  - - ">="
43
47
  - !ruby/object:Gem::Version
48
+ segments:
49
+ - 0
44
50
  version: "0"
45
- version:
51
+ type: :runtime
52
+ version_requirements: *id001
46
53
  - !ruby/object:Gem::Dependency
47
54
  name: httparty
48
- type: :development
49
- version_requirement:
50
- version_requirements: !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id002 !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - ">="
53
59
  - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
54
62
  version: "0"
55
- version:
63
+ type: :development
64
+ version_requirements: *id002
56
65
  description: A simple way to send notifications to yourself, or your users through Boxcar.
57
66
  email: help@boxcar.io
58
67
  executables: []
@@ -68,11 +77,11 @@ files:
68
77
  - Manifest
69
78
  - README.rdoc
70
79
  - Rakefile
80
+ - boxcar_api.gemspec
71
81
  - examples/send_as_provider.rb
72
82
  - examples/send_to_yourself.rb
73
83
  - init.rb
74
84
  - lib/boxcar_api.rb
75
- - boxcar_api.gemspec
76
85
  has_rdoc: true
77
86
  homepage: http://github.com/boxcar/boxcar_api
78
87
  licenses: []
@@ -91,18 +100,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
100
  requirements:
92
101
  - - ">="
93
102
  - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
94
105
  version: "0"
95
- version:
96
106
  required_rubygems_version: !ruby/object:Gem::Requirement
97
107
  requirements:
98
108
  - - ">="
99
109
  - !ruby/object:Gem::Version
110
+ segments:
111
+ - 1
112
+ - 2
100
113
  version: "1.2"
101
- version:
102
114
  requirements: []
103
115
 
104
116
  rubyforge_project: boxcar_api
105
- rubygems_version: 1.3.5
117
+ rubygems_version: 1.3.6
106
118
  signing_key:
107
119
  specification_version: 3
108
120
  summary: A simple way to send notifications to yourself, or your users through Boxcar.
metadata.gz.sig CHANGED
Binary file