Class: MTProto::TL::SentCode

Inherits:
Object
  • Object
show all
Defined in:
lib/mtproto/tl/objects/sent_code.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flags:, type:, phone_code_hash:, next_type: nil, timeout: nil) ⇒ SentCode

Returns a new instance of SentCode.



8
9
10
11
12
13
14
# File 'lib/mtproto/tl/objects/sent_code.rb', line 8

def initialize(flags:, type:, phone_code_hash:, next_type: nil, timeout: nil)
  @flags = flags
  @type = type
  @phone_code_hash = phone_code_hash
  @next_type = next_type
  @timeout = timeout
end

Instance Attribute Details

#flagsObject (readonly)

Returns the value of attribute flags.



6
7
8
# File 'lib/mtproto/tl/objects/sent_code.rb', line 6

def flags
  @flags
end

#next_typeObject (readonly)

Returns the value of attribute next_type.



6
7
8
# File 'lib/mtproto/tl/objects/sent_code.rb', line 6

def next_type
  @next_type
end

#phone_code_hashObject (readonly)

Returns the value of attribute phone_code_hash.



6
7
8
# File 'lib/mtproto/tl/objects/sent_code.rb', line 6

def phone_code_hash
  @phone_code_hash
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



6
7
8
# File 'lib/mtproto/tl/objects/sent_code.rb', line 6

def timeout
  @timeout
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/mtproto/tl/objects/sent_code.rb', line 6

def type
  @type
end

Class Method Details

.deserialize(data) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mtproto/tl/objects/sent_code.rb', line 16

def self.deserialize(data)
  constructor = data[0, 4].unpack1('L<')
  raise UnexpectedConstructorError, constructor unless constructor == Constructors::AUTH_SENT_CODE

  offset = 4
  flags = data[offset, 4].unpack1('L<')
  offset += 4

  type, offset = parse_sent_code_type(data, offset)

  phone_code_hash, offset = read_tl_string(data, offset)

  next_type = nil
  next_type, offset = parse_code_type(data, offset) if flags.anybits?(1 << 1)

  timeout = nil
  timeout = data[offset, 4].unpack1('L<') if flags.anybits?(1 << 2)

  new(flags: flags, type: type, phone_code_hash: phone_code_hash, next_type: next_type, timeout: timeout)
end