boxcar_client 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b9dbe7a1624ac2a395ee483daf771457179ce04
4
- data.tar.gz: 62a9f4877998d2ef2c1696a7b532caaaea51009e
3
+ metadata.gz: a901ab178db24465ed58eb8b56f6d6604ae8d996
4
+ data.tar.gz: 8e2cc03d39c497a0a4082021797eb91242b3b107
5
5
  SHA512:
6
- metadata.gz: 0c2b8e18b331b29e86572a642c1bea5439b87634c7a032e140d616fd16fe875e97a9da94426de981171796df6845e6f53e91d401b4fefd076bbb3bea6306c6de
7
- data.tar.gz: ee0a71cbd6bb04e70c295c5cee2c40a1776d2cbf10664e003cdba54efc4a0f38d2c0600386aa034bdab27a5d07f68719927325cff745fa84cd3bc38e4391415d
6
+ metadata.gz: e18ed0951236b68d62175a8bb615115b59298bb44412c3ecc5584b16cf7870eb6645effa7fac0e3e97b82f9a575086bb8eb48caffcafed5680fa58bcb0171c1a
7
+ data.tar.gz: c13c2c94bf9cdb9b4486c1338793572e06c90bfc80ea2210d1d18b8c734de5efa7c9f8925a8dfe162207f9d364b4ec668ac20df41300e39d087c286616880d38
@@ -1,26 +1,27 @@
1
1
  module BoxcarClient
2
2
  class Agent
3
- def initialize(push_url, data)
4
- @push_url = push_url
5
- @data = data
3
+ def initialize(url, data)
4
+ @url = url
5
+ @data = data
6
6
  end
7
7
 
8
- def push
9
- uri = URI(@push_url)
8
+ def post
9
+ uri = URI(@url)
10
10
  request = Net::HTTP::Post.new(uri.to_s)
11
11
  request.set_form_data(@data)
12
12
 
13
- response = Net::HTTP.start(uri.hostname, uri.port).request(request)
14
- response_handler response
13
+ begin
14
+ response = Net::HTTP.start(uri.hostname, uri.port).request(request)
15
+ response_handler response
16
+ rescue
17
+ end
15
18
  end
16
19
 
17
20
  private
18
-
19
-
20
21
  def response_handler(response)
21
22
  case response
22
23
  when Net::HTTPSuccess
23
- # OK
24
+ "OK"
24
25
  else
25
26
  response.value
26
27
  end
@@ -8,5 +8,9 @@ module BoxcarClient
8
8
  def push_url
9
9
  "http://boxcar.io/devices/providers/#{api_key}/notifications"
10
10
  end
11
+
12
+ def subscribe_url
13
+ "http://boxcar.io/devices/providers/#{api_key}/notifications/subscribe"
14
+ end
11
15
  end
12
16
  end
@@ -1,7 +1,11 @@
1
1
  module BoxcarClient
2
2
  class Notifier
3
3
  def self.push(user_data)
4
- Agent.new(BoxcarClient.configuration.push_url, push_data(user_data)).push
4
+ Agent.new(BoxcarClient.configuration.push_url, push_data(user_data)).post
5
+ end
6
+
7
+ def self.subscribe(email)
8
+ Agent.new(BoxcarClient.configuration.subscribe_url, {'email' => email}).post
5
9
  end
6
10
 
7
11
  def self.push_data(user_data)
@@ -1,3 +1,3 @@
1
1
  module BoxcarClient
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxcar_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Srihari, Unni