Class: Telegram::AuthProperties

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/telegram/auth_properties.rb

Overview

Telegram client authorization properties

Available options:

* phone_number: phone number which will be authorized
* confirmation: proc which should return confirmation code received via
                text message, or call
* register(optional): hash with two options
  - :first_name: user first name
  - :last_name: user last name

Constant Summary collapse

DEFAULT_OPTIONS =
{
  confirmation: -> {},
  registration: {},
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AuthProperties

Returns a new instance of AuthProperties.



25
26
27
# File 'lib/telegram/auth_properties.rb', line 25

def initialize(options = {})
  @options = OpenStruct.new(DEFAULT_OPTIONS.merge(options))
end

Instance Method Details

#present?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/telegram/auth_properties.rb', line 34

def present?
  !phone_number.nil?
end

#register?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/telegram/auth_properties.rb', line 29

def register?
  registration.include?(:first_name) &&
    registration.include?(:last_name)
end