Class: RubyVibe::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-vibe/client.rb

Overview

This class is almost never used directly by user. Send actual request to viber api and perform type validation for token, name and avatar (must be strings).

Direct Known Subclasses

Bot

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token: nil, name: nil, avatar: nil) ⇒ Object

Examples:

Initialize new client


@client = Client.new(token: 'token', name: 'name', avatar: 'https_url')

Parameters:

  • token (String) (defaults to: nil)

    Required. Viber auth token.

  • name (String) (defaults to: nil)

    Required. Sender name.

  • avatar (String) (defaults to: nil)

    Optional. Avatar url.

Raises:

  • (Token must be string)

    Token must be string.

  • (Name must be string)

    Name must be string.

  • (Avatar must use SSL)

    If defined, avatar must use https connection.



34
35
36
37
38
39
40
41
42
43
# File 'lib/ruby-vibe/client.rb', line 34

def initialize(token: nil, name: nil, avatar: nil)
  raise 'Token must be string!' unless token.is_a? String
  raise 'Sender name must be string' unless name.is_a? String

  raise 'Avatar URL must use SSL' if !avatar.empty? && !(avatar.start_with? 'https://')

  @token = token
  @name = name
  @avatar = avatar
end

Instance Attribute Details

#avatarObject

Returns the value of attribute avatar.



13
14
15
# File 'lib/ruby-vibe/client.rb', line 13

def avatar
  @avatar
end

#nameObject Also known as: sender

Returns the value of attribute name.



13
14
15
# File 'lib/ruby-vibe/client.rb', line 13

def name
  @name
end

#payload_hashObject (readonly)

Returns the value of attribute payload_hash.



15
16
17
# File 'lib/ruby-vibe/client.rb', line 15

def payload_hash
  @payload_hash
end

#responseObject (readonly)

Returns the value of attribute response.



15
16
17
# File 'lib/ruby-vibe/client.rb', line 15

def response
  @response
end

#tokenObject

Returns the value of attribute token.



13
14
15
# File 'lib/ruby-vibe/client.rb', line 13

def token
  @token
end