onesignal-ruby 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cc04a0b28c94e926c36f1edde7ed3d651474f2aebf47f2361b612beb329bb01
4
- data.tar.gz: 1d2eb9bddde95ce61315bdc5913e035305ad1b8e507c0d6fcc6a68be16a92702
3
+ metadata.gz: b152a9f9718b89b2e82e057aa1574e0376f10f3a20149e93113c97cb23d40680
4
+ data.tar.gz: c64d9e07ec9c528ba2104d72c538390e97f5fc6befe6d488cf7eb44146aafc38
5
5
  SHA512:
6
- metadata.gz: 528ff50448ce553e2bdc2c2f920dcd160208db6648caf1c2c0ad635279bce099c965c33b7930503a274d2cd7c05c42a498f873dfa4fd365ae69beae970c06b5c
7
- data.tar.gz: '0083d2a4996ef9cba0bcbbac3de6cb1dbe32ded69777e8512e0665be5647a4d5f349c272a781115bf814d987f108f7ed49f80942a29d7f7127b8870cd1ee0f61'
6
+ metadata.gz: a6e7d702153b4d487b94299887254287d8dc1f2d09db79002cddc4ec30b19eed1152f713c81a2ebc59a42263766e6f81da21b3a77161f22e1ab6ff6dc955282a
7
+ data.tar.gz: 8b99a40ce488772517310b767f26913b27a5b4a22205652e5435e55192551cab81f200adca0bf02942f1f2f688edf68900f98f31232026743943c5ce8b6c8420
@@ -0,0 +1,23 @@
1
+ Hello there! Welcome. Thank you for your contribution!
2
+
3
+ Here you can describe the code you are submitting. You can also reference related issues or other
4
+ pull requests that might add context.
5
+
6
+ Remember to assign the pull request to a [CODEOWNER](../CODEOWNERS) for review.
7
+
8
+ **ALWAYS** open PRs targeting [develop](https://github.com/mikamai/onesignal-ruby/tree/develop), as it is our mainline branch. Master is only used to cut stable releases.
9
+
10
+ ## Type of change
11
+
12
+ Please delete options that are not relevant.
13
+
14
+ - [ ] Bug fix (non-breaking change which fixes an issue)
15
+ - [ ] New feature (non-breaking change which adds functionality)
16
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
17
+ - [ ] This change requires a documentation update
18
+
19
+ ## Checklist
20
+
21
+ - [ ] I have added tests for each new piece of code I added, or updated existing tests if I changed some existing code
22
+ - [ ] I have added the relevant entry in the `Unreleased` section of the CHANGELOG file
23
+ - [ ] I have made corresponding changes to the documentation (namely the README file)
data/CHANGELOG.md ADDED
@@ -0,0 +1,57 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.6.0] - 2021-10-21
10
+ ### Added
11
+ - Support for external_player_id and for deleting a Player thanks to [@reachire-smendola] ([#35](https://github.com/mikamai/onesignal-ruby/pull/35))
12
+ - Support for icons thanks to [@mtayllan] ([#33](https://github.com/mikamai/onesignal-ruby/pull/33))
13
+
14
+
15
+ ## [0.5.0] - 2021-05-17
16
+ ### Added
17
+ - Support for the email_subject field thanks to [@regedarek] ([#26](https://github.com/mikamai/onesignal-ruby/pull/26))
18
+ with tests contributed by [@martinjaimem] ([#28](https://github.com/mikamai/onesignal-ruby/pull/28))
19
+ - Support for the email_body field thanks to [@martinjaimem] ([#29](https://github.com/mikamai/onesignal-ruby/pull/29))
20
+
21
+ ### Changed
22
+ - Bump Faraday to ~> 1.0 thanks to [@jongirard] (#25)
23
+
24
+ ## [0.4.0] - 2021-01-19
25
+ ### Added
26
+ - Support for OneSignal action buttons thanks to [@jongirard] ([#15](https://github.com/mikamai/onesignal-ruby/pull/15))
27
+ - Support for Ruby 2.7 thanks to [@hotatekaoru] ([#13](https://github.com/mikamai/onesignal-ruby/pull/13))
28
+ - Support for Rails 6 thanks to [@chrismaximin] ([#11](https://github.com/mikamai/onesignal-ruby/pull/11))
29
+ - API call for fetching all notifications thanks to [@rgould] ([#7](https://github.com/mikamai/onesignal-ruby/pull/7))
30
+ - CSV export thanks to [@joecorcoran] ([#6](https://github.com/mikamai/onesignal-ruby/pull/6))
31
+
32
+ ### Changed
33
+ - Bump bundler to ~> 2.0
34
+
35
+ ## [0.3.0] - 2019-01-08
36
+ ## Added
37
+ - Support for specific device targets for notifications, thanks to [@gabriel-dehan].
38
+
39
+ ## [0.2.0] - 2019-01-07
40
+ First public release. This version is the first publicly available on [RubyGems](https://rubygems.org/gems/onesignal-ruby).
41
+
42
+ [Unreleased]: https://github.com/mikamai/onesignal-ruby/compare/0.6.0...HEAD
43
+ [0.6.0]: https://github.com/mikamai/onesignal-ruby/compare/0.5.0...0.6.0
44
+ [0.5.0]: https://github.com/mikamai/onesignal-ruby/compare/0.4.0...0.5.0
45
+ [0.4.0]: https://github.com/mikamai/onesignal-ruby/compare/0.3.0...0.4.0
46
+ [0.3.0]: https://github.com/mikamai/onesignal-ruby/compare/0.2.0...0.3.0
47
+ [0.2.0]: https://github.com/mikamai/onesignal-ruby/releases/tag/0.2.0
48
+
49
+ [@chrismaximin]: https://github.com/chrismaximin
50
+ [@gabriel-dehan]: https://github.com/gabriel-dehan
51
+ [@hotatekaoru]: https://github.com/hotatekaoru
52
+ [@joecorcoran]: https://github.com/joecorcoran
53
+ [@jongirard]: https://github.com/jongirard
54
+ [@martinjaimem]: https://github.com/martinjaimem
55
+ [@regedarek]: https://github.com/regedarek
56
+ [@rgould]: https://github.com/rgould
57
+ [@reachire-smendola]: https://github.com/reachire-smendola
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/onesignal-ruby.svg)](https://badge.fury.io/rb/onesignal-ruby)
3
3
  [![CircleCI](https://circleci.com/gh/mikamai/onesignal-ruby.svg?style=svg)](https://circleci.com/gh/mikamai/onesignal-ruby)
4
4
 
5
- A simple, pure Ruby client to the [OneSignal](https://onesignal.com/apps/22bc6dec-5150-4d6d-8628-377259d2dd14/segments) API.
5
+ A simple, pure Ruby client to the [OneSignal Push Notification API](https://onesignal.com/). OneSignal provides a self-serve customer engagement solution for Push Notifications, Email, SMS & In-App.
6
6
 
7
7
  ## Installation
8
8
 
@@ -137,6 +137,13 @@ player = OneSignal.fetch_player(player_id)
137
137
  # => #<OneSignal::Responses::Player>
138
138
  ```
139
139
 
140
+ ### Delete players
141
+ You can delete a single player by its ID.
142
+ ```ruby
143
+ OneSignal.delete_player(player_id)
144
+ #<OneSignal::Responses::Player:0x000056062f397d18 @attributes={}>
145
+ ```
146
+
140
147
  ### Filters
141
148
 
142
149
  Filters can be created with a simple DSL. It closely matches the [JSON reference](https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters), with a few touches of syntax
@@ -192,6 +199,23 @@ included_targets = OneSignal::IncludedTargets.new(include_player_ids: 'test-id-1
192
199
  OneSignal::Notification.new(included_targets: included_targets)
193
200
  ```
194
201
 
202
+ ### Icons
203
+ You can customize notification icons by passing a `OneSignal::Icons` object.
204
+ ```ruby
205
+ icons = OneSignal::Icons.new(
206
+ small_icon: 'image URL',
207
+ huawei_small_icon: 'image URL',
208
+ large_icon: 'image URL',
209
+ huawei_large_icon: 'image URL',
210
+ adm_small_icon: 'image URL',
211
+ adm_large_icon: 'image URL',
212
+ chrome_web_icon: 'image URL',
213
+ firefox_icon: 'image URL',
214
+ chrome_icon: 'image URL'
215
+ )
216
+ OneSignal::Notification.new(icons: icons)
217
+ ```
218
+
195
219
  **WARNING**
196
220
  Passing `include_player_ids` alongside other params is prohibited and will raise an `ArgumentError`.
197
221
  Either use `include_player_ids` or use the other params.
@@ -213,6 +237,8 @@ This repo is managed following the [Git Flow](https://danielkummer.github.io/git
213
237
  - `hotfix/my-awesome-fix` are special branches dedicated to bugfixes that compromise the library functionality. They are merged
214
238
  in both master and develop and then deleted.
215
239
 
240
+ [CHANGELOG](CHANGELOG.md) entries MUST be added for every change made to the source code.
241
+
216
242
  ## License
217
243
 
218
244
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,72 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://onesignal.com/api/v1/players/?app_id
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.2
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic test
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Thu, 28 Jun 2018 15:30:58 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Set-Cookie:
34
+ - __cfduid=d162ae07cbc70fafa075f6d10a6694cc61530199858; expires=Fri, 28-Jun-19
35
+ 15:30:58 GMT; path=/; domain=.onesignal.com; HttpOnly
36
+ Status:
37
+ - 200 OK
38
+ Cache-Control:
39
+ - max-age=0, private, must-revalidate
40
+ Access-Control-Allow-Origin:
41
+ - "*"
42
+ X-Xss-Protection:
43
+ - 1; mode=block
44
+ X-Request-Id:
45
+ - 768dd4da-9f24-4a93-8a1b-3efbc3bf22b2
46
+ Access-Control-Allow-Headers:
47
+ - SDK-Version
48
+ Etag:
49
+ - W/"cee038b261c95e403233f1ada96658e3"
50
+ X-Frame-Options:
51
+ - SAMEORIGIN
52
+ X-Runtime:
53
+ - '0.029141'
54
+ X-Content-Type-Options:
55
+ - nosniff
56
+ X-Powered-By:
57
+ - Phusion Passenger 5.3.2
58
+ Expect-Ct:
59
+ - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
60
+ Server:
61
+ - cloudflare
62
+ Cf-Ray:
63
+ - 4321329ccab1430a-MXP
64
+ body:
65
+ encoding: ASCII-8BIT
66
+ string: '{"total_count":8,"offset":0,"limit":300,"players":[{"id":"14c8141f-d57d-4652-8911-960a00ff14fa","identifier":"52812f0ca9b3cc1c1f6a13fd1467c3a2a9f7ef3db5ee56cb951b00fb6bb78665","session_count":10,"language":"it","timezone":7200,"game_version":"1","device_os":"11.4","device_type":0,"device_model":"iPhone10,5","ad_id":"7A30EDB9-A4EA-404E-BA5E-2AEA86C74AA7","tags":{},"last_active":1530184068,"playtime":1219,"amount_spent":0.0,"created_at":1530177751,"invalid_identifier":false,"badge_count":0,"sdk":"020805","test_type":1,"ip":null},{"id":"16c0eee0-edc0-4630-8792-1c432a2e7da1","identifier":null,"session_count":2,"language":"en","timezone":7200,"game_version":"1","device_os":"7.1.2","device_type":1,"device_model":"MotoG3","ad_id":null,"tags":{},"last_active":1530192672,"playtime":0,"amount_spent":0.0,"created_at":1530192553,"invalid_identifier":true,"badge_count":0,"sdk":"030901","test_type":null,"ip":null},{"id":"066e3db6-1ed1-49f0-9340-624327e3faf8","identifier":null,"session_count":1,"language":"en","timezone":7200,"game_version":"1","device_os":"7.1.2","device_type":1,"device_model":"MotoG3","ad_id":null,"tags":{},"last_active":1530193737,"playtime":0,"amount_spent":0.0,"created_at":1530193737,"invalid_identifier":true,"badge_count":0,"sdk":"030901","test_type":null,"ip":null},{"id":"cf435718-f137-4fd8-ba43-b9ada7e88846","identifier":null,"session_count":1,"language":"en","timezone":7200,"game_version":"1","device_os":"7.1.2","device_type":1,"device_model":"MotoG3","ad_id":null,"tags":{},"last_active":1530194294,"playtime":0,"amount_spent":0.0,"created_at":1530194294,"invalid_identifier":true,"badge_count":0,"sdk":"030901","test_type":null,"ip":null},{"id":"ba4b2ab3-cc89-4bd6-8c1a-9f69e7a2aa55","identifier":null,"session_count":1,"language":"en","timezone":7200,"game_version":"1","device_os":"7.1.2","device_type":1,"device_model":"MotoG3","ad_id":null,"tags":{},"last_active":1530197017,"playtime":0,"amount_spent":0.0,"created_at":1530197017,"invalid_identifier":true,"badge_count":0,"sdk":"030901","test_type":null,"ip":null},{"id":"152c5092-beb7-4b54-a0c0-168460ff41c0","identifier":null,"session_count":1,"language":"en","timezone":0,"game_version":"1","device_os":"8.1.0","device_type":1,"device_model":"Android
67
+ SDK built for x86","ad_id":null,"tags":{},"last_active":1530198026,"playtime":0,"amount_spent":0.0,"created_at":1530198026,"invalid_identifier":true,"badge_count":0,"sdk":"030901","test_type":null,"ip":null},{"id":"16421e68-fa8f-4072-82db-2d2d1765c317","identifier":null,"session_count":1,"language":"en","timezone":0,"game_version":"1","device_os":"8.1.0","device_type":1,"device_model":"Android
68
+ SDK built for x86","ad_id":null,"tags":{},"last_active":1530198244,"playtime":0,"amount_spent":0.0,"created_at":1530198244,"invalid_identifier":true,"badge_count":0,"sdk":"030901","test_type":null,"ip":null},{"id":"e818b09c-3eca-41be-b0ee-8379cab19d93","identifier":null,"session_count":1,"language":"en","timezone":0,"game_version":"1","device_os":"8.1.0","device_type":1,"device_model":"Android
69
+ SDK built for x86","ad_id":null,"tags":{},"last_active":1530199447,"playtime":0,"amount_spent":0.0,"created_at":1530199447,"invalid_identifier":true,"badge_count":0,"sdk":"030901","test_type":null,"ip":null}]}'
70
+ http_version:
71
+ recorded_at: Thu, 28 Jun 2018 15:30:58 GMT
72
+ recorded_with: VCR 4.0.0
@@ -41,6 +41,10 @@ module OneSignal
41
41
  get "players/#{player_id}"
42
42
  end
43
43
 
44
+ def delete_player player_id
45
+ delete "players/#{player_id}"
46
+ end
47
+
44
48
  def csv_export extra_fields: nil, last_active_since: nil, segment_name: nil
45
49
  post "players/csv_export?app_id=#{@app_id}",
46
50
  extra_fields: extra_fields,
@@ -56,6 +60,15 @@ module OneSignal
56
60
  body
57
61
  end
58
62
 
63
+ def delete url
64
+ res = @conn.delete do |req|
65
+ req.url url, app_id: @app_id
66
+ req.headers['Authorization'] = "Basic #{@api_key}"
67
+ end
68
+
69
+ handle_errors res
70
+ end
71
+
59
72
  def post url, body
60
73
  res = @conn.post do |req|
61
74
  req.url url
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OneSignal
4
+ module Commands
5
+ class DeletePlayer < BaseCommand
6
+ def initialize player_id
7
+ @player_id = player_id
8
+ end
9
+
10
+ def call
11
+ client.delete_player @player_id
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OneSignal
4
+ class Icons
5
+ attr_reader :small_icon, :huawei_small_icon, :large_icon, :huawei_large_icon, :adm_small_icon,
6
+ :adm_large_icon, :chrome_web_icon, :firefox_icon, :chrome_icon
7
+
8
+ def initialize **params
9
+ @small_icon = params[:small_icon]
10
+ @huawei_small_icon = params[:huawei_small_icon]
11
+ @large_icon = params[:large_icon]
12
+ @huawei_large_icon = params[:huawei_large_icon]
13
+ @adm_small_icon = params[:adm_small_icon]
14
+ @adm_large_icon = params[:adm_large_icon]
15
+ @chrome_web_icon = params[:chrome_web_icon]
16
+ @firefox_icon = params[:firefox_icon]
17
+ @chrome_icon = params[:chrome_icon]
18
+ end
19
+
20
+ def as_json options = nil
21
+ {
22
+ 'small_icon' => @small_icon,
23
+ 'huawei_small_icon' => @huawei_small_icon,
24
+ 'large_icon' => @large_icon,
25
+ 'huawei_large_icon' => @huawei_large_icon,
26
+ 'adm_small_icon' => @adm_small_icon,
27
+ 'adm_large_icon' => @adm_large_icon,
28
+ 'chrome_web_icon' => @chrome_web_icon,
29
+ 'firefox_icon' => @firefox_icon,
30
+ 'chrome_icon' => @chrome_icon
31
+ }
32
+ end
33
+ end
34
+ end
@@ -7,7 +7,7 @@ module OneSignal
7
7
  class Notification
8
8
  attr_reader :contents, :headings, :template_id, :included_segments, :excluded_segments,
9
9
  :included_targets, :email_subject, :send_after, :attachments, :sounds, :buttons,
10
- :email_body
10
+ :email_body, :icons, :external_id
11
11
 
12
12
  def initialize **params
13
13
  unless params.include?(:contents) || params.include?(:template_id)
@@ -27,15 +27,18 @@ module OneSignal
27
27
  @filters = params[:filters]
28
28
  @sounds = params[:sounds]
29
29
  @buttons = params[:buttons]
30
+ @icons = params[:icons]
31
+ @external_id = params[:external_id]
30
32
  end
31
33
 
32
34
  def as_json options = {}
33
35
  super(options)
34
- .except('attachments', 'sounds', 'included_targets')
36
+ .except('attachments', 'sounds', 'included_targets', 'icons')
35
37
  .merge(@attachments&.as_json(options) || {})
36
38
  .merge(@sounds&.as_json(options) || {})
37
39
  .merge(@buttons&.as_json(options) || {})
38
40
  .merge(@included_targets&.as_json(options) || {})
41
+ .merge(@icons&.as_json(options) || {})
39
42
  .select { |_k, v| v.present? }
40
43
  end
41
44
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OneSignal
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  API_VERSION = 'v1'
6
6
  end
data/lib/onesignal.rb CHANGED
@@ -59,6 +59,13 @@ module OneSignal
59
59
  Responses::Player.from_json fetched.body
60
60
  end
61
61
 
62
+ def delete_player player_id
63
+ return unless OneSignal.config.active
64
+
65
+ fetched = Commands::DeletePlayer.call player_id
66
+ Responses::Player.from_json fetched.body
67
+ end
68
+
62
69
  def fetch_players
63
70
  return unless OneSignal.config.active
64
71
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onesignal-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Joliveau
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -198,10 +198,12 @@ files:
198
198
  - ".circleci/config.yml"
199
199
  - ".editorconfig"
200
200
  - ".envrc"
201
+ - ".github/pull_request_template.md"
201
202
  - ".gitignore"
202
203
  - ".rspec"
203
204
  - ".rubocop.yml"
204
205
  - ".ruby-version"
206
+ - CHANGELOG.md
205
207
  - CODEOWNERS
206
208
  - CODE_OF_CONDUCT.md
207
209
  - Gemfile
@@ -211,6 +213,7 @@ files:
211
213
  - bin/console
212
214
  - bin/setup
213
215
  - fixtures/vcr_cassettes/os-csv-export.yml
216
+ - fixtures/vcr_cassettes/os-delete-player.yml
214
217
  - fixtures/vcr_cassettes/os-fetch-noti.yml
215
218
  - fixtures/vcr_cassettes/os-fetch-notifications.yml
216
219
  - fixtures/vcr_cassettes/os-fetch-player.yml
@@ -227,12 +230,14 @@ files:
227
230
  - lib/onesignal/commands/base_command.rb
228
231
  - lib/onesignal/commands/create_notification.rb
229
232
  - lib/onesignal/commands/csv_export.rb
233
+ - lib/onesignal/commands/delete_player.rb
230
234
  - lib/onesignal/commands/fetch_notification.rb
231
235
  - lib/onesignal/commands/fetch_notifications.rb
232
236
  - lib/onesignal/commands/fetch_player.rb
233
237
  - lib/onesignal/commands/fetch_players.rb
234
238
  - lib/onesignal/configuration.rb
235
239
  - lib/onesignal/filter.rb
240
+ - lib/onesignal/icons.rb
236
241
  - lib/onesignal/included_targets.rb
237
242
  - lib/onesignal/notification.rb
238
243
  - lib/onesignal/notification/contents.rb