class NWitchGRPCClient::Notification

Public Class Methods

new() click to toggle source
# 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
push(topic, title, msg) click to toggle source
# 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) click to toggle source
# 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

Public Instance Methods

push(topic, title, msg, token) click to toggle source
# 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

Private Instance Methods

build_req(topic, title, msg, token) click to toggle source
# File lib/nwitch_grpc_client/notification.rb, line 32
def build_req(topic, title, msg, token)
  NWitchGRPC::Protobuf::PushRequest.new(
    nwitch_token: token,
    topic_name: topic,
    title: title,
    message: msg
  )
end