Class: OneSignal::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/onesignal/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(app_id, api_key, api_url) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/onesignal/client.rb', line 7

def initialize app_id, api_key, api_url
  @app_id = app_id
  @api_key = api_key
  @api_url = api_url
  @conn = ::Faraday.new(url: api_url) do |faraday|
    # faraday.response :logger do |logger|
    #   logger.filter(/(api_key=)(\w+)/, '\1[REMOVED]')
    #   logger.filter(/(Basic )(\w+)/, '\1[REMOVED]')
    # end
    faraday.adapter Faraday.default_adapter
  end
end

Instance Method Details

#create_notification(notification) ⇒ Object



20
21
22
# File 'lib/onesignal/client.rb', line 20

def create_notification notification
  post 'notifications', notification
end

#fetch_notification(notification_id) ⇒ Object



24
25
26
# File 'lib/onesignal/client.rb', line 24

def fetch_notification notification_id
  get "notifications/#{notification_id}"
end

#fetch_player(player_id) ⇒ Object



32
33
34
# File 'lib/onesignal/client.rb', line 32

def fetch_player player_id
  get "players/#{player_id}"
end

#fetch_playersObject



28
29
30
# File 'lib/onesignal/client.rb', line 28

def fetch_players
  get 'players'
end