Sha256: 56fc55caa118bd4b5cb0d57c19f713ded6eb71c11be796caffff6bbe3bacc262

Contents?: true

Size: 1023 Bytes

Versions: 10

Compression:

Stored size: 1023 Bytes

Contents

require 'json'
require 'net/http'
require 'uri'
require 'logger'

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

    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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
direct7-0.0.18 lib/direct7/viber.rb
direct7-0.0.17 lib/direct7/viber.rb
direct7-0.0.16 lib/direct7/viber.rb
direct7-0.0.13 lib/direct7/viber.rb
direct7-0.0.12 lib/direct7/viber.rb
direct7-0.0.11 lib/direct7/viber.rb
direct7-0.0.10 lib/direct7/viber.rb
direct7-0.0.9 lib/direct7/viber.rb
direct7-0.0.8 lib/direct7/viber.rb
direct7-0.0.1 lib/direct7/viber.rb