one_signal 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.txt +3 -0
- data/README.md +24 -0
- data/example.rb +7 -1
- data/lib/one_signal/player.rb +18 -2
- data/lib/one_signal/version.rb +1 -1
- data/one_signal.gemspec +1 -0
- data/test/player_test.rb +13 -3
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f71bd3eedf66b5c71a541f39bd3ad8a174516b9c
|
4
|
+
data.tar.gz: 3c732a489790f92c17f18f615b78cf8c21257c1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9ecaed3d48b162d43a36377240abef1a9ef124f8d443c5aa4bf7bb9dc66eac29b39f26b8248654beb0fff94434bb64a451312da5d25c3d396dad746289017a0
|
7
|
+
data.tar.gz: 389c5837037151b6af49f430dd95b9836c2648bad515ef09c329883c9f4630586db2c8d3cae1264073342bf473c0c6a0d8a2e9da526987a710950db4fb6b389b
|
data/CHANGELOG.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# onesignal-ruby
|
2
|
+
OneSignal Ruby bindings
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
```
|
7
|
+
gem install one_signal
|
8
|
+
```
|
9
|
+
|
10
|
+
## Basic usage
|
11
|
+
|
12
|
+
See basic examples in [example.rb](/example.rb)
|
13
|
+
|
14
|
+
## Changes
|
15
|
+
|
16
|
+
See [CHANGELOG.txt](CHANGELOG.txt)
|
17
|
+
|
18
|
+
## Contributors
|
19
|
+
|
20
|
+
They are [listed here](https://github.com/tbalthazar/onesignal-ruby/graphs/contributors), thanks to them!
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
Please see [LICENSE](/LICENSE) for licensing details.
|
data/example.rb
CHANGED
@@ -98,6 +98,12 @@ def notify
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
+
def csv_export
|
102
|
+
response = OneSignal::Player.csv_export(app_id: @app_id)
|
103
|
+
puts response.body
|
104
|
+
end
|
105
|
+
|
101
106
|
# player_id = create_player
|
102
107
|
# update_player(id: player_id)
|
103
|
-
notify
|
108
|
+
# notify
|
109
|
+
csv_export
|
data/lib/one_signal/player.rb
CHANGED
@@ -2,11 +2,27 @@ module OneSignal
|
|
2
2
|
|
3
3
|
class Player < OneSignal
|
4
4
|
|
5
|
+
def self.csv_export(app_id:)
|
6
|
+
uri_string = @@base_uri
|
7
|
+
uri_string += "/players/csv_export"
|
8
|
+
uri = URI.parse(uri_string)
|
9
|
+
|
10
|
+
response = send_post_request(uri: uri, body: {app_id: app_id})
|
11
|
+
|
12
|
+
ensure_http_status(response: response,
|
13
|
+
status: '200',
|
14
|
+
method_name: 'CSV Export',
|
15
|
+
uri: uri,
|
16
|
+
params: {})
|
17
|
+
|
18
|
+
return response
|
19
|
+
end
|
20
|
+
|
5
21
|
def self.create(params: {})
|
6
22
|
uri_string = @@base_uri
|
7
23
|
uri_string += "/players"
|
8
24
|
uri = URI.parse(uri_string)
|
9
|
-
|
25
|
+
|
10
26
|
response = send_post_request(uri: uri, body: params)
|
11
27
|
|
12
28
|
ensure_http_status(response: response,
|
@@ -23,7 +39,7 @@ module OneSignal
|
|
23
39
|
uri_string += "/players"
|
24
40
|
uri_string += "/#{id}"
|
25
41
|
uri = URI.parse(uri_string)
|
26
|
-
|
42
|
+
|
27
43
|
response = send_put_request(uri: uri, body: params)
|
28
44
|
|
29
45
|
ensure_http_status(response: response,
|
data/lib/one_signal/version.rb
CHANGED
data/one_signal.gemspec
CHANGED
@@ -6,6 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.add_development_dependency 'rake', '~> 10.4'
|
7
7
|
s.add_development_dependency 'mocha', '~> 1.1'
|
8
8
|
s.add_development_dependency 'dotenv', '~> 2.0'
|
9
|
+
s.add_development_dependency 'minitest'
|
9
10
|
s.name = 'one_signal'
|
10
11
|
s.version = OneSignal::VERSION
|
11
12
|
s.summary = "A library which implements the OneSignal API"
|
data/test/player_test.rb
CHANGED
@@ -5,7 +5,8 @@ class PlayerTest < MiniTest::Test
|
|
5
5
|
def setup
|
6
6
|
base_url = "https://onesignal.com/api/v1/players"
|
7
7
|
@create_uri = URI.parse(base_url)
|
8
|
-
|
8
|
+
@csv_export_uri = URI.parse(base_url + "/csv_export")
|
9
|
+
|
9
10
|
@player_id = "fake-id-123"
|
10
11
|
@update_uri = URI.parse(base_url + "/#{@player_id}")
|
11
12
|
|
@@ -17,7 +18,7 @@ class PlayerTest < MiniTest::Test
|
|
17
18
|
OneSignal::OneSignal.api_key = @api_key
|
18
19
|
end
|
19
20
|
|
20
|
-
def test_create_raises_error
|
21
|
+
def test_create_raises_error
|
21
22
|
response = mock_response_ko
|
22
23
|
OneSignal::OneSignal.expects(:send_post_request)
|
23
24
|
.with(uri: @create_uri, body: @params)
|
@@ -27,6 +28,15 @@ class PlayerTest < MiniTest::Test
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
31
|
+
def test_csv_export
|
32
|
+
@app_id = "foobar"
|
33
|
+
response = mock_response_ok
|
34
|
+
OneSignal::OneSignal.expects(:send_post_request)
|
35
|
+
.with(uri: @csv_export_uri, body: {app_id: @app_id})
|
36
|
+
.returns(response)
|
37
|
+
assert_equal response, OneSignal::Player.csv_export(app_id: @app_id)
|
38
|
+
end
|
39
|
+
|
30
40
|
def test_create
|
31
41
|
response = mock_response_ok
|
32
42
|
OneSignal::OneSignal.expects(:send_post_request)
|
@@ -35,7 +45,7 @@ class PlayerTest < MiniTest::Test
|
|
35
45
|
assert_equal response, OneSignal::Player.create(params: @params)
|
36
46
|
end
|
37
47
|
|
38
|
-
def test_update_raises_error
|
48
|
+
def test_update_raises_error
|
39
49
|
response = mock_response_ko
|
40
50
|
OneSignal::OneSignal.expects(:send_put_request)
|
41
51
|
.with(uri: @update_uri, body: @params)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: one_signal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Balthazar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: A library which implements the OneSignal API.
|
70
84
|
email: thomas@balthazar.info
|
71
85
|
executables: []
|
@@ -73,8 +87,10 @@ extensions: []
|
|
73
87
|
extra_rdoc_files: []
|
74
88
|
files:
|
75
89
|
- ".gitignore"
|
90
|
+
- CHANGELOG.txt
|
76
91
|
- Gemfile
|
77
92
|
- LICENSE
|
93
|
+
- README.md
|
78
94
|
- Rakefile
|
79
95
|
- example.rb
|
80
96
|
- lib/one_signal.rb
|