Class: NWitchGRPCClient::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/nwitch_grpc_client/notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNotification

Returns a new instance of Notification.



16
17
18
19
20
21
# File 'lib/nwitch_grpc_client/notification.rb', line 16

def initialize
  host = NWitchGRPCClient.configuration.grpc_host

  @stub = NWitchGRPC::Protobuf::Notification::Stub
    .new(host, :this_channel_is_insecure)
end

Class Method Details

.push(topic, title, msg) ⇒ Object



3
4
5
6
7
8
# File 'lib/nwitch_grpc_client/notification.rb', line 3

def self.push(topic, title, msg)
  token = NWitchGRPCClient.configuration.nwitch_token
  service = self.new

  service.push(topic, title, msg, token)
end

.push_with_token(topic, title, msg, token) ⇒ Object



10
11
12
13
14
# File 'lib/nwitch_grpc_client/notification.rb', line 10

def self.push_with_token(topic, title, msg, token)
  service = self.new

  service.push(topic, title, msg, token)
end

Instance Method Details

#push(topic, title, msg, token) ⇒ Object



23
24
25
26
27
28
# File 'lib/nwitch_grpc_client/notification.rb', line 23

def push(topic, title, msg, token)
  req_params = build_req(topic, title, msg, token)
  req = @stub.push(req_params)

  req.success
end