Class: MTProto::TL::Authorization
- Inherits:
-
Object
- Object
- MTProto::TL::Authorization
- Defined in:
- lib/mtproto/tl/objects/authorization.rb
Instance Attribute Summary collapse
-
#access_hash ⇒ Object
readonly
Returns the value of attribute access_hash.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#sign_up_required ⇒ Object
readonly
Returns the value of attribute sign_up_required.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Class Method Summary collapse
Instance Method Summary collapse
- #authorization? ⇒ Boolean
-
#initialize(user_id: nil, access_hash: nil, flags: 0, sign_up_required: false) ⇒ Authorization
constructor
A new instance of Authorization.
Constructor Details
#initialize(user_id: nil, access_hash: nil, flags: 0, sign_up_required: false) ⇒ Authorization
Returns a new instance of Authorization.
8 9 10 11 12 13 |
# File 'lib/mtproto/tl/objects/authorization.rb', line 8 def initialize(user_id: nil, access_hash: nil, flags: 0, sign_up_required: false) @user_id = user_id @access_hash = access_hash @flags = flags @sign_up_required = sign_up_required end |
Instance Attribute Details
#access_hash ⇒ Object (readonly)
Returns the value of attribute access_hash.
6 7 8 |
# File 'lib/mtproto/tl/objects/authorization.rb', line 6 def access_hash @access_hash end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
6 7 8 |
# File 'lib/mtproto/tl/objects/authorization.rb', line 6 def flags @flags end |
#sign_up_required ⇒ Object (readonly)
Returns the value of attribute sign_up_required.
6 7 8 |
# File 'lib/mtproto/tl/objects/authorization.rb', line 6 def sign_up_required @sign_up_required end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
6 7 8 |
# File 'lib/mtproto/tl/objects/authorization.rb', line 6 def user_id @user_id end |
Class Method Details
.deserialize(data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mtproto/tl/objects/authorization.rb', line 19 def self.deserialize(data) constructor = data[0, 4].unpack1('L<') return new(sign_up_required: true) if constructor == Constructors::AUTH_AUTHORIZATION_SIGN_UP_REQUIRED raise UnexpectedConstructorError, constructor unless constructor == Constructors::AUTH_AUTHORIZATION offset = 4 flags = data[offset, 4].unpack1('L<') offset += 4 offset += 4 if flags.anybits?(1 << 0) # tmp_sessions offset += 4 if flags.anybits?(1 << 1) # otherwise_relogin_days offset = skip_tl_bytes(data, offset) if flags.anybits?(1 << 2) # future_auth_token # user#20b1422 flags:# flags2:# id:long access_hash:flags.0?long ... offset += 4 # user constructor user_flags = data[offset, 4].unpack1('L<') offset += 4 offset += 4 # flags2 user_id = data[offset, 8].unpack1('Q<') offset += 8 access_hash = nil access_hash = data[offset, 8].unpack1('Q<') if user_flags.anybits?(1 << 0) new(user_id: user_id, access_hash: access_hash, flags: flags) end |
Instance Method Details
#authorization? ⇒ Boolean
15 16 17 |
# File 'lib/mtproto/tl/objects/authorization.rb', line 15 def !@sign_up_required && @user_id end |