instapush-api 0.0.1 → 0.1.0
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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/README.md +16 -5
- data/bin/instapush +0 -0
- data/instapush.gemspec +1 -0
- data/lib/instapush/application.rb +13 -2
- data/lib/instapush/version.rb +1 -1
- data/spec/application_spec.rb +48 -0
- data/spec/event_spec.rb +16 -0
- data/spec/instapush_spec.rb +0 -4
- data/spec/spec_helper.rb +1 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fbc68ab911f9849e5401f9b0b0f2ba142579712
|
4
|
+
data.tar.gz: e1574b911494282baf1ff705eb4ec35bb4401873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ebf4c725ad68d6b41d1e541333c11c6da1524070cfe572129c62dbc68cdb5d8632d02d7a30137a171875bdb8f587a1867812d331838bc88b3a645291243897d
|
7
|
+
data.tar.gz: f9647b511e7d1d1d302a233234dd5cd20b044858680597e3a28dc1e09526f2691aa703b6db706203c925dca02a011c71792d65dd24f0dbc52e65d04249ba2730
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Instapush
|
2
2
|
|
3
|
-
|
3
|
+
This library provides an API wrapper for [Instapush.im](http://instapush.im). Instapush.im allows you to send push notification to your Android/iOS mobile from your application.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'instapush'
|
9
|
+
gem 'instapush-api'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -14,15 +14,26 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install instapush
|
17
|
+
$ gem install instapush-api
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Using the library requires only a few lines of code:
|
22
|
+
|
23
|
+
```
|
24
|
+
require 'instapush'
|
25
|
+
|
26
|
+
app = Instapush::Application.new 'id', 'secret'
|
27
|
+
|
28
|
+
event = Instapush::Event.new 'event-name'
|
29
|
+
event.tracker= { :version => '0.9.0' }
|
30
|
+
|
31
|
+
app.push event
|
32
|
+
```
|
22
33
|
|
23
34
|
## Contributing
|
24
35
|
|
25
|
-
1. Fork it ( http://github.com
|
36
|
+
1. Fork it ( http://github.com/halfdan/instapush/fork )
|
26
37
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
38
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
39
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/bin/instapush
CHANGED
File without changes
|
data/instapush.gemspec
CHANGED
@@ -4,10 +4,17 @@ require 'json'
|
|
4
4
|
|
5
5
|
module Instapush
|
6
6
|
class Application
|
7
|
-
def initialize(app_id, app_secret)
|
7
|
+
def initialize(app_id, app_secret, opts = {})
|
8
|
+
default_options = {
|
9
|
+
:use_ssl => false
|
10
|
+
}
|
11
|
+
@options = default_options.merge(opts)
|
12
|
+
|
8
13
|
@app_id = app_id
|
9
14
|
@app_secret = app_secret
|
10
|
-
|
15
|
+
|
16
|
+
scheme = @options[:use_ssl] ? 'https' : 'http'
|
17
|
+
@api_url = "#{scheme}://api.instapush.im/post"
|
11
18
|
end
|
12
19
|
|
13
20
|
def push(event)
|
@@ -17,6 +24,10 @@ module Instapush
|
|
17
24
|
|
18
25
|
uri = URI.parse(@api_url)
|
19
26
|
http = Net::HTTP.new(uri.host, uri.port)
|
27
|
+
|
28
|
+
http.use_ssl = @options[:use_ssl];
|
29
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
30
|
+
|
20
31
|
request = Net::HTTP::Post.new(uri.request_uri)
|
21
32
|
request.body= data.to_json
|
22
33
|
request.content_type = 'application/json'
|
data/lib/instapush/version.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Instapush::Application do
|
4
|
+
before(:each) do
|
5
|
+
@event = Instapush::Event.new 'event'
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should fail on invalid push argument' do
|
9
|
+
app = Instapush::Application.new 'id', 'secret'
|
10
|
+
lambda { app.push('foo')}.should raise_error(ArgumentError)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should use HTTP by default' do
|
14
|
+
app = Instapush::Application.new 'id', 'secret'
|
15
|
+
stub_request(:post, "http://api.instapush.im/post")
|
16
|
+
|
17
|
+
app.push @event
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should use HTTPS if requested' do
|
21
|
+
app = Instapush::Application.new 'id', 'secret', use_ssl: true
|
22
|
+
stub_request(:post, "https://api.instapush.im/post").with(body: {})
|
23
|
+
|
24
|
+
app.push @event
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should send the event name in the body' do
|
28
|
+
app = Instapush::Application.new 'id', 'secret'
|
29
|
+
stub_request(:post, "api.instapush.im/post").with(:body => "{\"event\":\"event\",\"trackers\":{}}")
|
30
|
+
|
31
|
+
app.push @event
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should send the app id as POST header' do
|
35
|
+
app = Instapush::Application.new 'id', 'secret'
|
36
|
+
stub_request(:post, "api.instapush.im/post").with(:body => "{\"event\":\"event\",\"trackers\":{}}", :headers => { 'X-INSTAPUSH-APPSECRET' => 'secret' })
|
37
|
+
|
38
|
+
app.push @event
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should send the app secret as POST header' do
|
43
|
+
app = Instapush::Application.new 'id', 'secret'
|
44
|
+
stub_request(:post, "api.instapush.im/post").with(:body => "{\"event\":\"event\",\"trackers\":{}}", :headers => { 'X-INSTAPUSH-APPID' => 'id' })
|
45
|
+
|
46
|
+
app.push @event
|
47
|
+
end
|
48
|
+
end
|
data/spec/event_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Instapush::Event do
|
4
|
+
it 'should take a name as parameter' do
|
5
|
+
event = Instapush::Event.new 'event'
|
6
|
+
event.name.should eq('event')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should accept a hash of trackers' do
|
10
|
+
event = Instapush::Event.new 'event'
|
11
|
+
data = { a: 5, b: 7 }
|
12
|
+
event.tracker= data
|
13
|
+
|
14
|
+
event.tracker.should equal(data)
|
15
|
+
end
|
16
|
+
end
|
data/spec/instapush_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instapush-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabian Becker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Instapush.im allows you to send push notifications to your mobile device.
|
56
70
|
This library provides a simple API wrapper for the service.
|
57
71
|
email:
|
@@ -74,6 +88,8 @@ files:
|
|
74
88
|
- lib/instapush/application.rb
|
75
89
|
- lib/instapush/event.rb
|
76
90
|
- lib/instapush/version.rb
|
91
|
+
- spec/application_spec.rb
|
92
|
+
- spec/event_spec.rb
|
77
93
|
- spec/instapush_spec.rb
|
78
94
|
- spec/spec_helper.rb
|
79
95
|
homepage: http://github.com/halfdan/instapush
|
@@ -101,5 +117,7 @@ signing_key:
|
|
101
117
|
specification_version: 4
|
102
118
|
summary: Instapush.im API Wrapper
|
103
119
|
test_files:
|
120
|
+
- spec/application_spec.rb
|
121
|
+
- spec/event_spec.rb
|
104
122
|
- spec/instapush_spec.rb
|
105
123
|
- spec/spec_helper.rb
|