Module: OneSignal
- Defined in:
- lib/onesignal.rb,
lib/onesignal/client.rb,
lib/onesignal/filter.rb,
lib/onesignal/sounds.rb,
lib/onesignal/buttons.rb,
lib/onesignal/segment.rb,
lib/onesignal/version.rb,
lib/onesignal/auto_map.rb,
lib/onesignal/commands.rb,
lib/onesignal/responses.rb,
lib/onesignal/attachments.rb,
lib/onesignal/notification.rb,
lib/onesignal/configuration.rb,
lib/onesignal/included_targets.rb,
lib/onesignal/responses/player.rb,
lib/onesignal/commands/csv_export.rb,
lib/onesignal/responses/csv_export.rb,
lib/onesignal/commands/base_command.rb,
lib/onesignal/commands/fetch_player.rb,
lib/onesignal/notification/contents.rb,
lib/onesignal/notification/headings.rb,
lib/onesignal/commands/fetch_players.rb,
lib/onesignal/responses/notification.rb,
lib/onesignal/responses/base_response.rb,
lib/onesignal/commands/fetch_notification.rb,
lib/onesignal/commands/create_notification.rb,
lib/onesignal/commands/fetch_notifications.rb
Defined Under Namespace
Modules: AutoMap, Commands, Responses
Classes: Attachments, Buttons, Client, Configuration, Filter, IncludedTargets, InvalidError, Notification, Segment, Sounds
Constant Summary
collapse
- VERSION =
'0.3.1'
- API_VERSION =
'v1'
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
76
77
78
|
# File 'lib/onesignal.rb', line 76
def config
@config ||= Configuration.new
end
|
12
13
14
|
# File 'lib/onesignal.rb', line 12
def configure
yield config
end
|
.csv_export(params = {}) ⇒ Object
.fetch_notification(notification_id) ⇒ Object
.fetch_notifications(page_limit: 50, page_offset: 0, kind: nil) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/onesignal.rb', line 30
def fetch_notifications(page_limit: 50, page_offset: 0, kind: nil)
return unless OneSignal.config.active
Enumerator.new() do |yielder|
limit = page_limit
offset = page_offset
fetched = Commands::FetchNotifications.call limit, offset, kind
parsed = JSON.parse(fetched.body)
total_count = parsed["total_count"]
max_pages = (total_count / limit.to_f).ceil
loop do
parsed['notifications'].each do |notification|
yielder << Responses::Notification.from_json(notification)
end
offset += 1
break if offset >= max_pages
fetched = Commands::FetchNotifications.call limit, offset*limit, kind
parsed = JSON.parse(fetched.body)
end
end
end
|
.fetch_player(player_id) ⇒ Object
.send_notification(notification) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/onesignal.rb', line 16
def send_notification notification
return unless OneSignal.config.active
created = Commands::CreateNotification.call notification
fetch_notification(JSON.parse(created.body)['id'])
end
|