Class: MTProto::TL::ExportedAuthorization

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, bytes:) ⇒ ExportedAuthorization

Returns a new instance of ExportedAuthorization.



8
9
10
11
# File 'lib/mtproto/tl/objects/exported_authorization.rb', line 8

def initialize(id:, bytes:)
  @id = id
  @bytes = bytes
end

Instance Attribute Details

#bytesObject (readonly)

Returns the value of attribute bytes.



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

def bytes
  @bytes
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Class Method Details

.deserialize(data) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/mtproto/tl/objects/exported_authorization.rb', line 13

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

  id = data[4, 8].unpack1('Q<')
  new(id: id, bytes: read_tl_bytes(data, 12))
end

.read_tl_bytes(data, offset) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/mtproto/tl/objects/exported_authorization.rb', line 21

def self.read_tl_bytes(data, offset)
  first = data.getbyte(offset)
  if first == 254
    len = data.getbyte(offset + 1) | (data.getbyte(offset + 2) << 8) | (data.getbyte(offset + 3) << 16)
    data[offset + 4, len]
  else
    data[offset + 1, first]
  end
end