Class: Direct7::VIBER

Inherits:
Object
  • Object
show all
Defined in:
lib/direct7/viber.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ VIBER

Returns a new instance of VIBER.



8
9
10
11
# File 'lib/direct7/viber.rb', line 8

def initialize(client)
  @client = client
  @log = Logger.new(STDOUT) # You can customize the log destination as needed
end

Instance Method Details

#get_status(request_id) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/direct7/viber.rb', line 30

def get_status(request_id)
  response = @client.get(
    @client.host,
    "/report/v1/viber-log/#{request_id}"
  )
  @log.info('Message status retrieved successfully.')
  response
end

#send_viber_message(recipients, content, label, originator, call_back_url = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/direct7/viber.rb', line 13

def send_viber_message(recipients, content, label, originator, call_back_url = nil)
  message = {
    'channel' => 'viber',
    'recipients' => recipients,
    'content' => content,
    'label' => label
  }
  message_globals = {
    'originator' => originator,
    'call_back_url' => call_back_url
  }

  response = @client.post(@client.host, '/viber/v1/send', true, params= { 'messages' => [message], 'message_globals' => message_globals })
  @log.info('Message sent successfully.')
  response
end