onesignal-ruby-rails6 0.3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +14 -0
  3. data/.github/workflows/gempush.yml +41 -0
  4. data/.github/workflows/ruby.yml +20 -0
  5. data/.gitignore +17 -0
  6. data/.rspec +3 -0
  7. data/.rubocop.yml +182 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +12 -0
  10. data/Gemfile.lock +85 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +211 -0
  13. data/Rakefile +8 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/fixtures/vcr_cassettes/os-csv-export.yml +135 -0
  17. data/fixtures/vcr_cassettes/os-fetch-noti.yml +76 -0
  18. data/fixtures/vcr_cassettes/os-fetch-player.yml +72 -0
  19. data/fixtures/vcr_cassettes/os-fetch-players.yml +72 -0
  20. data/fixtures/vcr_cassettes/os-send-noti.yml +145 -0
  21. data/lib/onesignal.rb +60 -0
  22. data/lib/onesignal/attachments.rb +27 -0
  23. data/lib/onesignal/auto_map.rb +13 -0
  24. data/lib/onesignal/autoloader.rb +7 -0
  25. data/lib/onesignal/client.rb +81 -0
  26. data/lib/onesignal/commands.rb +7 -0
  27. data/lib/onesignal/commands/autoloader.rb +7 -0
  28. data/lib/onesignal/commands/base_command.rb +23 -0
  29. data/lib/onesignal/commands/create_notification.rb +15 -0
  30. data/lib/onesignal/commands/csv_export.rb +15 -0
  31. data/lib/onesignal/commands/fetch_notification.rb +15 -0
  32. data/lib/onesignal/commands/fetch_player.rb +15 -0
  33. data/lib/onesignal/commands/fetch_players.rb +11 -0
  34. data/lib/onesignal/configuration.rb +19 -0
  35. data/lib/onesignal/filter.rb +140 -0
  36. data/lib/onesignal/included_targets.rb +47 -0
  37. data/lib/onesignal/notification.rb +37 -0
  38. data/lib/onesignal/notification/contents.rb +17 -0
  39. data/lib/onesignal/notification/headings.rb +17 -0
  40. data/lib/onesignal/responses.rb +7 -0
  41. data/lib/onesignal/responses/autoloader.rb +7 -0
  42. data/lib/onesignal/responses/base_response.rb +18 -0
  43. data/lib/onesignal/responses/csv_export.rb +18 -0
  44. data/lib/onesignal/responses/notification.rb +45 -0
  45. data/lib/onesignal/responses/player.rb +21 -0
  46. data/lib/onesignal/segment.rb +22 -0
  47. data/lib/onesignal/sounds.rb +39 -0
  48. data/lib/onesignal/version.rb +6 -0
  49. data/onesignal-ruby.gemspec +48 -0
  50. metadata +270 -0
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OneSignal
4
+ module Responses
5
+ # Example JSON
6
+ # {
7
+ # "id": '481a2734-6b7d-11e4-a6ea-4b53294fa671',
8
+ # "successful": 15,
9
+ # "failed": 1,
10
+ # "converted": 3,
11
+ # "remaining": 0,
12
+ # "queued_at": 1_415_914_655,
13
+ # "send_after": 1_415_914_655,
14
+ # "completed_at": 1_415_914_656,
15
+ # "url": 'https://yourWebsiteToOpen.com',
16
+ # "data": {
17
+ # "foo": 'bar',
18
+ # "your": 'custom metadata'
19
+ # },
20
+ # "canceled": false,
21
+ # "headings": {
22
+ # "en": 'English and default language heading',
23
+ # "es": 'Spanish language heading'
24
+ # },
25
+ # "contents": {
26
+ # "en": 'English language content',
27
+ # "es": 'Hola'
28
+ # }
29
+ # }
30
+ class Notification < BaseResponse
31
+ ATTRIBUTES_WHITELIST = %i[id successful failed converted remaining
32
+ queued_at send_after completed_at url data
33
+ canceled headings contents].freeze
34
+
35
+ def canceled?
36
+ canceled
37
+ end
38
+
39
+ def self.from_json json
40
+ body = json.is_a?(String) ? JSON.parse(json) : json
41
+ new(body)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OneSignal
4
+ module Responses
5
+ class Player < BaseResponse
6
+ ATTRIBUTES_WHITELIST = %i[id identifier session_count language timezone
7
+ game_version device_os device_type device_model tags
8
+ ad_id last_active playtime amount_spent created_at
9
+ invalid_identifier badge_count sdk test_type ip].freeze
10
+
11
+ def invalid_identifier?
12
+ invalid_identifier
13
+ end
14
+
15
+ def self.from_json json
16
+ body = json.is_a?(String) ? JSON.parse(json) : json
17
+ new(body)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OneSignal
4
+ class Segment
5
+ ALL_USERS = 'All'
6
+ ACTIVE_USERS = 'Active Users'
7
+ ENGAGED_USERS = 'Engaged Users'
8
+ INACTIVE_USERS = 'Inactive Users'
9
+
10
+ def initialize name:
11
+ @name = name
12
+ end
13
+
14
+ def as_json _options = nil
15
+ @name.to_s
16
+ end
17
+
18
+ def to_s
19
+ @name.to_s
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OneSignal
4
+ class Sounds
5
+ attr_reader :ios, :android, :amazon, :windows
6
+
7
+ def initialize ios: nil, android: nil, amazon: nil, windows: nil
8
+ validate ios: ios, windows: windows
9
+
10
+ @ios = ios
11
+ @android = android
12
+ @amazon = amazon
13
+ @windows = windows
14
+ end
15
+
16
+ def as_json options = nil
17
+ {
18
+ 'ios_sound' => @ios.as_json(options),
19
+ 'android_sound' => @android.as_json(options),
20
+ 'adm_sound' => @amazon.as_json(options),
21
+ 'wp_wns_sound' => @windows.as_json(options)
22
+ }
23
+ end
24
+
25
+ private
26
+
27
+ REGEX = /.*.\.\w*/.freeze
28
+
29
+ def validate ios: nil, windows: nil
30
+ ios_valid = !ios.nil? && (REGEX =~ ios).nil?
31
+ windows_valid = !windows.nil? && (REGEX =~ windows).nil?
32
+ raise InvalidError, "provide file extension for iOS: #{ios}" if ios_valid
33
+ raise InvalidError, "provide file extension for windows: #{ios}" if windows_valid
34
+ end
35
+ end
36
+
37
+ class InvalidError < StandardError
38
+ end
39
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OneSignal
4
+ VERSION = '0.3.0.1'
5
+ API_VERSION = 'v1'
6
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'onesignal/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'onesignal-ruby-rails6'
9
+ spec.version = OneSignal::VERSION
10
+ spec.authors = ['Matteo Joliveau']
11
+ spec.email = ['matteo.joliveau@mikamai.com']
12
+
13
+ spec.summary = 'Ruby wrapper to OneSignal API'
14
+ spec.description = 'Ruby wrapper to OneSignal API, mapping to Plain Old Ruby Objects'
15
+ spec.homepage = 'https://github.com/mikamai/onesignal-ruby'
16
+ spec.license = 'MIT'
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
22
+ else
23
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
24
+ 'public gem pushes.'
25
+ end
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ end
32
+ spec.bindir = 'exe'
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ['lib']
35
+
36
+ spec.add_development_dependency 'bundler', '~> 1.16'
37
+ spec.add_development_dependency 'dotenv', '~> 2.5'
38
+ spec.add_development_dependency 'factory_bot', '~> 4.11'
39
+ spec.add_development_dependency 'rake', '~> 10.0'
40
+ spec.add_development_dependency 'rspec', '~> 3.0'
41
+ spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4'
42
+ spec.add_development_dependency 'vcr', '~> 4.0', '>= 4.0.0'
43
+ spec.add_development_dependency 'webmock', '~> 3.4'
44
+
45
+ spec.add_runtime_dependency 'activesupport', '>= 5.0.0', '< 7'
46
+ spec.add_runtime_dependency 'faraday', '~> 0.15', '>= 0.15.4'
47
+ spec.add_runtime_dependency 'simple_command', '~> 0', '>= 0.0.9'
48
+ end
metadata ADDED
@@ -0,0 +1,270 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: onesignal-ruby-rails6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matteo Joliveau
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: factory_bot
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 4.0.0
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '4.0'
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: 4.0.0
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '4.0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: webmock
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.4'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3.4'
131
+ - !ruby/object:Gem::Dependency
132
+ name: activesupport
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: 5.0.0
138
+ - - "<"
139
+ - !ruby/object:Gem::Version
140
+ version: '7'
141
+ type: :runtime
142
+ prerelease: false
143
+ version_requirements: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 5.0.0
148
+ - - "<"
149
+ - !ruby/object:Gem::Version
150
+ version: '7'
151
+ - !ruby/object:Gem::Dependency
152
+ name: faraday
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '0.15'
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 0.15.4
161
+ type: :runtime
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '0.15'
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 0.15.4
171
+ - !ruby/object:Gem::Dependency
172
+ name: simple_command
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 0.0.9
181
+ type: :runtime
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: 0.0.9
191
+ description: Ruby wrapper to OneSignal API, mapping to Plain Old Ruby Objects
192
+ email:
193
+ - matteo.joliveau@mikamai.com
194
+ executables: []
195
+ extensions: []
196
+ extra_rdoc_files: []
197
+ files:
198
+ - ".editorconfig"
199
+ - ".github/workflows/gempush.yml"
200
+ - ".github/workflows/ruby.yml"
201
+ - ".gitignore"
202
+ - ".rspec"
203
+ - ".rubocop.yml"
204
+ - CODE_OF_CONDUCT.md
205
+ - Gemfile
206
+ - Gemfile.lock
207
+ - LICENSE.txt
208
+ - README.md
209
+ - Rakefile
210
+ - bin/console
211
+ - bin/setup
212
+ - fixtures/vcr_cassettes/os-csv-export.yml
213
+ - fixtures/vcr_cassettes/os-fetch-noti.yml
214
+ - fixtures/vcr_cassettes/os-fetch-player.yml
215
+ - fixtures/vcr_cassettes/os-fetch-players.yml
216
+ - fixtures/vcr_cassettes/os-send-noti.yml
217
+ - lib/onesignal.rb
218
+ - lib/onesignal/attachments.rb
219
+ - lib/onesignal/auto_map.rb
220
+ - lib/onesignal/autoloader.rb
221
+ - lib/onesignal/client.rb
222
+ - lib/onesignal/commands.rb
223
+ - lib/onesignal/commands/autoloader.rb
224
+ - lib/onesignal/commands/base_command.rb
225
+ - lib/onesignal/commands/create_notification.rb
226
+ - lib/onesignal/commands/csv_export.rb
227
+ - lib/onesignal/commands/fetch_notification.rb
228
+ - lib/onesignal/commands/fetch_player.rb
229
+ - lib/onesignal/commands/fetch_players.rb
230
+ - lib/onesignal/configuration.rb
231
+ - lib/onesignal/filter.rb
232
+ - lib/onesignal/included_targets.rb
233
+ - lib/onesignal/notification.rb
234
+ - lib/onesignal/notification/contents.rb
235
+ - lib/onesignal/notification/headings.rb
236
+ - lib/onesignal/responses.rb
237
+ - lib/onesignal/responses/autoloader.rb
238
+ - lib/onesignal/responses/base_response.rb
239
+ - lib/onesignal/responses/csv_export.rb
240
+ - lib/onesignal/responses/notification.rb
241
+ - lib/onesignal/responses/player.rb
242
+ - lib/onesignal/segment.rb
243
+ - lib/onesignal/sounds.rb
244
+ - lib/onesignal/version.rb
245
+ - onesignal-ruby.gemspec
246
+ homepage: https://github.com/mikamai/onesignal-ruby
247
+ licenses:
248
+ - MIT
249
+ metadata:
250
+ allowed_push_host: https://rubygems.org
251
+ post_install_message:
252
+ rdoc_options: []
253
+ require_paths:
254
+ - lib
255
+ required_ruby_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - ">="
258
+ - !ruby/object:Gem::Version
259
+ version: '0'
260
+ required_rubygems_version: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
265
+ requirements: []
266
+ rubygems_version: 3.0.1
267
+ signing_key:
268
+ specification_version: 4
269
+ summary: Ruby wrapper to OneSignal API
270
+ test_files: []